Skip to content

Commit bea1c4a

Browse files
committed
Auto merge of #25823 - oli-obk:static_to_const_lint, r=alexcrichton
r? @eddyb
2 parents 717e883 + ec078a0 commit bea1c4a

File tree

13 files changed

+18
-22
lines changed

13 files changed

+18
-22
lines changed

src/liballoc/boxed.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ use core::raw::{TraitObject};
8181
#[lang = "exchange_heap"]
8282
#[unstable(feature = "alloc",
8383
reason = "may be renamed; uncertain about custom allocator design")]
84-
pub static HEAP: () = ();
84+
pub const HEAP: () = ();
8585

8686
/// A pointer type for heap allocation.
8787
///

src/libcollections/bit.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ fn match_words <'a,'b>(a: &'a BitVec, b: &'b BitVec) -> (MatchWords<'a>, MatchWo
125125
}
126126
}
127127

128-
static TRUE: bool = true;
129-
static FALSE: bool = false;
128+
const TRUE: &'static bool = &true;
129+
const FALSE: &'static bool = &false;
130130

131131
/// The bitvector type.
132132
///
@@ -172,9 +172,9 @@ impl Index<usize> for BitVec {
172172
#[inline]
173173
fn index(&self, i: usize) -> &bool {
174174
if self.get(i).expect("index out of bounds") {
175-
&TRUE
175+
TRUE
176176
} else {
177-
&FALSE
177+
FALSE
178178
}
179179
}
180180
}

src/libcollections/vec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ use borrow::{Cow, IntoCow};
8383
use super::range::RangeArgument;
8484

8585
// FIXME- fix places which assume the max vector allowed has memory usize::MAX.
86-
static MAX_MEMORY_SIZE: usize = isize::MAX as usize;
86+
const MAX_MEMORY_SIZE: usize = isize::MAX as usize;
8787

8888
/// A growable list type, written `Vec<T>` but pronounced 'vector.'
8989
///

src/libcore/num/flt2dec/strategy/dragon.rs

-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ use num::flt2dec::estimator::estimate_scaling_factor;
2424
use num::flt2dec::bignum::Digit32 as Digit;
2525
use num::flt2dec::bignum::Big32x36 as Big;
2626

27-
// FIXME(#22540) const ref to static array seems to ICE
2827
static POW10: [Digit; 10] = [1, 10, 100, 1000, 10000, 100000,
2928
1000000, 10000000, 100000000, 1000000000];
3029
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
328327

329328
(len, k)
330329
}
331-

src/libcore/num/flt2dec/strategy/grisu.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ for i in xrange(-308, 333, 8):
8787
f = ((f << 64 >> (l-1)) + 1) >> 1; e += l - 64
8888
print ' (%#018x, %5d, %4d),' % (f, e, i)
8989
*/
90-
// FIXME(#22540) const ref to static array seems to ICE
90+
9191
#[doc(hidden)]
9292
pub static CACHED_POW10: [(u64, i16, i16); 81] = [ // (f, e, k)
9393
(0xe61acf033d1a45df, -1087, -308),
@@ -746,4 +746,3 @@ pub fn format_exact(d: &Decoded, buf: &mut [u8], limit: i16) -> (/*#digits*/ usi
746746
None => fallback(d, buf, limit),
747747
}
748748
}
749-

src/liblog/directive.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub struct LogDirective {
1717
pub level: u32,
1818
}
1919

