syntax: Convert statics to constants
This commit is contained in:
parent
8ccb616092
commit
edf8841642
@ -48,9 +48,9 @@ pub enum Architecture {
|
||||
}
|
||||
|
||||
#[allow(non_uppercase_statics)]
|
||||
static IntelBits: u32 = (1 << (X86 as uint)) | (1 << (X86_64 as uint));
|
||||
const IntelBits: u32 = (1 << (X86 as uint)) | (1 << (X86_64 as uint));
|
||||
#[allow(non_uppercase_statics)]
|
||||
static ArmBits: u32 = (1 << (Arm as uint));
|
||||
const ArmBits: u32 = (1 << (Arm as uint));
|
||||
|
||||
pub struct AbiData {
|
||||
abi: Abi,
|
||||
|
@ -104,8 +104,8 @@ impl PartialEq for Ident {
|
||||
// this uint is a reference to a table stored in thread-local
|
||||
// storage.
|
||||
pub type SyntaxContext = u32;
|
||||
pub static EMPTY_CTXT : SyntaxContext = 0;
|
||||
pub static ILLEGAL_CTXT : SyntaxContext = 1;
|
||||
pub const EMPTY_CTXT : SyntaxContext = 0;
|
||||
pub const ILLEGAL_CTXT : SyntaxContext = 1;
|
||||
|
||||
/// A name is a part of an identifier, representing a string or gensym. It's
|
||||
/// the result of interning.
|
||||
@ -198,13 +198,13 @@ pub struct DefId {
|
||||
|
||||
/// Item definitions in the currently-compiled crate would have the CrateNum
|
||||
/// LOCAL_CRATE in their DefId.
|
||||
pub static LOCAL_CRATE: CrateNum = 0;
|
||||
pub static CRATE_NODE_ID: NodeId = 0;
|
||||
pub const LOCAL_CRATE: CrateNum = 0;
|
||||
pub const CRATE_NODE_ID: NodeId = 0;
|
||||
|
||||
/// When parsing and doing expansions, we initially give all AST nodes this AST
|
||||
/// node value. Then later, in the renumber pass, we renumber them to have
|
||||
/// small, positive ids.
|
||||
pub static DUMMY_NODE_ID: NodeId = -1;
|
||||
pub const DUMMY_NODE_ID: NodeId = -1;
|
||||
|
||||
/// The AST represents all type param bounds as types.
|
||||
/// typeck::collect::compute_bounds matches these against
|
||||
|
@ -96,7 +96,7 @@ pub struct Span {
|
||||
pub expn_id: ExpnId
|
||||
}
|
||||
|
||||
pub static DUMMY_SP: Span = Span { lo: BytePos(0), hi: BytePos(0), expn_id: NO_EXPANSION };
|
||||
pub const DUMMY_SP: Span = Span { lo: BytePos(0), hi: BytePos(0), expn_id: NO_EXPANSION };
|
||||
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
|
||||
pub struct Spanned<T> {
|
||||
@ -227,7 +227,7 @@ pub struct ExpnInfo {
|
||||
#[deriving(PartialEq, Eq, Clone, Show, Hash, Encodable, Decodable)]
|
||||
pub struct ExpnId(u32);
|
||||
|
||||
pub static NO_EXPANSION: ExpnId = ExpnId(-1);
|
||||
pub const NO_EXPANSION: ExpnId = ExpnId(-1);
|
||||
|
||||
impl ExpnId {
|
||||
pub fn from_llvm_cookie(cookie: c_uint) -> ExpnId {
|
||||
|
@ -91,10 +91,10 @@ use std::iter;
|
||||
|
||||
bitflags! {
|
||||
flags Restrictions: u8 {
|
||||
static UNRESTRICTED = 0b0000,
|
||||
static RESTRICTION_STMT_EXPR = 0b0001,
|
||||
static RESTRICTION_NO_BAR_OP = 0b0010,
|
||||
static RESTRICTION_NO_STRUCT_LITERAL = 0b0100
|
||||
const UNRESTRICTED = 0b0000,
|
||||
const RESTRICTION_STMT_EXPR = 0b0001,
|
||||
const RESTRICTION_NO_BAR_OP = 0b0010,
|
||||
const RESTRICTION_NO_STRUCT_LITERAL = 0b0100
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -385,13 +385,13 @@ macro_rules! declare_special_idents_and_keywords {(
|
||||
use ast::{Ident, Name};
|
||||
$(
|
||||
#[allow(non_uppercase_statics)]
|
||||
pub static $si_static: Ident = Ident { name: Name($si_name), ctxt: 0 };
|
||||
pub const $si_static: Ident = Ident { name: Name($si_name), ctxt: 0 };
|
||||
)*
|
||||
}
|
||||
|
||||
pub mod special_names {
|
||||
use ast::Name;
|
||||
$( #[allow(non_uppercase_statics)] pub static $si_static: Name = Name($si_name); )*
|
||||
$( #[allow(non_uppercase_statics)] pub const $si_static: Name = Name($si_name); )*
|
||||
}
|
||||
|
||||
/**
|
||||
@ -432,13 +432,13 @@ macro_rules! declare_special_idents_and_keywords {(
|
||||
}}
|
||||
|
||||
// If the special idents get renumbered, remember to modify these two as appropriate
|
||||
pub static SELF_KEYWORD_NAME: Name = Name(SELF_KEYWORD_NAME_NUM);
|
||||
static STATIC_KEYWORD_NAME: Name = Name(STATIC_KEYWORD_NAME_NUM);
|
||||
static SUPER_KEYWORD_NAME: Name = Name(SUPER_KEYWORD_NAME_NUM);
|
||||
pub const SELF_KEYWORD_NAME: Name = Name(SELF_KEYWORD_NAME_NUM);
|
||||
const STATIC_KEYWORD_NAME: Name = Name(STATIC_KEYWORD_NAME_NUM);
|
||||
const SUPER_KEYWORD_NAME: Name = Name(SUPER_KEYWORD_NAME_NUM);
|
||||
|
||||
pub static SELF_KEYWORD_NAME_NUM: u32 = 1;
|
||||
static STATIC_KEYWORD_NAME_NUM: u32 = 2;
|
||||
static SUPER_KEYWORD_NAME_NUM: u32 = 3;
|
||||
pub const SELF_KEYWORD_NAME_NUM: u32 = 1;
|
||||
const STATIC_KEYWORD_NAME_NUM: u32 = 2;
|
||||
const SUPER_KEYWORD_NAME_NUM: u32 = 3;
|
||||
|
||||
// NB: leaving holes in the ident table is bad! a different ident will get
|
||||
// interned with the id from the hole, but it will be between the min and max
|
||||
|
@ -90,10 +90,10 @@ pub fn rust_printer_annotated<'a>(writer: Box<io::Writer+'static>,
|
||||
}
|
||||
|
||||
#[allow(non_uppercase_statics)]
|
||||
pub static indent_unit: uint = 4u;
|
||||
pub const indent_unit: uint = 4u;
|
||||
|
||||
#[allow(non_uppercase_statics)]
|
||||
pub static default_columns: uint = 78u;
|
||||
pub const default_columns: uint = 78u;
|
||||
|
||||
/// Requires you to pass an input filename and reader so that
|
||||
/// it can scan the input text for comments and literals to
|
||||
|
Loading…
x
Reference in New Issue
Block a user