mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-26 14:43:24 +00:00
auto merge of #7523 : huonw/rust/uppercase-statics-lint, r=cmr
Adds a lint for `static some_lowercase_name: uint = 1;`. Warning by default since it causes confusion, e.g. `static a: uint = 1; ... let a = 2;` => `error: only refutable patterns allowed here`.
This commit is contained in:
commit
55f155521d
12
doc/rust.md
12
doc/rust.md
@ -1107,11 +1107,11 @@ The derived types are borrowed pointers with the `'static` lifetime,
|
||||
fixed-size arrays, tuples, and structs.
|
||||
|
||||
~~~~
|
||||
static bit1: uint = 1 << 0;
|
||||
static bit2: uint = 1 << 1;
|
||||
static BIT1: uint = 1 << 0;
|
||||
static BIT2: uint = 1 << 1;
|
||||
|
||||
static bits: [uint, ..2] = [bit1, bit2];
|
||||
static string: &'static str = "bitstring";
|
||||
static BITS: [uint, ..2] = [BIT1, BIT2];
|
||||
static STRING: &'static str = "bitstring";
|
||||
|
||||
struct BitsNStrings<'self> {
|
||||
mybits: [uint, ..2],
|
||||
@ -1119,8 +1119,8 @@ struct BitsNStrings<'self> {
|
||||
}
|
||||
|
||||
static bits_n_strings: BitsNStrings<'static> = BitsNStrings {
|
||||
mybits: bits,
|
||||
mystring: string
|
||||
mybits: BITS,
|
||||
mystring: STRING
|
||||
};
|
||||
~~~~
|
||||
|
||||
|
@ -237,8 +237,8 @@ can specify a variable's type by following it with a colon, then the type
|
||||
name. Static items, on the other hand, always require a type annotation.
|
||||
|
||||
~~~~
|
||||
static monster_factor: float = 57.8;
|
||||
let monster_size = monster_factor * 10.0;
|
||||
static MONSTER_FACTOR: float = 57.8;
|
||||
let monster_size = MONSTER_FACTOR * 10.0;
|
||||
let monster_size: int = 50;
|
||||
~~~~
|
||||
|
||||
|
@ -79,8 +79,8 @@ 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;
|
||||
if ProcRes.status == valgrind_err {
|
||||
static VALGRIND_ERR: int = 100;
|
||||
if ProcRes.status == VALGRIND_ERR {
|
||||
fatal_ProcRes(~"run-fail test isn't valgrind-clean!", &ProcRes);
|
||||
}
|
||||
|
||||
@ -102,8 +102,8 @@ fn run_rfail_test(config: &config, props: &TestProps, testfile: &Path) {
|
||||
|
||||
fn check_correct_failure_status(ProcRes: &ProcRes) {
|
||||
// The value the rust runtime returns on failure
|
||||
static rust_err: int = 101;
|
||||
if ProcRes.status != rust_err {
|
||||
static RUST_ERR: int = 101;
|
||||
if ProcRes.status != RUST_ERR {
|
||||
fatal_ProcRes(
|
||||
fmt!("failure produced the wrong error code: %d",
|
||||
ProcRes.status),
|
||||
|
@ -250,6 +250,7 @@ rf.write('''// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGH
|
||||
// The following code was generated by "src/etc/unicode.py"
|
||||
|
||||
#[allow(missing_doc)];
|
||||
#[allow(non_uppercase_statics)];
|
||||
|
||||
''')
|
||||
|
||||
|
@ -872,7 +872,7 @@ mod tests {
|
||||
use std::rand;
|
||||
use std::rand::Rng;
|
||||
|
||||
static bench_bits : uint = 1 << 14;
|
||||
static BENCH_BITS : uint = 1 << 14;
|
||||
|
||||
#[test]
|
||||
fn test_to_str() {
|
||||
@ -1452,19 +1452,19 @@ mod tests {
|
||||
fn bench_big_bitv_big(b: &mut BenchHarness) {
|
||||
let mut r = rng();
|
||||
let mut storage = ~[];
|
||||
storage.grow(bench_bits / uint::bits, &0);
|
||||
storage.grow(BENCH_BITS / uint::bits, &0);
|
||||
let mut bitv = BigBitv::new(storage);
|
||||
do b.iter {
|
||||
bitv.set((r.next() as uint) % bench_bits, true);
|
||||
bitv.set((r.next() as uint) % BENCH_BITS, true);
|
||||
}
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn bench_bitv_big(b: &mut BenchHarness) {
|
||||
let mut r = rng();
|
||||
let mut bitv = Bitv::new(bench_bits, false);
|
||||
let mut bitv = Bitv::new(BENCH_BITS, false);
|
||||
do b.iter {
|
||||
bitv.set((r.next() as uint) % bench_bits, true);
|
||||
bitv.set((r.next() as uint) % BENCH_BITS, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1491,14 +1491,14 @@ mod tests {
|
||||
let mut r = rng();
|
||||
let mut bitv = BitvSet::new();
|
||||
do b.iter {
|
||||
bitv.insert((r.next() as uint) % bench_bits);
|
||||
bitv.insert((r.next() as uint) % BENCH_BITS);
|
||||
}
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn bench_bitv_big_union(b: &mut BenchHarness) {
|
||||
let mut b1 = Bitv::new(bench_bits, false);
|
||||
let b2 = Bitv::new(bench_bits, false);
|
||||
let mut b1 = Bitv::new(BENCH_BITS, false);
|
||||
let b2 = Bitv::new(BENCH_BITS, false);
|
||||
do b.iter {
|
||||
b1.union(&b2);
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ use std::util::replace;
|
||||
use std::vec;
|
||||
use std::cast::transmute;
|
||||
|
||||
static initial_capacity: uint = 32u; // 2^5
|
||||
static INITIAL_CAPACITY: uint = 32u; // 2^5
|
||||
|
||||
#[allow(missing_doc)]
|
||||
pub struct Deque<T> {
|
||||
@ -47,7 +47,7 @@ impl<T> Deque<T> {
|
||||
/// Create an empty Deque
|
||||
pub fn new() -> Deque<T> {
|
||||
Deque{nelts: 0, lo: 0, hi: 0,
|
||||
elts: vec::from_fn(initial_capacity, |_| None)}
|
||||
elts: vec::from_fn(INITIAL_CAPACITY, |_| None)}
|
||||
}
|
||||
|
||||
/// Return a reference to the first element in the deque
|
||||
|
@ -748,7 +748,7 @@ pub mod writer {
|
||||
|
||||
// Set to true to generate more debugging in EBML code.
|
||||
// Totally lame approach.
|
||||
static debug: bool = true;
|
||||
static DEBUG: bool = true;
|
||||
|
||||
impl Encoder {
|
||||
// used internally to emit things like the vector length and so on
|
||||
@ -764,7 +764,7 @@ pub mod writer {
|
||||
// efficiency. When debugging, though, we can emit such
|
||||
// labels and then they will be checked by decoder to
|
||||
// try and check failures more quickly.
|
||||
if debug { self.wr_tagged_str(EsLabel as uint, label) }
|
||||
if DEBUG { self.wr_tagged_str(EsLabel as uint, label) }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,10 +39,10 @@ pub mod rustrt {
|
||||
}
|
||||
}
|
||||
|
||||
static lz_none : c_int = 0x0; // Huffman-coding only.
|
||||
static lz_fast : c_int = 0x1; // LZ with only one probe
|
||||
static lz_norm : c_int = 0x80; // LZ with 128 probes, "normal"
|
||||
static lz_best : c_int = 0xfff; // LZ with 4095 probes, "best"
|
||||
static LZ_NONE : c_int = 0x0; // Huffman-coding only.
|
||||
static LZ_FAST : c_int = 0x1; // LZ with only one probe
|
||||
static LZ_NORM : c_int = 0x80; // LZ with 128 probes, "normal"
|
||||
static LZ_BEST : c_int = 0xfff; // LZ with 4095 probes, "best"
|
||||
|
||||
pub fn deflate_bytes(bytes: &[u8]) -> ~[u8] {
|
||||
do vec::as_imm_buf(bytes) |b, len| {
|
||||
@ -52,7 +52,7 @@ pub fn deflate_bytes(bytes: &[u8]) -> ~[u8] {
|
||||
rustrt::tdefl_compress_mem_to_heap(b as *c_void,
|
||||
len as size_t,
|
||||
&mut outsz,
|
||||
lz_norm);
|
||||
LZ_NORM);
|
||||
assert!(res as int != 0);
|
||||
let out = vec::raw::from_buf_raw(res as *u8,
|
||||
outsz as uint);
|
||||
|
@ -17,6 +17,7 @@ A BigInt is a combination of BigUint and Sign.
|
||||
*/
|
||||
|
||||
#[allow(missing_doc)];
|
||||
#[allow(non_uppercase_statics)];
|
||||
|
||||
use std::cmp::{Eq, Ord, TotalEq, TotalOrd, Ordering, Less, Equal, Greater};
|
||||
use std::int;
|
||||
|
@ -191,6 +191,8 @@ impl<T: ToStrRadix + Num + Ord> ToStrRadix for Cmplx<T> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
#[allow(non_uppercase_statics)];
|
||||
|
||||
use super::*;
|
||||
use std::num::{Zero,One,Real};
|
||||
|
||||
|
@ -20,10 +20,10 @@ use future_spawn = future::spawn;
|
||||
* The maximum number of tasks this module will spawn for a single
|
||||
* operation.
|
||||
*/
|
||||
static max_tasks : uint = 32u;
|
||||
static MAX_TASKS : uint = 32u;
|
||||
|
||||
/// The minimum number of elements each task will process.
|
||||
static min_granularity : uint = 1024u;
|
||||
static MIN_GRANULARITY : uint = 1024u;
|
||||
|
||||
/**
|
||||
* An internal helper to map a function over a large vector and
|
||||
@ -38,13 +38,13 @@ fn map_slices<A:Copy + Send,B:Copy + Send>(
|
||||
-> ~[B] {
|
||||
|
||||
let len = xs.len();
|
||||
if len < min_granularity {
|
||||
if len < MIN_GRANULARITY {
|
||||
info!("small slice");
|
||||
// This is a small vector, fall back on the normal map.
|
||||
~[f()(0u, xs)]
|
||||
}
|
||||
else {
|
||||
let num_tasks = uint::min(max_tasks, len / min_granularity);
|
||||
let num_tasks = uint::min(MAX_TASKS, len / MIN_GRANULARITY);
|
||||
|
||||
let items_per_task = len / num_tasks;
|
||||
|
||||
|
@ -632,14 +632,14 @@ pub mod node {
|
||||
*
|
||||
* This is not a strict value
|
||||
*/
|
||||
pub static hint_max_leaf_char_len: uint = 256u;
|
||||
pub static HINT_MAX_LEAF_CHAR_LEN: uint = 256u;
|
||||
|
||||
/**
|
||||
* The maximal height that _should_ be permitted in a tree.
|
||||
*
|
||||
* This is not a strict value
|
||||
*/
|
||||
pub static hint_max_node_height: uint = 16u;
|
||||
pub static HINT_MAX_NODE_HEIGHT: uint = 16u;
|
||||
|
||||
/**
|
||||
* Adopt a string as a node.
|
||||
@ -707,26 +707,26 @@ pub mod node {
|
||||
char_len: char_len,
|
||||
content: str,
|
||||
});
|
||||
if char_len <= hint_max_leaf_char_len {
|
||||
if char_len <= HINT_MAX_LEAF_CHAR_LEN {
|
||||
return candidate;
|
||||
} else {
|
||||
//Firstly, split `str` in slices of hint_max_leaf_char_len
|
||||
let mut leaves = uint::div_ceil(char_len, hint_max_leaf_char_len);
|
||||
//Firstly, split `str` in slices of HINT_MAX_LEAF_CHAR_LEN
|
||||
let mut leaves = uint::div_ceil(char_len, HINT_MAX_LEAF_CHAR_LEN);
|
||||
//Number of leaves
|
||||
let mut nodes = vec::from_elem(leaves, candidate);
|
||||
|
||||
let mut i = 0u;
|
||||
let mut offset = byte_start;
|
||||
let first_leaf_char_len =
|
||||
if char_len%hint_max_leaf_char_len == 0u {
|
||||
hint_max_leaf_char_len
|
||||
if char_len%HINT_MAX_LEAF_CHAR_LEN == 0u {
|
||||
HINT_MAX_LEAF_CHAR_LEN
|
||||
} else {
|
||||
char_len%hint_max_leaf_char_len
|
||||
char_len%HINT_MAX_LEAF_CHAR_LEN
|
||||
};
|
||||
while i < leaves {
|
||||
let chunk_char_len: uint =
|
||||
if i == 0u { first_leaf_char_len }
|
||||
else { hint_max_leaf_char_len };
|
||||
else { HINT_MAX_LEAF_CHAR_LEN };
|
||||
let chunk_byte_len =
|
||||
str.slice_from(offset).slice_chars(0, chunk_char_len).len();
|
||||
nodes[i] = @Leaf(Leaf {
|
||||
@ -792,22 +792,22 @@ pub mod node {
|
||||
let right_len= char_len(right);
|
||||
let mut left_height= height(left);
|
||||
let mut right_height=height(right);
|
||||
if left_len + right_len > hint_max_leaf_char_len {
|
||||
if left_len <= hint_max_leaf_char_len {
|
||||
if left_len + right_len > HINT_MAX_LEAF_CHAR_LEN {
|
||||
if left_len <= HINT_MAX_LEAF_CHAR_LEN {
|
||||
left = flatten(left);
|
||||
left_height = height(left);
|
||||
}
|
||||
if right_len <= hint_max_leaf_char_len {
|
||||
if right_len <= HINT_MAX_LEAF_CHAR_LEN {
|
||||
right = flatten(right);
|
||||
right_height = height(right);
|
||||
}
|
||||
}
|
||||
if left_height >= hint_max_node_height {
|
||||
if left_height >= HINT_MAX_NODE_HEIGHT {
|
||||
left = of_substr_unsafer(@serialize_node(left),
|
||||
0u,byte_len(left),
|
||||
left_len);
|
||||
}
|
||||
if right_height >= hint_max_node_height {
|
||||
if right_height >= HINT_MAX_NODE_HEIGHT {
|
||||
right = of_substr_unsafer(@serialize_node(right),
|
||||
0u,byte_len(right),
|
||||
right_len);
|
||||
@ -875,7 +875,7 @@ pub mod node {
|
||||
*
|
||||
* # Algorithm
|
||||
*
|
||||
* * if the node height is smaller than `hint_max_node_height`, do nothing
|
||||
* * if the node height is smaller than `HINT_MAX_NODE_HEIGHT`, do nothing
|
||||
* * otherwise, gather all leaves as a forest, rebuild a balanced node,
|
||||
* concatenating small leaves along the way
|
||||
*
|
||||
@ -886,7 +886,7 @@ pub mod node {
|
||||
* as `node` bot lower height and/or fragmentation.
|
||||
*/
|
||||
pub fn bal(node: @Node) -> Option<@Node> {
|
||||
if height(node) < hint_max_node_height { return None; }
|
||||
if height(node) < HINT_MAX_NODE_HEIGHT { return None; }
|
||||
//1. Gather all leaves as a forest
|
||||
let mut forest = ~[];
|
||||
let mut it = leaf_iterator::start(node);
|
||||
|
@ -26,23 +26,23 @@ use std::io;
|
||||
pub mod color {
|
||||
pub type Color = u16;
|
||||
|
||||
pub static black: Color = 0u16;
|
||||
pub static red: Color = 1u16;
|
||||
pub static green: Color = 2u16;
|
||||
pub static yellow: Color = 3u16;
|
||||
pub static blue: Color = 4u16;
|
||||
pub static magenta: Color = 5u16;
|
||||
pub static cyan: Color = 6u16;
|
||||
pub static white: Color = 7u16;
|
||||
pub static BLACK: Color = 0u16;
|
||||
pub static RED: Color = 1u16;
|
||||
pub static GREEN: Color = 2u16;
|
||||
pub static YELLOW: Color = 3u16;
|
||||
pub static BLUE: Color = 4u16;
|
||||
pub static MAGENTA: Color = 5u16;
|
||||
pub static CYAN: Color = 6u16;
|
||||
pub static WHITE: Color = 7u16;
|
||||
|
||||
pub static bright_black: Color = 8u16;
|
||||
pub static bright_red: Color = 9u16;
|
||||
pub static bright_green: Color = 10u16;
|
||||
pub static bright_yellow: Color = 11u16;
|
||||
pub static bright_blue: Color = 12u16;
|
||||
pub static bright_magenta: Color = 13u16;
|
||||
pub static bright_cyan: Color = 14u16;
|
||||
pub static bright_white: Color = 15u16;
|
||||
pub static BRIGHT_BLACK: Color = 8u16;
|
||||
pub static BRIGHT_RED: Color = 9u16;
|
||||
pub static BRIGHT_GREEN: Color = 10u16;
|
||||
pub static BRIGHT_YELLOW: Color = 11u16;
|
||||
pub static BRIGHT_BLUE: Color = 12u16;
|
||||
pub static BRIGHT_MAGENTA: Color = 13u16;
|
||||
pub static BRIGHT_CYAN: Color = 14u16;
|
||||
pub static BRIGHT_WHITE: Color = 15u16;
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "win32"))]
|
||||
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[allow(non_uppercase_statics)];
|
||||
|
||||
/// ncurses-compatible compiled terminfo format parsing (term(5))
|
||||
|
||||
|
||||
|
@ -331,19 +331,19 @@ pub fn run_tests_console(opts: &TestOpts,
|
||||
}
|
||||
|
||||
fn write_ok(out: @io::Writer, use_color: bool) {
|
||||
write_pretty(out, "ok", term::color::green, use_color);
|
||||
write_pretty(out, "ok", term::color::GREEN, use_color);
|
||||
}
|
||||
|
||||
fn write_failed(out: @io::Writer, use_color: bool) {
|
||||
write_pretty(out, "FAILED", term::color::red, use_color);
|
||||
write_pretty(out, "FAILED", term::color::RED, use_color);
|
||||
}
|
||||
|
||||
fn write_ignored(out: @io::Writer, use_color: bool) {
|
||||
write_pretty(out, "ignored", term::color::yellow, use_color);
|
||||
write_pretty(out, "ignored", term::color::YELLOW, use_color);
|
||||
}
|
||||
|
||||
fn write_bench(out: @io::Writer, use_color: bool) {
|
||||
write_pretty(out, "bench", term::color::cyan, use_color);
|
||||
write_pretty(out, "bench", term::color::CYAN, use_color);
|
||||
}
|
||||
|
||||
fn write_pretty(out: @io::Writer,
|
||||
@ -487,16 +487,16 @@ fn run_tests(opts: &TestOpts,
|
||||
|
||||
// Windows tends to dislike being overloaded with threads.
|
||||
#[cfg(windows)]
|
||||
static sched_overcommit : uint = 1;
|
||||
static SCHED_OVERCOMMIT : uint = 1;
|
||||
|
||||
#[cfg(unix)]
|
||||
static sched_overcommit : uint = 4u;
|
||||
static SCHED_OVERCOMMIT : uint = 4u;
|
||||
|
||||
fn get_concurrency() -> uint {
|
||||
unsafe {
|
||||
let threads = rustrt::rust_sched_threads() as uint;
|
||||
if threads == 1 { 1 }
|
||||
else { threads * sched_overcommit }
|
||||
else { threads * SCHED_OVERCOMMIT }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -868,20 +868,20 @@ mod tests {
|
||||
use std::str;
|
||||
|
||||
fn test_get_time() {
|
||||
static some_recent_date: i64 = 1325376000i64; // 2012-01-01T00:00:00Z
|
||||
static some_future_date: i64 = 1577836800i64; // 2020-01-01T00:00:00Z
|
||||
static SOME_RECENT_DATE: i64 = 1325376000i64; // 2012-01-01T00:00:00Z
|
||||
static SOME_FUTURE_DATE: i64 = 1577836800i64; // 2020-01-01T00:00:00Z
|
||||
|
||||
let tv1 = get_time();
|
||||
debug!("tv1=%? sec + %? nsec", tv1.sec as uint, tv1.nsec as uint);
|
||||
|
||||
assert!(tv1.sec > some_recent_date);
|
||||
assert!(tv1.sec > SOME_RECENT_DATE);
|
||||
assert!(tv1.nsec < 1000000000i32);
|
||||
|
||||
let tv2 = get_time();
|
||||
debug!("tv2=%? sec + %? nsec", tv2.sec as uint, tv2.nsec as uint);
|
||||
|
||||
assert!(tv2.sec >= tv1.sec);
|
||||
assert!(tv2.sec < some_future_date);
|
||||
assert!(tv2.sec < SOME_FUTURE_DATE);
|
||||
assert!(tv2.nsec < 1000000000i32);
|
||||
if tv2.sec == tv1.sec {
|
||||
assert!(tv2.nsec >= tv1.nsec);
|
||||
|
@ -60,7 +60,7 @@ struct Command<'self> {
|
||||
usage_full: UsageSource<'self>,
|
||||
}
|
||||
|
||||
static commands: &'static [Command<'static>] = &[
|
||||
static COMMANDS: &'static [Command<'static>] = &[
|
||||
Command{
|
||||
cmd: "build",
|
||||
action: CallMain("rustc", rustc::main),
|
||||
@ -122,7 +122,7 @@ fn rustc_help() {
|
||||
}
|
||||
|
||||
fn find_cmd(command_string: &str) -> Option<Command> {
|
||||
do commands.iter().find_ |command| {
|
||||
do COMMANDS.iter().find_ |command| {
|
||||
command.cmd == command_string
|
||||
}.map_consume(|x| copy *x)
|
||||
}
|
||||
@ -197,7 +197,7 @@ fn do_command(command: &Command, args: &[~str]) -> ValidUsage {
|
||||
}
|
||||
|
||||
fn usage() {
|
||||
static indent: uint = 8;
|
||||
static INDENT: uint = 8;
|
||||
|
||||
io::print(
|
||||
"The rust tool is a convenience for managing rust source code.\n\
|
||||
@ -209,8 +209,8 @@ fn usage() {
|
||||
\n"
|
||||
);
|
||||
|
||||
for commands.iter().advance |command| {
|
||||
let padding = " ".repeat(indent - command.cmd.len());
|
||||
for COMMANDS.iter().advance |command| {
|
||||
let padding = " ".repeat(INDENT - command.cmd.len());
|
||||
io::println(fmt!(" %s%s%s",
|
||||
command.cmd, padding, command.usage_line));
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ use middle::ty;
|
||||
use middle::pat_util;
|
||||
use util::ppaux::{ty_to_str};
|
||||
|
||||
use std::char;
|
||||
use std::cmp;
|
||||
use std::hashmap::HashMap;
|
||||
use std::i16;
|
||||
@ -80,6 +79,7 @@ pub enum lint {
|
||||
non_implicitly_copyable_typarams,
|
||||
deprecated_pattern,
|
||||
non_camel_case_types,
|
||||
non_uppercase_statics,
|
||||
type_limits,
|
||||
default_methods,
|
||||
unused_unsafe,
|
||||
@ -198,6 +198,13 @@ static lint_table: &'static [(&'static str, LintSpec)] = &[
|
||||
default: allow
|
||||
}),
|
||||
|
||||
("non_uppercase_statics",
|
||||
LintSpec {
|
||||
lint: non_uppercase_statics,
|
||||
desc: "static constants should have uppercase identifiers",
|
||||
default: warn
|
||||
}),
|
||||
|
||||
("managed_heap_memory",
|
||||
LintSpec {
|
||||
lint: managed_heap_memory,
|
||||
@ -854,7 +861,10 @@ fn check_item_non_camel_case_types(cx: &Context, it: &ast::item) {
|
||||
let ident = cx.sess.str_of(ident);
|
||||
assert!(!ident.is_empty());
|
||||
let ident = ident.trim_chars(&'_');
|
||||
char::is_uppercase(ident.char_at(0)) &&
|
||||
|
||||
// start with a non-lowercase letter rather than non-uppercase
|
||||
// ones (some scripts don't have a concept of upper/lowercase)
|
||||
!ident.char_at(0).is_lowercase() &&
|
||||
!ident.contains_char('_')
|
||||
}
|
||||
|
||||
@ -881,6 +891,23 @@ fn check_item_non_camel_case_types(cx: &Context, it: &ast::item) {
|
||||
}
|
||||
}
|
||||
|
||||
fn check_item_non_uppercase_statics(cx: &Context, it: &ast::item) {
|
||||
match it.node {
|
||||
// only check static constants
|
||||
ast::item_static(_, ast::m_imm, _) => {
|
||||
let s = cx.tcx.sess.str_of(it.ident);
|
||||
// check for lowercase letters rather than non-uppercase
|
||||
// ones (some scripts don't have a concept of
|
||||
// upper/lowercase)
|
||||
if s.iter().any_(|c| c.is_lowercase()) {
|
||||
cx.span_lint(non_uppercase_statics, it.span,
|
||||
"static constant should have an uppercase identifier");
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn lint_unused_unsafe() -> visit::vt<@mut Context> {
|
||||
visit::mk_vt(@visit::Visitor {
|
||||
visit_expr: |e, (cx, vt): (@mut Context, visit::vt<@mut Context>)| {
|
||||
@ -1143,6 +1170,7 @@ pub fn check_crate(tcx: ty::ctxt, crate: @ast::crate) {
|
||||
}
|
||||
check_item_ctypes(cx, it);
|
||||
check_item_non_camel_case_types(cx, it);
|
||||
check_item_non_uppercase_statics(cx, it);
|
||||
check_item_default_methods(cx, it);
|
||||
check_item_heap(cx, it);
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#[allow(non_implicitly_copyable_typarams)];
|
||||
#[allow(non_camel_case_types)];
|
||||
#[allow(non_uppercase_statics)];
|
||||
#[deny(deprecated_pattern)];
|
||||
|
||||
extern mod extra;
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
|
||||
/// The base price of a muffin on a non-holiday
|
||||
static price_of_a_muffin: float = 70f;
|
||||
static PRICE_OF_A_MUFFIN: float = 70f;
|
||||
|
||||
struct WaitPerson {
|
||||
hair_color: ~str
|
||||
|
@ -87,11 +87,11 @@ pub fn extract(desc: Option<~str>) -> Option<~str> {
|
||||
}
|
||||
|
||||
fn parse_desc(desc: ~str) -> Option<~str> {
|
||||
static max_brief_len: uint = 120u;
|
||||
static MAX_BRIEF_LEN: uint = 120u;
|
||||
|
||||
match first_sentence(copy desc) {
|
||||
Some(first_sentence) => {
|
||||
if first_sentence.len() <= max_brief_len {
|
||||
if first_sentence.len() <= MAX_BRIEF_LEN {
|
||||
Some(first_sentence)
|
||||
} else {
|
||||
None
|
||||
|
@ -13,15 +13,15 @@ use std::io;
|
||||
use std::result::*;
|
||||
|
||||
pub fn note(msg: &str) {
|
||||
pretty_message(msg, "note: ", term::color::green, io::stdout())
|
||||
pretty_message(msg, "note: ", term::color::GREEN, io::stdout())
|
||||
}
|
||||
|
||||
pub fn warn(msg: &str) {
|
||||
pretty_message(msg, "warning: ", term::color::yellow, io::stdout())
|
||||
pretty_message(msg, "warning: ", term::color::YELLOW, io::stdout())
|
||||
}
|
||||
|
||||
pub fn error(msg: &str) {
|
||||
pretty_message(msg, "error: ", term::color::red, io::stdout())
|
||||
pretty_message(msg, "error: ", term::color::RED, io::stdout())
|
||||
}
|
||||
|
||||
fn pretty_message<'a>(msg: &'a str, prefix: &'a str, color: term::color::Color, out: @io::Writer) {
|
||||
|
@ -29,9 +29,9 @@ fn push_if_exists(vec: &mut ~[Path], p: &Path) {
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
static path_entry_separator: &'static str = ";";
|
||||
static PATH_ENTRY_SEPARATOR: &'static str = ";";
|
||||
#[cfg(not(windows))]
|
||||
static path_entry_separator: &'static str = ":";
|
||||
static PATH_ENTRY_SEPARATOR: &'static str = ":";
|
||||
|
||||
/// Returns the value of RUST_PATH, as a list
|
||||
/// of Paths. Includes default entries for, if they exist:
|
||||
@ -42,7 +42,7 @@ pub fn rust_path() -> ~[Path] {
|
||||
let mut env_rust_path: ~[Path] = match os::getenv("RUST_PATH") {
|
||||
Some(env_path) => {
|
||||
let env_path_components: ~[&str] =
|
||||
env_path.split_str_iter(path_entry_separator).collect();
|
||||
env_path.split_str_iter(PATH_ENTRY_SEPARATOR).collect();
|
||||
env_path_components.map(|&s| Path(s))
|
||||
}
|
||||
None => ~[]
|
||||
@ -56,12 +56,12 @@ pub fn rust_path() -> ~[Path] {
|
||||
env_rust_path
|
||||
}
|
||||
|
||||
pub static u_rwx: i32 = (S_IRUSR | S_IWUSR | S_IXUSR) as i32;
|
||||
pub static U_RWX: i32 = (S_IRUSR | S_IWUSR | S_IXUSR) as i32;
|
||||
|
||||
/// Creates a directory that is readable, writeable,
|
||||
/// and executable by the user. Returns true iff creation
|
||||
/// succeeded.
|
||||
pub fn make_dir_rwx(p: &Path) -> bool { os::make_dir(p, u_rwx) }
|
||||
pub fn make_dir_rwx(p: &Path) -> bool { os::make_dir(p, U_RWX) }
|
||||
|
||||
// n.b. The next three functions ignore the package version right
|
||||
// now. Should fix that.
|
||||
@ -318,7 +318,7 @@ fn target_file_in_workspace(pkgid: &PkgId, workspace: &Path,
|
||||
Lib => "lib", Main | Test | Bench => "bin"
|
||||
};
|
||||
let result = workspace.push(subdir);
|
||||
if !os::path_exists(&result) && !mkdir_recursive(&result, u_rwx) {
|
||||
if !os::path_exists(&result) && !mkdir_recursive(&result, U_RWX) {
|
||||
cond.raise((copy result, fmt!("target_file_in_workspace couldn't \
|
||||
create the %s dir (pkgid=%s, workspace=%s, what=%?, where=%?",
|
||||
subdir, pkgid.to_str(), workspace.to_str(), what, where)));
|
||||
@ -335,7 +335,7 @@ pub fn build_pkg_id_in_workspace(pkgid: &PkgId, workspace: &Path) -> Path {
|
||||
// n.b. Should actually use a target-specific
|
||||
// subdirectory of build/
|
||||
result = result.push_rel(&*pkgid.local_path);
|
||||
if os::path_exists(&result) || os::mkdir_recursive(&result, u_rwx) {
|
||||
if os::path_exists(&result) || os::mkdir_recursive(&result, U_RWX) {
|
||||
result
|
||||
}
|
||||
else {
|
||||
|
@ -38,7 +38,7 @@ use syntax::{ast, diagnostic};
|
||||
use util::*;
|
||||
use messages::*;
|
||||
use path_util::{build_pkg_id_in_workspace, first_pkgid_src_in_workspace};
|
||||
use path_util::{u_rwx, rust_path};
|
||||
use path_util::{U_RWX, rust_path};
|
||||
use path_util::{built_executable_in_workspace, built_library_in_workspace};
|
||||
use path_util::{target_executable_in_workspace, target_library_in_workspace};
|
||||
use workspace::{each_pkg_parent_workspace, pkg_parent_workspaces};
|
||||
@ -374,7 +374,7 @@ impl CtxMethods for Ctx {
|
||||
|
||||
for maybe_executable.iter().advance |exec| {
|
||||
debug!("Copying: %s -> %s", exec.to_str(), target_exec.to_str());
|
||||
if !(os::mkdir_recursive(&target_exec.dir_path(), u_rwx) &&
|
||||
if !(os::mkdir_recursive(&target_exec.dir_path(), U_RWX) &&
|
||||
os::copy_file(exec, &target_exec)) {
|
||||
cond.raise((copy *exec, copy target_exec));
|
||||
}
|
||||
@ -383,7 +383,7 @@ impl CtxMethods for Ctx {
|
||||
let target_lib = (copy target_lib).expect(fmt!("I built %s but apparently \
|
||||
didn't install it!", lib.to_str()));
|
||||
debug!("Copying: %s -> %s", lib.to_str(), target_lib.to_str());
|
||||
if !(os::mkdir_recursive(&target_lib.dir_path(), u_rwx) &&
|
||||
if !(os::mkdir_recursive(&target_lib.dir_path(), U_RWX) &&
|
||||
os::copy_file(lib, &target_lib)) {
|
||||
cond.raise((copy *lib, copy target_lib));
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ use package_source::*;
|
||||
use version::{ExactRevision, NoVersion, Version};
|
||||
use path_util::{target_executable_in_workspace, target_library_in_workspace,
|
||||
target_test_in_workspace, target_bench_in_workspace,
|
||||
make_dir_rwx, u_rwx, library_in_workspace,
|
||||
make_dir_rwx, U_RWX, library_in_workspace,
|
||||
built_bench_in_workspace, built_test_in_workspace,
|
||||
built_library_in_workspace, built_executable_in_workspace,
|
||||
installed_library_in_workspace, rust_path};
|
||||
@ -78,7 +78,7 @@ fn mk_workspace(workspace: &Path, short_name: &LocalPath, version: &Version) ->
|
||||
// include version number in directory name
|
||||
let package_dir = workspace.push("src").push(fmt!("%s-%s",
|
||||
short_name.to_str(), version.to_str()));
|
||||
assert!(os::mkdir_recursive(&package_dir, u_rwx));
|
||||
assert!(os::mkdir_recursive(&package_dir, U_RWX));
|
||||
package_dir
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ fn mk_temp_workspace(short_name: &LocalPath, version: &Version) -> Path {
|
||||
os::path_is_dir(&package_dir));
|
||||
// Create main, lib, test, and bench files
|
||||
debug!("mk_workspace: creating %s", package_dir.to_str());
|
||||
assert!(os::mkdir_recursive(&package_dir, u_rwx));
|
||||
assert!(os::mkdir_recursive(&package_dir, U_RWX));
|
||||
debug!("Created %s and does it exist? %?", package_dir.to_str(),
|
||||
os::path_is_dir(&package_dir));
|
||||
// Create main, lib, test, and bench files
|
||||
@ -181,7 +181,7 @@ fn create_local_package_in(pkgid: &PkgId, pkgdir: &Path) -> Path {
|
||||
let package_dir = pkgdir.push("src").push(pkgid.to_str());
|
||||
|
||||
// Create main, lib, test, and bench files
|
||||
assert!(os::mkdir_recursive(&package_dir, u_rwx));
|
||||
assert!(os::mkdir_recursive(&package_dir, U_RWX));
|
||||
debug!("Created %s and does it exist? %?", package_dir.to_str(),
|
||||
os::path_is_dir(&package_dir));
|
||||
// Create main, lib, test, and bench files
|
||||
@ -585,9 +585,9 @@ fn rust_path_test() {
|
||||
fn rust_path_contents() {
|
||||
let dir = mkdtemp(&os::tmpdir(), "rust_path").expect("rust_path_contents failed");
|
||||
let abc = &dir.push("A").push("B").push("C");
|
||||
assert!(os::mkdir_recursive(&abc.push(".rust"), u_rwx));
|
||||
assert!(os::mkdir_recursive(&abc.pop().push(".rust"), u_rwx));
|
||||
assert!(os::mkdir_recursive(&abc.pop().pop().push(".rust"), u_rwx));
|
||||
assert!(os::mkdir_recursive(&abc.push(".rust"), U_RWX));
|
||||
assert!(os::mkdir_recursive(&abc.pop().push(".rust"), U_RWX));
|
||||
assert!(os::mkdir_recursive(&abc.pop().pop().push(".rust"), U_RWX));
|
||||
assert!(do os::change_dir_locked(&dir.push("A").push("B").push("C")) {
|
||||
let p = rust_path();
|
||||
let cwd = os::getcwd().push(".rust");
|
||||
|
@ -28,7 +28,7 @@ use search::find_library_in_search_path;
|
||||
use path_util::target_library_in_workspace;
|
||||
pub use target::{OutputType, Main, Lib, Bench, Test};
|
||||
|
||||
static Commands: &'static [&'static str] =
|
||||
static COMMANDS: &'static [&'static str] =
|
||||
&["build", "clean", "do", "info", "install", "prefer", "test", "uninstall",
|
||||
"unprefer"];
|
||||
|
||||
@ -55,7 +55,7 @@ pub fn root() -> Path {
|
||||
}
|
||||
|
||||
pub fn is_cmd(cmd: &str) -> bool {
|
||||
Commands.iter().any_(|&c| c == cmd)
|
||||
COMMANDS.iter().any_(|&c| c == cmd)
|
||||
}
|
||||
|
||||
struct ListenerFn {
|
||||
@ -417,4 +417,4 @@ mod test {
|
||||
|
||||
// tjc: cheesy
|
||||
fn debug_flags() -> ~[~str] { ~[] }
|
||||
// static debug_flags: ~[~str] = ~[~"-Z", ~"time-passes"];
|
||||
// static DEBUG_FLAGS: ~[~str] = ~[~"-Z", ~"time-passes"];
|
||||
|
@ -9,6 +9,7 @@
|
||||
// except according to those terms.
|
||||
|
||||
#[doc(hidden)];
|
||||
#[allow(non_uppercase_statics)];
|
||||
|
||||
/*! Precise garbage collector
|
||||
|
||||
|
@ -64,6 +64,7 @@
|
||||
*/
|
||||
|
||||
#[allow(non_camel_case_types)];
|
||||
#[allow(non_uppercase_statics)];
|
||||
#[allow(missing_doc)];
|
||||
|
||||
// Initial glob-exports mean that all the contents of all the modules
|
||||
|
@ -9,6 +9,7 @@
|
||||
// except according to those terms.
|
||||
|
||||
#[allow(missing_doc)];
|
||||
#[allow(non_uppercase_statics)];
|
||||
|
||||
// function names are almost identical to C's libmath, a few have been
|
||||
// renamed, grep for "rename:"
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
//! Operations and constants for `f32`
|
||||
#[allow(missing_doc)];
|
||||
#[allow(non_uppercase_statics)];
|
||||
|
||||
use libc::c_int;
|
||||
use num::{Zero, One, strconv};
|
||||
|
@ -11,6 +11,7 @@
|
||||
//! Operations and constants for `f64`
|
||||
|
||||
#[allow(missing_doc)];
|
||||
#[allow(non_uppercase_statics)];
|
||||
|
||||
use libc::c_int;
|
||||
use num::{Zero, One, strconv};
|
||||
|
@ -21,6 +21,7 @@
|
||||
// PORT this must match in width according to architecture
|
||||
|
||||
#[allow(missing_doc)];
|
||||
#[allow(non_uppercase_statics)];
|
||||
|
||||
use f64;
|
||||
use libc::c_int;
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
//! Operations and constants for `int`
|
||||
|
||||
#[allow(non_uppercase_statics)];
|
||||
|
||||
use num::BitCount;
|
||||
|
||||
pub use self::generated::*;
|
||||
|
@ -14,6 +14,8 @@
|
||||
|
||||
macro_rules! int_module (($T:ty, $bits:expr) => (mod generated {
|
||||
|
||||
#[allow(non_uppercase_statics)];
|
||||
|
||||
use num::{ToStrRadix, FromStrRadix};
|
||||
use num::{Zero, One, strconv};
|
||||
use prelude::*;
|
||||
|
@ -101,12 +101,12 @@ impl_NumStrConv_Integer!(u64)
|
||||
|
||||
|
||||
// Special value strings as [u8] consts.
|
||||
static inf_buf: [u8, ..3] = ['i' as u8, 'n' as u8, 'f' as u8];
|
||||
static positive_inf_buf: [u8, ..4] = ['+' as u8, 'i' as u8, 'n' as u8,
|
||||
static INF_BUF: [u8, ..3] = ['i' as u8, 'n' as u8, 'f' as u8];
|
||||
static POS_INF_BUF: [u8, ..4] = ['+' as u8, 'i' as u8, 'n' as u8,
|
||||
'f' as u8];
|
||||
static negative_inf_buf: [u8, ..4] = ['-' as u8, 'i' as u8, 'n' as u8,
|
||||
static NEG_INF_BUF: [u8, ..4] = ['-' as u8, 'i' as u8, 'n' as u8,
|
||||
'f' as u8];
|
||||
static nan_buf: [u8, ..3] = ['N' as u8, 'a' as u8, 'N' as u8];
|
||||
static NAN_BUF: [u8, ..3] = ['N' as u8, 'a' as u8, 'N' as u8];
|
||||
|
||||
/**
|
||||
* Converts an integral number to its string representation as a byte vector.
|
||||
@ -506,15 +506,15 @@ pub fn from_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Copy+Div<T,T>+
|
||||
}
|
||||
|
||||
if special {
|
||||
if buf == inf_buf || buf == positive_inf_buf {
|
||||
if buf == INF_BUF || buf == POS_INF_BUF {
|
||||
return NumStrConv::inf();
|
||||
} else if buf == negative_inf_buf {
|
||||
} else if buf == NEG_INF_BUF {
|
||||
if negative {
|
||||
return NumStrConv::neg_inf();
|
||||
} else {
|
||||
return None;
|
||||
}
|
||||
} else if buf == nan_buf {
|
||||
} else if buf == NAN_BUF {
|
||||
return NumStrConv::NaN();
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,8 @@
|
||||
|
||||
macro_rules! uint_module (($T:ty, $T_SIGNED:ty, $bits:expr) => (mod generated {
|
||||
|
||||
#[allow(non_uppercase_statics)];
|
||||
|
||||
use num::BitCount;
|
||||
use num::{ToStrRadix, FromStrRadix};
|
||||
use num::{Zero, One, strconv};
|
||||
|
@ -157,7 +157,7 @@ impl Rand for f32 {
|
||||
}
|
||||
}
|
||||
|
||||
static scale : f64 = (u32::max_value as f64) + 1.0f64;
|
||||
static SCALE : f64 = (u32::max_value as f64) + 1.0f64;
|
||||
impl Rand for f64 {
|
||||
#[inline]
|
||||
fn rand<R: Rng>(rng: &mut R) -> f64 {
|
||||
@ -165,7 +165,7 @@ impl Rand for f64 {
|
||||
let u2 = rng.next() as f64;
|
||||
let u3 = rng.next() as f64;
|
||||
|
||||
((u1 / scale + u2) / scale + u3) / scale
|
||||
((u1 / SCALE + u2) / SCALE + u3) / SCALE
|
||||
}
|
||||
}
|
||||
|
||||
@ -724,7 +724,7 @@ impl IsaacRng {
|
||||
let mut a = self.a;
|
||||
let mut b = self.b + self.c;
|
||||
|
||||
static midpoint: uint = RAND_SIZE as uint / 2;
|
||||
static MIDPOINT: uint = RAND_SIZE as uint / 2;
|
||||
|
||||
macro_rules! ind (($x:expr) => {
|
||||
self.mem[($x >> 2) & (RAND_SIZE - 1)]
|
||||
@ -748,9 +748,9 @@ impl IsaacRng {
|
||||
}}
|
||||
);
|
||||
|
||||
let r = [(0, midpoint), (midpoint, 0)];
|
||||
let r = [(0, MIDPOINT), (MIDPOINT, 0)];
|
||||
for r.iter().advance |&(mr_offset, m2_offset)| {
|
||||
for uint::range_step(0, midpoint, 4) |base| {
|
||||
for uint::range_step(0, MIDPOINT, 4) |base| {
|
||||
rngstep!(0, 13);
|
||||
rngstep!(1, -6);
|
||||
rngstep!(2, 2);
|
||||
|
@ -602,7 +602,7 @@ pub fn is_utf8(v: &[u8]) -> bool {
|
||||
if i + chsize > total { return false; }
|
||||
i += 1u;
|
||||
while chsize > 1u {
|
||||
if v[i] & 192u8 != tag_cont_u8 { return false; }
|
||||
if v[i] & 192u8 != TAG_CONT_U8 { return false; }
|
||||
i += 1u;
|
||||
chsize -= 1u;
|
||||
}
|
||||
@ -743,18 +743,18 @@ pub struct CharRange {
|
||||
}
|
||||
|
||||
// UTF-8 tags and ranges
|
||||
static tag_cont_u8: u8 = 128u8;
|
||||
static tag_cont: uint = 128u;
|
||||
static max_one_b: uint = 128u;
|
||||
static tag_two_b: uint = 192u;
|
||||
static max_two_b: uint = 2048u;
|
||||
static tag_three_b: uint = 224u;
|
||||
static max_three_b: uint = 65536u;
|
||||
static tag_four_b: uint = 240u;
|
||||
static max_four_b: uint = 2097152u;
|
||||
static tag_five_b: uint = 248u;
|
||||
static max_five_b: uint = 67108864u;
|
||||
static tag_six_b: uint = 252u;
|
||||
static TAG_CONT_U8: u8 = 128u8;
|
||||
static TAG_CONT: uint = 128u;
|
||||
static MAX_ONE_B: uint = 128u;
|
||||
static TAG_TWO_B: uint = 192u;
|
||||
static MAX_TWO_B: uint = 2048u;
|
||||
static TAG_THREE_B: uint = 224u;
|
||||
static MAX_THREE_B: uint = 65536u;
|
||||
static TAG_FOUR_B: uint = 240u;
|
||||
static MAX_FOUR_B: uint = 2097152u;
|
||||
static TAG_FIVE_B: uint = 248u;
|
||||
static MAX_FIVE_B: uint = 67108864u;
|
||||
static TAG_SIX_B: uint = 252u;
|
||||
|
||||
/**
|
||||
* A dummy trait to hold all the utility methods that we implement on strings.
|
||||
@ -1728,7 +1728,7 @@ impl<'self> StrSlice<'self> for &'self str {
|
||||
let mut i = i + 1u;
|
||||
while i < end {
|
||||
let byte = self[i];
|
||||
assert_eq!(byte & 192u8, tag_cont_u8);
|
||||
assert_eq!(byte & 192u8, TAG_CONT_U8);
|
||||
val <<= 6u;
|
||||
val += (byte & 63u8) as uint;
|
||||
i += 1u;
|
||||
@ -1755,7 +1755,7 @@ impl<'self> StrSlice<'self> for &'self str {
|
||||
let mut prev = start;
|
||||
|
||||
// while there is a previous byte == 10......
|
||||
while prev > 0u && self[prev - 1u] & 192u8 == tag_cont_u8 {
|
||||
while prev > 0u && self[prev - 1u] & 192u8 == TAG_CONT_U8 {
|
||||
prev -= 1u;
|
||||
}
|
||||
|
||||
@ -2071,11 +2071,11 @@ impl OwnedStr for ~str {
|
||||
fn push_char(&mut self, c: char) {
|
||||
unsafe {
|
||||
let code = c as uint;
|
||||
let nb = if code < max_one_b { 1u }
|
||||
else if code < max_two_b { 2u }
|
||||
else if code < max_three_b { 3u }
|
||||
else if code < max_four_b { 4u }
|
||||
else if code < max_five_b { 5u }
|
||||
let nb = if code < MAX_ONE_B { 1u }
|
||||
else if code < MAX_TWO_B { 2u }
|
||||
else if code < MAX_THREE_B { 3u }
|
||||
else if code < MAX_FOUR_B { 4u }
|
||||
else if code < MAX_FIVE_B { 5u }
|
||||
else { 6u };
|
||||
let len = self.len();
|
||||
let new_len = len + nb;
|
||||
@ -2088,34 +2088,34 @@ impl OwnedStr for ~str {
|
||||
*ptr::mut_offset(buf, off) = code as u8;
|
||||
}
|
||||
2u => {
|
||||
*ptr::mut_offset(buf, off) = (code >> 6u & 31u | tag_two_b) as u8;
|
||||
*ptr::mut_offset(buf, off + 1u) = (code & 63u | tag_cont) as u8;
|
||||
*ptr::mut_offset(buf, off) = (code >> 6u & 31u | TAG_TWO_B) as u8;
|
||||
*ptr::mut_offset(buf, off + 1u) = (code & 63u | TAG_CONT) as u8;
|
||||
}
|
||||
3u => {
|
||||
*ptr::mut_offset(buf, off) = (code >> 12u & 15u | tag_three_b) as u8;
|
||||
*ptr::mut_offset(buf, off + 1u) = (code >> 6u & 63u | tag_cont) as u8;
|
||||
*ptr::mut_offset(buf, off + 2u) = (code & 63u | tag_cont) as u8;
|
||||
*ptr::mut_offset(buf, off) = (code >> 12u & 15u | TAG_THREE_B) as u8;
|
||||
*ptr::mut_offset(buf, off + 1u) = (code >> 6u & 63u | TAG_CONT) as u8;
|
||||
*ptr::mut_offset(buf, off + 2u) = (code & 63u | TAG_CONT) as u8;
|
||||
}
|
||||
4u => {
|
||||
*ptr::mut_offset(buf, off) = (code >> 18u & 7u | tag_four_b) as u8;
|
||||
*ptr::mut_offset(buf, off + 1u) = (code >> 12u & 63u | tag_cont) as u8;
|
||||
*ptr::mut_offset(buf, off + 2u) = (code >> 6u & 63u | tag_cont) as u8;
|
||||
*ptr::mut_offset(buf, off + 3u) = (code & 63u | tag_cont) as u8;
|
||||
*ptr::mut_offset(buf, off) = (code >> 18u & 7u | TAG_FOUR_B) as u8;
|
||||
*ptr::mut_offset(buf, off + 1u) = (code >> 12u & 63u | TAG_CONT) as u8;
|
||||
*ptr::mut_offset(buf, off + 2u) = (code >> 6u & 63u | TAG_CONT) as u8;
|
||||
*ptr::mut_offset(buf, off + 3u) = (code & 63u | TAG_CONT) as u8;
|
||||
}
|
||||
5u => {
|
||||
*ptr::mut_offset(buf, off) = (code >> 24u & 3u | tag_five_b) as u8;
|
||||
*ptr::mut_offset(buf, off + 1u) = (code >> 18u & 63u | tag_cont) as u8;
|
||||
*ptr::mut_offset(buf, off + 2u) = (code >> 12u & 63u | tag_cont) as u8;
|
||||
*ptr::mut_offset(buf, off + 3u) = (code >> 6u & 63u | tag_cont) as u8;
|
||||
*ptr::mut_offset(buf, off + 4u) = (code & 63u | tag_cont) as u8;
|
||||
*ptr::mut_offset(buf, off) = (code >> 24u & 3u | TAG_FIVE_B) as u8;
|
||||
*ptr::mut_offset(buf, off + 1u) = (code >> 18u & 63u | TAG_CONT) as u8;
|
||||
*ptr::mut_offset(buf, off + 2u) = (code >> 12u & 63u | TAG_CONT) as u8;
|
||||
*ptr::mut_offset(buf, off + 3u) = (code >> 6u & 63u | TAG_CONT) as u8;
|
||||
*ptr::mut_offset(buf, off + 4u) = (code & 63u | TAG_CONT) as u8;
|
||||
}
|
||||
6u => {
|
||||
*ptr::mut_offset(buf, off) = (code >> 30u & 1u | tag_six_b) as u8;
|
||||
*ptr::mut_offset(buf, off + 1u) = (code >> 24u & 63u | tag_cont) as u8;
|
||||
*ptr::mut_offset(buf, off + 2u) = (code >> 18u & 63u | tag_cont) as u8;
|
||||
*ptr::mut_offset(buf, off + 3u) = (code >> 12u & 63u | tag_cont) as u8;
|
||||
*ptr::mut_offset(buf, off + 4u) = (code >> 6u & 63u | tag_cont) as u8;
|
||||
*ptr::mut_offset(buf, off + 5u) = (code & 63u | tag_cont) as u8;
|
||||
*ptr::mut_offset(buf, off) = (code >> 30u & 1u | TAG_SIX_B) as u8;
|
||||
*ptr::mut_offset(buf, off + 1u) = (code >> 24u & 63u | TAG_CONT) as u8;
|
||||
*ptr::mut_offset(buf, off + 2u) = (code >> 18u & 63u | TAG_CONT) as u8;
|
||||
*ptr::mut_offset(buf, off + 3u) = (code >> 12u & 63u | TAG_CONT) as u8;
|
||||
*ptr::mut_offset(buf, off + 4u) = (code >> 6u & 63u | TAG_CONT) as u8;
|
||||
*ptr::mut_offset(buf, off + 5u) = (code & 63u | TAG_CONT) as u8;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
// The following code was generated by "src/etc/unicode.py"
|
||||
|
||||
#[allow(missing_doc)];
|
||||
#[allow(non_uppercase_statics)];
|
||||
|
||||
pub mod general_category {
|
||||
|
||||
|
@ -472,6 +472,7 @@ pub mod ct {
|
||||
// conditions can be evaluated at compile-time. For now though it's cleaner to
|
||||
// implement it this way, I think.
|
||||
#[doc(hidden)]
|
||||
#[allow(non_uppercase_statics)]
|
||||
pub mod rt {
|
||||
use float;
|
||||
use str;
|
||||
|
@ -197,15 +197,15 @@ impl DebugPrints for io::fd_t {
|
||||
fn write_hex(&self, mut i: uint) {
|
||||
let letters = ['0', '1', '2', '3', '4', '5', '6', '7', '8',
|
||||
'9', 'a', 'b', 'c', 'd', 'e', 'f'];
|
||||
static uint_nibbles: uint = ::uint::bytes << 1;
|
||||
let mut buffer = [0_u8, ..uint_nibbles+1];
|
||||
let mut c = uint_nibbles;
|
||||
static UINT_NIBBLES: uint = ::uint::bytes << 1;
|
||||
let mut buffer = [0_u8, ..UINT_NIBBLES+1];
|
||||
let mut c = UINT_NIBBLES;
|
||||
while c > 0 {
|
||||
c -= 1;
|
||||
buffer[c] = letters[i & 0xF] as u8;
|
||||
i >>= 4;
|
||||
}
|
||||
self.write(buffer.slice(0, uint_nibbles));
|
||||
self.write(buffer.slice(0, UINT_NIBBLES));
|
||||
}
|
||||
|
||||
unsafe fn write_cstr(&self, p: *c_char) {
|
||||
|
@ -179,10 +179,10 @@ fn diagnosticstr(lvl: level) -> ~str {
|
||||
|
||||
fn diagnosticcolor(lvl: level) -> term::color::Color {
|
||||
match lvl {
|
||||
fatal => term::color::bright_red,
|
||||
error => term::color::bright_red,
|
||||
warning => term::color::bright_yellow,
|
||||
note => term::color::bright_green
|
||||
fatal => term::color::BRIGHT_RED,
|
||||
error => term::color::BRIGHT_RED,
|
||||
warning => term::color::BRIGHT_YELLOW,
|
||||
note => term::color::BRIGHT_GREEN
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -580,6 +580,7 @@ pub fn core_macros() -> @str {
|
||||
pub mod $c {
|
||||
fn key(_x: @::std::condition::Handler<$in,$out>) { }
|
||||
|
||||
#[allow(non_uppercase_statics)]
|
||||
pub static cond :
|
||||
::std::condition::Condition<'static,$in,$out> =
|
||||
::std::condition::Condition {
|
||||
@ -595,6 +596,7 @@ pub fn core_macros() -> @str {
|
||||
pub mod $c {
|
||||
fn key(_x: @::std::condition::Handler<$in,$out>) { }
|
||||
|
||||
#[allow(non_uppercase_statics)]
|
||||
pub static cond :
|
||||
::std::condition::Condition<'static,$in,$out> =
|
||||
::std::condition::Condition {
|
||||
|
@ -21,6 +21,7 @@
|
||||
#[crate_type = "lib"];
|
||||
|
||||
#[allow(non_camel_case_types)];
|
||||
#[allow(non_uppercase_statics)];
|
||||
#[deny(deprecated_pattern)];
|
||||
|
||||
extern mod extra;
|
||||
|
15
src/test/compile-fail/lint-non-uppercase-statics.rs
Normal file
15
src/test/compile-fail/lint-non-uppercase-statics.rs
Normal file
@ -0,0 +1,15 @@
|
||||
// Copyright 2013 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.
|
||||
|
||||
#[forbid(non_uppercase_statics)];
|
||||
|
||||
static foo: int = 1; //~ ERROR static constant should have an uppercase identifier
|
||||
|
||||
fn main() { }
|
@ -1,5 +1,5 @@
|
||||
#[static_assert]
|
||||
static a: bool = false; //~ ERROR static assertion failed
|
||||
static A: bool = false; //~ ERROR static assertion failed
|
||||
|
||||
fn main() {
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
#[static_assert]
|
||||
static e: bool = 1 == 2; //~ ERROR static assertion failed
|
||||
static E: bool = 1 == 2; //~ ERROR static assertion failed
|
||||
|
||||
fn main() {}
|
||||
|
@ -0,0 +1,21 @@
|
||||
// Copyright 2013 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.
|
||||
|
||||
#[forbid(non_camel_case_types)];
|
||||
#[forbid(non_uppercase_statics)];
|
||||
|
||||
// Some scripts (e.g. hiragana) don't have a concept of
|
||||
// upper/lowercase
|
||||
|
||||
struct ヒ;
|
||||
|
||||
static ラ: uint = 0;
|
||||
|
||||
fn main() {}
|
@ -0,0 +1,17 @@
|
||||
// Copyright 2013 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.
|
||||
|
||||
|
||||
#[forbid(non_camel_case_types)];
|
||||
#[forbid(non_uppercase_statics)];
|
||||
|
||||
static mut bar: int = 2;
|
||||
|
||||
fn main() {}
|
Loading…
Reference in New Issue
Block a user