20-
pub static LOG_LEVEL_NAMES: [&'static str; 4] = ["ERROR", "WARN", "INFO",
20+
pub const LOG_LEVEL_NAMES: [&'static str; 4] = ["ERROR", "WARN", "INFO",
2121
"DEBUG"];
2222

2323
/// Parse an individual log level that is either a number or a symbolic log level

src/librand/distributions/ziggurat_tables.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// algorithm. Autogenerated by `ziggurat_tables.py`.
1313

1414
pub type ZigTable = &'static [f64; 257];
15-
pub static ZIG_NORM_R: f64 = 3.654152885361008796;
15+
pub const ZIG_NORM_R: f64 = 3.654152885361008796;
1616
pub static ZIG_NORM_X: [f64; 257] =
1717
[3.910757959537090045, 3.654152885361008796, 3.449278298560964462, 3.320244733839166074,
1818
3.224575052047029100, 3.147889289517149969, 3.083526132001233044, 3.027837791768635434,
@@ -145,7 +145,7 @@ pub static ZIG_NORM_F: [f64; 257] =
145145
0.887984660763399880, 0.898095921906304051, 0.908726440060562912, 0.919991505048360247,
146146
0.932060075968990209, 0.945198953453078028, 0.959879091812415930, 0.977101701282731328,
147147
1.000000000000000000];
148-
pub static ZIG_EXP_R: f64 = 7.697117470131050077;
148+
pub const ZIG_EXP_R: f64 = 7.697117470131050077;
149149
pub static ZIG_EXP_X: [f64; 257] =
150150
[8.697117470131052741, 7.697117470131050077, 6.941033629377212577, 6.478378493832569696,
151151
6.144164665772472667, 5.882144315795399869, 5.666410167454033697, 5.482890627526062488,

src/librustc/lint/mod.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,8 @@ macro_rules! declare_lint {
101101
#[macro_export]
102102
macro_rules! lint_array { ($( $lint:expr ),*) => (
103103
{
104-
#[allow(non_upper_case_globals)]
105-
static array: LintArray = &[ $( &$lint ),* ];
106-
array
104+
static ARRAY: LintArray = &[ $( &$lint ),* ];
105+
ARRAY
107106
}
108107
) }
109108

src/librustdoc/clean/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ use visit_ast;
5555

5656
/// A stable identifier to the particular version of JSON output.
5757
/// Increment this when the `Crate` and related structures change.
58-
pub static SCHEMA_VERSION: &'static str = "0.8.3";
58+
pub const SCHEMA_VERSION: &'static str = "0.8.3";
5959

6060
mod inline;
6161
mod simplify;

src/libstd/net/tcp.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ mod tests {
483483

484484
#[test]
485485
fn multiple_connect_interleaved_greedy_schedule() {
486-
static MAX: usize = 10;
486+
const MAX: usize = 10;
487487
each_ip(&mut |addr| {
488488
let acceptor = t!(TcpListener::bind(&addr));
489489

@@ -890,7 +890,7 @@ mod tests {
890890
socket_addr, name, listener_inner);
891891
assert_eq!(format!("{:?}", listener), compare);
892892

893-
let mut stream = t!(TcpStream::connect(&("localhost",
893+
let stream = t!(TcpStream::connect(&("localhost",
894894
socket_addr.port())));
895895
let stream_inner = stream.0.socket().as_inner();
896896
let compare = format!("TcpStream {{ addr: {:?}, \

src/libstd/sys/common/remutex.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ mod tests {
187187
assert_eq!(*lock.borrow(), 4950);
188188
});
189189
for i in 0..100 {
190-
let mut lock = m.lock().unwrap();
190+
let lock = m.lock().unwrap();
191191
*lock.borrow_mut() += i;
192192
}
193193
drop(lock);

src/libsyntax/diagnostics/plugin.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,8 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt,
200200
ident: name.clone(),
201201
attrs: Vec::new(),
202202
id: ast::DUMMY_NODE_ID,
203-
node: ast::ItemStatic(
203+
node: ast::ItemConst(
204204
ty,
205-
ast::MutImmutable,
206205
expr,
207206
),
208207
vis: ast::Public,

src/libsyntax/ext/format.rs

+1
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,7 @@ impl<'a, 'b> Context<'a, 'b> {
452452
Some(ecx.lifetime(sp, special_idents::static_lifetime.name)),
453453
ast::MutImmutable);
454454
let slice = ecx.expr_vec_slice(sp, pieces);
455+
// static instead of const to speed up codegen by not requiring this to be inlined
455456
let st = ast::ItemStatic(ty, ast::MutImmutable, slice);
456457

457458
let name = ecx.ident_of(name);

0 commit comments

Comments
 (0)