Skip to content

Commit edf8841

Browse files
committed
syntax: Convert statics to constants
1 parent 8ccb616 commit edf8841

File tree

6 files changed

+23
-23
lines changed

6 files changed

+23
-23
lines changed

src/libsyntax/abi.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ pub enum Architecture {
4848
}
4949

5050
#[allow(non_uppercase_statics)]
51-
static IntelBits: u32 = (1 << (X86 as uint)) | (1 << (X86_64 as uint));
51+
const IntelBits: u32 = (1 << (X86 as uint)) | (1 << (X86_64 as uint));
5252
#[allow(non_uppercase_statics)]
53-
static ArmBits: u32 = (1 << (Arm as uint));
53+
const ArmBits: u32 = (1 << (Arm as uint));
5454

5555
pub struct AbiData {
5656
abi: Abi,

src/libsyntax/ast.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ impl PartialEq for Ident {
104104
// this uint is a reference to a table stored in thread-local
105105
// storage.
106106
pub type SyntaxContext = u32;
107-
pub static EMPTY_CTXT : SyntaxContext = 0;
108-
pub static ILLEGAL_CTXT : SyntaxContext = 1;
107+
pub const EMPTY_CTXT : SyntaxContext = 0;
108+
pub const ILLEGAL_CTXT : SyntaxContext = 1;
109109

110110
/// A name is a part of an identifier, representing a string or gensym. It's
111111
/// the result of interning.
@@ -198,13 +198,13 @@ pub struct DefId {
198198

199199
/// Item definitions in the currently-compiled crate would have the CrateNum
200200
/// LOCAL_CRATE in their DefId.
201-
pub static LOCAL_CRATE: CrateNum = 0;
202-
pub static CRATE_NODE_ID: NodeId = 0;
201+
pub const LOCAL_CRATE: CrateNum = 0;
202+
pub const CRATE_NODE_ID: NodeId = 0;
203203

204204
/// When parsing and doing expansions, we initially give all AST nodes this AST
205205
/// node value. Then later, in the renumber pass, we renumber them to have
206206
/// small, positive ids.
207-
pub static DUMMY_NODE_ID: NodeId = -1;
207+
pub const DUMMY_NODE_ID: NodeId = -1;
208208

209209
/// The AST represents all type param bounds as types.
210210
/// typeck::collect::compute_bounds matches these against

src/libsyntax/codemap.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ pub struct Span {
9696
pub expn_id: ExpnId
9797
}
9898

99-
pub static DUMMY_SP: Span = Span { lo: BytePos(0), hi: BytePos(0), expn_id: NO_EXPANSION };
99+
pub const DUMMY_SP: Span = Span { lo: BytePos(0), hi: BytePos(0), expn_id: NO_EXPANSION };
100100

101101
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
102102
pub struct Spanned<T> {
@@ -227,7 +227,7 @@ pub struct ExpnInfo {
227227
#[deriving(PartialEq, Eq, Clone, Show, Hash, Encodable, Decodable)]
228228
pub struct ExpnId(u32);
229229

230-
pub static NO_EXPANSION: ExpnId = ExpnId(-1);
230+
pub const NO_EXPANSION: ExpnId = ExpnId(-1);
231231

232232
impl ExpnId {
233233
pub fn from_llvm_cookie(cookie: c_uint) -> ExpnId {

src/libsyntax/parse/parser.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ use std::iter;
9191

9292
bitflags! {
9393
flags Restrictions: u8 {
94-
static UNRESTRICTED = 0b0000,
95-
static RESTRICTION_STMT_EXPR = 0b0001,
96-
static RESTRICTION_NO_BAR_OP = 0b0010,
97-
static RESTRICTION_NO_STRUCT_LITERAL = 0b0100
94+
const UNRESTRICTED = 0b0000,
95+
const RESTRICTION_STMT_EXPR = 0b0001,
96+
const RESTRICTION_NO_BAR_OP = 0b0010,
97+
const RESTRICTION_NO_STRUCT_LITERAL = 0b0100
9898
}
9999
}
100100

src/libsyntax/parse/token.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -385,13 +385,13 @@ macro_rules! declare_special_idents_and_keywords {(
385385
use ast::{Ident, Name};
386386
$(
387387
#[allow(non_uppercase_statics)]
388-
pub static $si_static: Ident = Ident { name: Name($si_name), ctxt: 0 };
388+
pub const $si_static: Ident = Ident { name: Name($si_name), ctxt: 0 };
389389
)*
390390
}
391391

392392
pub mod special_names {
393393
use ast::Name;
394-
$( #[allow(non_uppercase_statics)] pub static $si_static: Name = Name($si_name); )*
394+
$( #[allow(non_uppercase_statics)] pub const $si_static: Name = Name($si_name); )*
395395
}
396396

397397
/**
@@ -432,13 +432,13 @@ macro_rules! declare_special_idents_and_keywords {(
432432
}}
433433

434434
// If the special idents get renumbered, remember to modify these two as appropriate
435-
pub static SELF_KEYWORD_NAME: Name = Name(SELF_KEYWORD_NAME_NUM);
436-
static STATIC_KEYWORD_NAME: Name = Name(STATIC_KEYWORD_NAME_NUM);
437-
static SUPER_KEYWORD_NAME: Name = Name(SUPER_KEYWORD_NAME_NUM);
435+
pub const SELF_KEYWORD_NAME: Name = Name(SELF_KEYWORD_NAME_NUM);
436+
const STATIC_KEYWORD_NAME: Name = Name(STATIC_KEYWORD_NAME_NUM);
437+
const SUPER_KEYWORD_NAME: Name = Name(SUPER_KEYWORD_NAME_NUM);
438438

439-
pub static SELF_KEYWORD_NAME_NUM: u32 = 1;
440-
static STATIC_KEYWORD_NAME_NUM: u32 = 2;
441-
static SUPER_KEYWORD_NAME_NUM: u32 = 3;
439+
pub const SELF_KEYWORD_NAME_NUM: u32 = 1;
440+
const STATIC_KEYWORD_NAME_NUM: u32 = 2;
441+
const SUPER_KEYWORD_NAME_NUM: u32 = 3;
442442

443443
// NB: leaving holes in the ident table is bad! a different ident will get
444444
// interned with the id from the hole, but it will be between the min and max

src/libsyntax/print/pprust.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@ pub fn rust_printer_annotated<'a>(writer: Box<io::Writer+'static>,
9090
}
9191

9292
#[allow(non_uppercase_statics)]
93-
pub static indent_unit: uint = 4u;
93+
pub const indent_unit: uint = 4u;
9494

9595
#[allow(non_uppercase_statics)]
96-
pub static default_columns: uint = 78u;
96+
pub const default_columns: uint = 78u;
9797

9898
/// Requires you to pass an input filename and reader so that
9999
/// it can scan the input text for comments and literals to

0 commit comments

Comments
 (0)