Auto merge of #25823 - oli-obk:static_to_const_lint, r=alexcrichton
r? @eddyb
This commit is contained in:
commit
bea1c4a78e
@ -81,7 +81,7 @@ use core::raw::{TraitObject};
|
||||
#[lang = "exchange_heap"]
|
||||
#[unstable(feature = "alloc",
|
||||
reason = "may be renamed; uncertain about custom allocator design")]
|
||||
pub static HEAP: () = ();
|
||||
pub const HEAP: () = ();
|
||||
|
||||
/// A pointer type for heap allocation.
|
||||
///
|
||||
|
@ -125,8 +125,8 @@ fn match_words <'a,'b>(a: &'a BitVec, b: &'b BitVec) -> (MatchWords<'a>, MatchWo
|
||||
}
|
||||
}
|
||||
|
||||
static TRUE: bool = true;
|
||||
static FALSE: bool = false;
|
||||
const TRUE: &'static bool = &true;
|
||||
const FALSE: &'static bool = &false;
|
||||
|
||||
/// The bitvector type.
|
||||
///
|
||||
@ -172,9 +172,9 @@ impl Index<usize> for BitVec {
|
||||
#[inline]
|
||||
fn index(&self, i: usize) -> &bool {
|
||||
if self.get(i).expect("index out of bounds") {
|
||||
&TRUE
|
||||
TRUE
|
||||
} else {
|
||||
&FALSE
|
||||
FALSE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ use borrow::{Cow, IntoCow};
|
||||
use super::range::RangeArgument;
|
||||
|
||||
// FIXME- fix places which assume the max vector allowed has memory usize::MAX.
|
||||
static MAX_MEMORY_SIZE: usize = isize::MAX as usize;
|
||||
const MAX_MEMORY_SIZE: usize = isize::MAX as usize;
|
||||
|
||||
/// A growable list type, written `Vec<T>` but pronounced 'vector.'
|
||||
///
|
||||
|
@ -24,7 +24,6 @@ use num::flt2dec::estimator::estimate_scaling_factor;
|
||||
use num::flt2dec::bignum::Digit32 as Digit;
|
||||
use num::flt2dec::bignum::Big32x36 as Big;
|
||||
|
||||
// FIXME(#22540) const ref to static array seems to ICE
|
||||
static POW10: [Digit; 10] = [1, 10, 100, 1000, 10000, 100000,
|
||||
1000000, 10000000, 100000000, 1000000000];
|
||||
static TWOPOW10: [Digit; 10] = [2, 20, 200, 2000, 20000, 200000,
|
||||
@ -328,4 +327,3 @@ pub fn format_exact(d: &Decoded, buf: &mut [u8], limit: i16) -> (/*#digits*/ usi
|
||||
|
||||
(len, k)
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ for i in xrange(-308, 333, 8):
|
||||
f = ((f << 64 >> (l-1)) + 1) >> 1; e += l - 64
|
||||
print ' (%#018x, %5d, %4d),' % (f, e, i)
|
||||
*/
|
||||
// FIXME(#22540) const ref to static array seems to ICE
|
||||
|
||||
#[doc(hidden)]
|
||||
pub static CACHED_POW10: [(u64, i16, i16); 81] = [ // (f, e, k)
|
||||
(0xe61acf033d1a45df, -1087, -308),
|
||||
@ -746,4 +746,3 @@ pub fn format_exact(d: &Decoded, buf: &mut [u8], limit: i16) -> (/*#digits*/ usi
|
||||
None => fallback(d, buf, limit),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ pub struct LogDirective {
|
||||
pub level: u32,
|
||||
}
|
||||
|
||||
pub static LOG_LEVEL_NAMES: [&'static str; 4] = ["ERROR", "WARN", "INFO",
|
||||
pub const LOG_LEVEL_NAMES: [&'static str; 4] = ["ERROR", "WARN", "INFO",
|
||||
"DEBUG"];
|
||||
|
||||
/// Parse an individual log level that is either a number or a symbolic log level
|
||||
|
@ -12,7 +12,7 @@
|
||||
// algorithm. Autogenerated by `ziggurat_tables.py`.
|
||||
|
||||
pub type ZigTable = &'static [f64; 257];
|
||||
pub static ZIG_NORM_R: f64 = 3.654152885361008796;
|
||||
pub const ZIG_NORM_R: f64 = 3.654152885361008796;
|
||||
pub static ZIG_NORM_X: [f64; 257] =
|
||||
[3.910757959537090045, 3.654152885361008796, 3.449278298560964462, 3.320244733839166074,
|
||||
3.224575052047029100, 3.147889289517149969, 3.083526132001233044, 3.027837791768635434,
|
||||
@ -145,7 +145,7 @@ pub static ZIG_NORM_F: [f64; 257] =
|
||||
0.887984660763399880, 0.898095921906304051, 0.908726440060562912, 0.919991505048360247,
|
||||
0.932060075968990209, 0.945198953453078028, 0.959879091812415930, 0.977101701282731328,
|
||||
1.000000000000000000];
|
||||
pub static ZIG_EXP_R: f64 = 7.697117470131050077;
|
||||
pub const ZIG_EXP_R: f64 = 7.697117470131050077;
|
||||
pub static ZIG_EXP_X: [f64; 257] =
|
||||
[8.697117470131052741, 7.697117470131050077, 6.941033629377212577, 6.478378493832569696,
|
||||
6.144164665772472667, 5.882144315795399869, 5.666410167454033697, 5.482890627526062488,
|
||||
|
@ -101,9 +101,8 @@ macro_rules! declare_lint {
|
||||
#[macro_export]
|
||||
macro_rules! lint_array { ($( $lint:expr ),*) => (
|
||||
{
|
||||
#[allow(non_upper_case_globals)]
|
||||
static array: LintArray = &[ $( &$lint ),* ];
|
||||
array
|
||||
static ARRAY: LintArray = &[ $( &$lint ),* ];
|
||||
ARRAY
|
||||
}
|
||||
) }
|
||||
|
||||
|
@ -55,7 +55,7 @@ use visit_ast;
|
||||
|
||||
/// A stable identifier to the particular version of JSON output.
|
||||
/// Increment this when the `Crate` and related structures change.
|
||||
pub static SCHEMA_VERSION: &'static str = "0.8.3";
|
||||
pub const SCHEMA_VERSION: &'static str = "0.8.3";
|
||||
|
||||
mod inline;
|
||||
mod simplify;
|
||||
|
@ -483,7 +483,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn multiple_connect_interleaved_greedy_schedule() {
|
||||
static MAX: usize = 10;
|
||||
const MAX: usize = 10;
|
||||
each_ip(&mut |addr| {
|
||||
let acceptor = t!(TcpListener::bind(&addr));
|
||||
|
||||
@ -890,7 +890,7 @@ mod tests {
|
||||
socket_addr, name, listener_inner);
|
||||
assert_eq!(format!("{:?}", listener), compare);
|
||||
|
||||
let mut stream = t!(TcpStream::connect(&("localhost",
|
||||
let stream = t!(TcpStream::connect(&("localhost",
|
||||
socket_addr.port())));
|
||||
let stream_inner = stream.0.socket().as_inner();
|
||||
let compare = format!("TcpStream {{ addr: {:?}, \
|
||||
|
@ -187,7 +187,7 @@ mod tests {
|
||||
assert_eq!(*lock.borrow(), 4950);
|
||||
});
|
||||
for i in 0..100 {
|
||||
let mut lock = m.lock().unwrap();
|
||||
let lock = m.lock().unwrap();
|
||||
*lock.borrow_mut() += i;
|
||||
}
|
||||
drop(lock);
|
||||
|
@ -200,9 +200,8 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt,
|
||||
ident: name.clone(),
|
||||
attrs: Vec::new(),
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
node: ast::ItemStatic(
|
||||
node: ast::ItemConst(
|
||||
ty,
|
||||
ast::MutImmutable,
|
||||
expr,
|
||||
),
|
||||
vis: ast::Public,
|
||||
|
@ -452,6 +452,7 @@ impl<'a, 'b> Context<'a, 'b> {
|
||||
Some(ecx.lifetime(sp, special_idents::static_lifetime.name)),
|
||||
ast::MutImmutable);
|
||||
let slice = ecx.expr_vec_slice(sp, pieces);
|
||||
// static instead of const to speed up codegen by not requiring this to be inlined
|
||||
let st = ast::ItemStatic(ty, ast::MutImmutable, slice);
|
||||
|
||||
let name = ecx.ident_of(name);
|
||||
|
Loading…
x
Reference in New Issue
Block a user