diff options
| author | Florian Zeitz <florob@babelmonkeys.de> | 2015-02-27 15:36:53 +0100 |
|---|---|---|
| committer | Florian Zeitz <florob@babelmonkeys.de> | 2015-03-02 17:11:51 +0100 |
| commit | f35f973cb700c444d8c029ee13b37dc16d560225 (patch) | |
| tree | 7d87e40045e89a5d75001ef4b241840870b6aed7 /src/libsyntax | |
| parent | 1cc8b6ec664f30b43f75551e95299d943c8a4e6a (diff) | |
| download | rust-f35f973cb700c444d8c029ee13b37dc16d560225.tar.gz rust-f35f973cb700c444d8c029ee13b37dc16d560225.zip | |
Use `const`s instead of `static`s 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]
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/abi.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/diagnostic.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/asm.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/feature_gate.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/parse/lexer/comments.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/parse/token.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/print/pp.rs | 2 |
7 files changed, 13 insertions, 13 deletions
diff --git a/src/libsyntax/abi.rs b/src/libsyntax/abi.rs index 2cf157bd245..896e638deb4 100644 --- a/src/libsyntax/abi.rs +++ b/src/libsyntax/abi.rs @@ -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" }, diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index 27219774cf1..a6f4974502c 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -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 { diff --git a/src/libsyntax/ext/asm.rs b/src/libsyntax/ext/asm.rs index ae48084947e..e58a3de41c0 100644 --- a/src/libsyntax/ext/asm.rs +++ b/src/libsyntax/ext/asm.rs @@ -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> { diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index ffc136d5a1d..cf0591365ae 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -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), diff --git a/src/libsyntax/parse/lexer/comments.rs b/src/libsyntax/parse/lexer/comments.rs index 7a5d75581a5..3ad1d96a45d 100644 --- a/src/libsyntax/parse/lexer/comments.rs +++ b/src/libsyntax/parse/lexer/comments.rs @@ -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(); } diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 2797ef084d9..61a3a5ca82a 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -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; diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs index 5b3fde8535b..4cef7ed469f 100644 --- a/src/libsyntax/print/pp.rs +++ b/src/libsyntax/print/pp.rs @@ -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 |
