Skip to content

Commit 97452d9

Browse files
authored
Rollup merge of rust-lang#56500 - ljedrz:cleanup_rest_of_const_lifetimes, r=zackmdavis
cleanup: remove static lifetimes from consts A follow-up to rust-lang#56497.
2 parents f39173d + d0c64bb commit 97452d9

File tree

26 files changed

+88
-91
lines changed

26 files changed

+88
-91
lines changed

src/liballoc/string.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ impl String {
577577
return Cow::Borrowed("");
578578
};
579579

580-
const REPLACEMENT: &'static str = "\u{FFFD}";
580+
const REPLACEMENT: &str = "\u{FFFD}";
581581

582582
let mut res = String::with_capacity(v.len());
583583
res.push_str(first_valid);

src/libcore/fmt/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1381,7 +1381,7 @@ impl<'a> Formatter<'a> {
13811381
for part in formatted.parts {
13821382
match *part {
13831383
flt2dec::Part::Zero(mut nzeroes) => {
1384-
const ZEROES: &'static str = // 64 zeroes
1384+
const ZEROES: &str = // 64 zeroes
13851385
"0000000000000000000000000000000000000000000000000000000000000000";
13861386
while nzeroes > ZEROES.len() {
13871387
self.buf.write_str(ZEROES)?;

src/libcore/unicode/printable.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ pub(crate) fn is_printable(x: char) -> bool {
8080
}
8181
}
8282

83-
const SINGLETONS0U: &'static [(u8, u8)] = &[
83+
const SINGLETONS0U: &[(u8, u8)] = &[
8484
(0x00, 1),
8585
(0x03, 5),
8686
(0x05, 6),
@@ -122,7 +122,7 @@ const SINGLETONS0U: &'static [(u8, u8)] = &[
122122
(0xfe, 3),
123123
(0xff, 9),
124124
];
125-
const SINGLETONS0L: &'static [u8] = &[
125+
const SINGLETONS0L: &[u8] = &[
126126
0xad, 0x78, 0x79, 0x8b, 0x8d, 0xa2, 0x30, 0x57,
127127
0x58, 0x8b, 0x8c, 0x90, 0x1c, 0x1d, 0xdd, 0x0e,
128128
0x0f, 0x4b, 0x4c, 0xfb, 0xfc, 0x2e, 0x2f, 0x3f,
@@ -162,7 +162,7 @@ const SINGLETONS0L: &'static [u8] = &[
162162
0x91, 0xfe, 0xff, 0x53, 0x67, 0x75, 0xc8, 0xc9,
163163
0xd0, 0xd1, 0xd8, 0xd9, 0xe7, 0xfe, 0xff,
164164
];
165-
const SINGLETONS1U: &'static [(u8, u8)] = &[
165+
const SINGLETONS1U: &[(u8, u8)] = &[
166166
(0x00, 6),
167167
(0x01, 1),
168168
(0x03, 1),
@@ -197,7 +197,7 @@ const SINGLETONS1U: &'static [(u8, u8)] = &[
197197
(0xf0, 4),
198198
(0xf9, 4),
199199
];
200-
const SINGLETONS1L: &'static [u8] = &[
200+
const SINGLETONS1L: &[u8] = &[
201201
0x0c, 0x27, 0x3b, 0x3e, 0x4e, 0x4f, 0x8f, 0x9e,
202202
0x9e, 0x9f, 0x06, 0x07, 0x09, 0x36, 0x3d, 0x3e,
203203
0x56, 0xf3, 0xd0, 0xd1, 0x04, 0x14, 0x18, 0x36,
@@ -219,7 +219,7 @@ const SINGLETONS1L: &'static [u8] = &[
219219
0x78, 0x7d, 0x7f, 0x8a, 0xa4, 0xaa, 0xaf, 0xb0,
220220
0xc0, 0xd0, 0x3f, 0x71, 0x72, 0x7b,
221221
];
222-
const NORMAL0: &'static [u8] = &[
222+
const NORMAL0: &[u8] = &[
223223
0x00, 0x20,
224224
0x5f, 0x22,
225225
0x82, 0xdf, 0x04,
@@ -363,7 +363,7 @@ const NORMAL0: &'static [u8] = &[
363363
0x1b, 0x03,
364364
0x0f, 0x0d,
365365
];
366-
const NORMAL1: &'static [u8] = &[
366+
const NORMAL1: &[u8] = &[
367367
0x5e, 0x22,
368368
0x7b, 0x05,
369369
0x03, 0x04,

src/librustc/dep_graph/dep_node.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ macro_rules! define_dep_nodes {
381381
#[allow(dead_code, non_upper_case_globals)]
382382
pub mod label_strs {
383383
$(
384-
pub const $variant: &'static str = stringify!($variant);
384+
pub const $variant: &str = stringify!($variant);
385385
)*
386386
}
387387
);

src/librustc/hir/print.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pub trait PpAnn {
6565

6666
pub struct NoAnn;
6767
impl PpAnn for NoAnn {}
68-
pub const NO_ANN: &'static dyn PpAnn = &NoAnn;
68+
pub const NO_ANN: &dyn PpAnn = &NoAnn;
6969

7070
impl PpAnn for hir::Crate {
7171
fn try_fetch_item(&self, item: ast::NodeId) -> Option<&hir::Item> {

src/librustc/ich/mod.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ mod impls_misc;
2424
mod impls_ty;
2525
mod impls_syntax;
2626

27-
pub const ATTR_DIRTY: &'static str = "rustc_dirty";
28-
pub const ATTR_CLEAN: &'static str = "rustc_clean";
29-
pub const ATTR_IF_THIS_CHANGED: &'static str = "rustc_if_this_changed";
30-
pub const ATTR_THEN_THIS_WOULD_NEED: &'static str = "rustc_then_this_would_need";
31-
pub const ATTR_PARTITION_REUSED: &'static str = "rustc_partition_reused";
32-
pub const ATTR_PARTITION_CODEGENED: &'static str = "rustc_partition_codegened";
33-
pub const ATTR_EXPECTED_CGU_REUSE: &'static str = "rustc_expected_cgu_reuse";
27+
pub const ATTR_DIRTY: &str = "rustc_dirty";
28+
pub const ATTR_CLEAN: &str = "rustc_clean";
29+
pub const ATTR_IF_THIS_CHANGED: &str = "rustc_if_this_changed";
30+
pub const ATTR_THEN_THIS_WOULD_NEED: &str = "rustc_then_this_would_need";
31+
pub const ATTR_PARTITION_REUSED: &str = "rustc_partition_reused";
32+
pub const ATTR_PARTITION_CODEGENED: &str = "rustc_partition_codegened";
33+
pub const ATTR_EXPECTED_CGU_REUSE: &str = "rustc_expected_cgu_reuse";
3434

35-
pub const IGNORED_ATTRIBUTES: &'static [&'static str] = &[
35+
pub const IGNORED_ATTRIBUTES: &[&str] = &[
3636
"cfg",
3737
ATTR_IF_THIS_CHANGED,
3838
ATTR_THEN_THIS_WOULD_NEED,

src/librustc/session/config.rs

+21-22
Original file line numberDiff line numberDiff line change
@@ -780,43 +780,42 @@ macro_rules! options {
780780
}
781781

782782
pub type $setter_name = fn(&mut $struct_name, v: Option<&str>) -> bool;
783-
pub const $stat: &'static [(&'static str, $setter_name,
784-
Option<&'static str>, &'static str)] =
783+
pub const $stat: &[(&str, $setter_name, Option<&str>, &str)] =
785784
&[ $( (stringify!($opt), $mod_set::$opt, $mod_desc::$parse, $desc) ),* ];
786785

787786
#[allow(non_upper_case_globals, dead_code)]
788787
mod $mod_desc {
789-
pub const parse_bool: Option<&'static str> = None;
790-
pub const parse_opt_bool: Option<&'static str> =
788+
pub const parse_bool: Option<&str> = None;
789+
pub const parse_opt_bool: Option<&str> =
791790
Some("one of: `y`, `yes`, `on`, `n`, `no`, or `off`");
792-
pub const parse_string: Option<&'static str> = Some("a string");
793-
pub const parse_string_push: Option<&'static str> = Some("a string");
794-
pub const parse_pathbuf_push: Option<&'static str> = Some("a path");
795-
pub const parse_opt_string: Option<&'static str> = Some("a string");
796-
pub const parse_opt_pathbuf: Option<&'static str> = Some("a path");
797-
pub const parse_list: Option<&'static str> = Some("a space-separated list of strings");
798-
pub const parse_opt_list: Option<&'static str> = Some("a space-separated list of strings");
799-
pub const parse_uint: Option<&'static str> = Some("a number");
800-
pub const parse_passes: Option<&'static str> =
791+
pub const parse_string: Option<&str> = Some("a string");
792+
pub const parse_string_push: Option<&str> = Some("a string");
793+
pub const parse_pathbuf_push: Option<&str> = Some("a path");
794+
pub const parse_opt_string: Option<&str> = Some("a string");
795+
pub const parse_opt_pathbuf: Option<&str> = Some("a path");
796+
pub const parse_list: Option<&str> = Some("a space-separated list of strings");
797+
pub const parse_opt_list: Option<&str> = Some("a space-separated list of strings");
798+
pub const parse_uint: Option<&str> = Some("a number");
799+
pub const parse_passes: Option<&str> =
801800
Some("a space-separated list of passes, or `all`");
802-
pub const parse_opt_uint: Option<&'static str> =
801+
pub const parse_opt_uint: Option<&str> =
803802
Some("a number");
804-
pub const parse_panic_strategy: Option<&'static str> =
803+
pub const parse_panic_strategy: Option<&str> =
805804
Some("either `unwind` or `abort`");
806-
pub const parse_relro_level: Option<&'static str> =
805+
pub const parse_relro_level: Option<&str> =
807806
Some("one of: `full`, `partial`, or `off`");
808-
pub const parse_sanitizer: Option<&'static str> =
807+
pub const parse_sanitizer: Option<&str> =
809808
Some("one of: `address`, `leak`, `memory` or `thread`");
810-
pub const parse_linker_flavor: Option<&'static str> =
809+
pub const parse_linker_flavor: Option<&str> =
811810
Some(::rustc_target::spec::LinkerFlavor::one_of());
812-
pub const parse_optimization_fuel: Option<&'static str> =
811+
pub const parse_optimization_fuel: Option<&str> =
813812
Some("crate=integer");
814-
pub const parse_unpretty: Option<&'static str> =
813+
pub const parse_unpretty: Option<&str> =
815814
Some("`string` or `string=string`");
816-
pub const parse_lto: Option<&'static str> =
815+
pub const parse_lto: Option<&str> =
817816
Some("either a boolean (`yes`, `no`, `on`, `off`, etc), `thin`, \
818817
`fat`, or omitted");
819-
pub const parse_cross_lang_lto: Option<&'static str> =
818+
pub const parse_cross_lang_lto: Option<&str> =
820819
Some("either a boolean (`yes`, `no`, `on`, `off`, etc), \
821820
or the path to the linker plugin");
822821
}

src/librustc/session/filesearch.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,12 @@ fn find_libdir(sysroot: &Path) -> Cow<'static, str> {
179179
// "lib" (i.e. non-default), this value is used (see issue #16552).
180180

181181
#[cfg(target_pointer_width = "64")]
182-
const PRIMARY_LIB_DIR: &'static str = "lib64";
182+
const PRIMARY_LIB_DIR: &str = "lib64";
183183

184184
#[cfg(target_pointer_width = "32")]
185-
const PRIMARY_LIB_DIR: &'static str = "lib32";
185+
const PRIMARY_LIB_DIR: &str = "lib32";
186186

187-
const SECONDARY_LIB_DIR: &'static str = "lib";
187+
const SECONDARY_LIB_DIR: &str = "lib";
188188

189189
match option_env!("CFG_LIBDIR_RELATIVE") {
190190
Some(libdir) if libdir != "lib" => libdir.into(),
@@ -198,4 +198,4 @@ fn find_libdir(sysroot: &Path) -> Cow<'static, str> {
198198

199199
// The name of rustc's own place to organize libraries.
200200
// Used to be "rustc", now the default is "rustlib"
201-
const RUST_LIB_DIR: &'static str = "rustlib";
201+
const RUST_LIB_DIR: &str = "rustlib";

src/librustc/util/common.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use lazy_static;
2828
use session::Session;
2929

3030
// The name of the associated type for `Fn` return types
31-
pub const FN_OUTPUT_NAME: &'static str = "Output";
31+
pub const FN_OUTPUT_NAME: &str = "Output";
3232

3333
// Useful type to use with `Result<>` indicate that an error has already
3434
// been reported to the user, so no need to continue checking.

src/librustc_codegen_ssa/back/symbol_export.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ fn exported_symbols_provider_local<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
225225
// These are weak symbols that point to the profile version and the
226226
// profile name, which need to be treated as exported so LTO doesn't nix
227227
// them.
228-
const PROFILER_WEAK_SYMBOLS: [&'static str; 2] = [
228+
const PROFILER_WEAK_SYMBOLS: [&str; 2] = [
229229
"__llvm_profile_raw_version",
230230
"__llvm_profile_filename",
231231
];

src/librustc_codegen_utils/symbol_names.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ impl SymbolPathBuffer {
389389

390390
impl ItemPathBuffer for SymbolPathBuffer {
391391
fn root_mode(&self) -> &RootMode {
392-
const ABSOLUTE: &'static RootMode = &RootMode::Absolute;
392+
const ABSOLUTE: &RootMode = &RootMode::Absolute;
393393
ABSOLUTE
394394
}
395395

src/librustc_incremental/assert_module_sources.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ use syntax::ast;
4040
use rustc::ich::{ATTR_PARTITION_REUSED, ATTR_PARTITION_CODEGENED,
4141
ATTR_EXPECTED_CGU_REUSE};
4242

43-
const MODULE: &'static str = "module";
44-
const CFG: &'static str = "cfg";
45-
const KIND: &'static str = "kind";
43+
const MODULE: &str = "module";
44+
const CFG: &str = "cfg";
45+
const KIND: &str = "kind";
4646

4747
pub fn assert_module_sources<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
4848
tcx.dep_graph.with_ignore(|| {

src/librustc_incremental/persist/file_format.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ use rustc::session::config::nightly_options;
2828
use rustc_serialize::opaque::Encoder;
2929

3030
/// The first few bytes of files generated by incremental compilation
31-
const FILE_MAGIC: &'static [u8] = b"RSIC";
31+
const FILE_MAGIC: &[u8] = b"RSIC";
3232

3333
/// Change this if the header format changes
3434
const HEADER_FORMAT_VERSION: u16 = 0;
3535

3636
/// A version string that hopefully is always different for compiler versions
3737
/// with different encodings of incremental compilation artifacts. Contains
3838
/// the git commit hash.
39-
const RUSTC_VERSION: Option<&'static str> = option_env!("CFG_VERSION");
39+
const RUSTC_VERSION: Option<&str> = option_env!("CFG_VERSION");
4040

4141
pub fn write_file_header(stream: &mut Encoder) {
4242
stream.emit_raw_bytes(FILE_MAGIC);

src/librustc_incremental/persist/fs.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,10 @@ use std::time::{UNIX_EPOCH, SystemTime, Duration};
128128

129129
use rand::{RngCore, thread_rng};
130130

131-
const LOCK_FILE_EXT: &'static str = ".lock";
132-
const DEP_GRAPH_FILENAME: &'static str = "dep-graph.bin";
133-
const WORK_PRODUCTS_FILENAME: &'static str = "work-products.bin";
134-
const QUERY_CACHE_FILENAME: &'static str = "query-cache.bin";
131+
const LOCK_FILE_EXT: &str = ".lock";
132+
const DEP_GRAPH_FILENAME: &str = "dep-graph.bin";
133+
const WORK_PRODUCTS_FILENAME: &str = "work-products.bin";
134+
const QUERY_CACHE_FILENAME: &str = "query-cache.bin";
135135

136136
// We encode integers using the following base, so they are shorter than decimal
137137
// or hexadecimal numbers (we want short file and directory names). Since these

src/librustc_metadata/schema.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub const METADATA_VERSION: u8 = 4;
5252
/// This header is followed by the position of the `CrateRoot`,
5353
/// which is encoded as a 32-bit big-endian unsigned integer,
5454
/// and further followed by the rustc version string.
55-
pub const METADATA_HEADER: &'static [u8; 12] =
55+
pub const METADATA_HEADER: &[u8; 12] =
5656
&[0, 0, 0, 0, b'r', b'u', b's', b't', 0, 0, 0, METADATA_VERSION];
5757

5858
/// A value of type T referred to by its absolute position

src/librustc_mir/dataflow/graphviz.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ where MWF: MirWithFlowState<'tcx>,
137137
block: BasicBlock,
138138
mir: &Mir) -> io::Result<()> {
139139
// Header rows
140-
const HDRS: [&'static str; 4] = ["ENTRY", "MIR", "BLOCK GENS", "BLOCK KILLS"];
141-
const HDR_FMT: &'static str = "bgcolor=\"grey\"";
140+
const HDRS: [&str; 4] = ["ENTRY", "MIR", "BLOCK GENS", "BLOCK KILLS"];
141+
const HDR_FMT: &str = "bgcolor=\"grey\"";
142142
write!(w, "<table><tr><td rowspan=\"{}\">", HDRS.len())?;
143143
write!(w, "{:?}", block.index())?;
144144
write!(w, "</td></tr><tr>")?;

src/librustc_mir/diagnostics.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ static X: i32 = 1;
606606
const C: i32 = 2;
607607
608608
// these three are not allowed:
609-
const CR: &'static mut i32 = &mut C;
609+
const CR: &mut i32 = &mut C;
610610
static STATIC_REF: &'static mut i32 = &mut X;
611611
static CONST_REF: &'static mut i32 = &mut C;
612612
```
@@ -1163,18 +1163,18 @@ You can also have this error while using a cell type:
11631163
use std::cell::Cell;
11641164
11651165
const A: Cell<usize> = Cell::new(1);
1166-
const B: &'static Cell<usize> = &A;
1166+
const B: &Cell<usize> = &A;
11671167
// error: cannot borrow a constant which may contain interior mutability,
11681168
// create a static instead
11691169
11701170
// or:
11711171
struct C { a: Cell<usize> }
11721172
11731173
const D: C = C { a: Cell::new(1) };
1174-
const E: &'static Cell<usize> = &D.a; // error
1174+
const E: &Cell<usize> = &D.a; // error
11751175
11761176
// or:
1177-
const F: &'static C = &D; // error
1177+
const F: &C = &D; // error
11781178
```
11791179
11801180
This is because cell types do operations that are not thread-safe. Due to this,

src/librustc_mir/util/pretty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use std::path::{Path, PathBuf};
2424
use super::graphviz::write_mir_fn_graphviz;
2525
use transform::MirSource;
2626

27-
const INDENT: &'static str = " ";
27+
const INDENT: &str = " ";
2828
/// Alignment for lining up comments following MIR statements
2929
pub(crate) const ALIGN: usize = 40;
3030

src/librustc_target/spec/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ macro_rules! supported_targets {
234234
$(mod $module;)*
235235

236236
/// List of supported targets
237-
const TARGETS: &'static [&'static str] = &[$($triple),*];
237+
const TARGETS: &[&str] = &[$($triple),*];
238238

239239
fn load_specific(target: &str) -> TargetResult {
240240
match target {

0 commit comments

Comments
 (0)