diff options
| author | bors <bors@rust-lang.org> | 2017-09-10 10:09:47 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-09-10 10:09:47 +0000 |
| commit | 23aaeb573b626a51af9ecc97680663153e4ab2b0 (patch) | |
| tree | 76d3ea096545044d5f30f1b9bfb947605a04452e /src/libstd | |
| parent | 34035d23ff5acd9bd08602bfab5d667450243966 (diff) | |
| parent | 10f66bd6e494c5b329f6b21b31e388e0ed3d69c1 (diff) | |
| download | rust-23aaeb573b626a51af9ecc97680663153e4ab2b0.tar.gz rust-23aaeb573b626a51af9ecc97680663153e4ab2b0.zip | |
Auto merge of #44312 - eddyb:static-by-any-other-name, r=alexcrichton
Use rvalue promotion to 'static instead of static items. Fixes #44240. Among other things, in crates that do a lot of formatting, this could reduce the number of items, although I haven't measured the performance benefits. If there's a codegen slowdown, that should IMO be solved by caching the output of miri, *not* by using `static`. r? @alexcrichton
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/ffi/c_str.rs | 2 | ||||
| -rw-r--r-- | src/libstd/macros.rs | 18 |
2 files changed, 4 insertions, 16 deletions
diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index 7392a153e3b..7992aefcb42 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -545,7 +545,7 @@ impl fmt::Debug for CStr { #[stable(feature = "cstr_default", since = "1.10.0")] impl<'a> Default for &'a CStr { fn default() -> &'a CStr { - static SLICE: &'static [c_char] = &[0]; + const SLICE: &'static [c_char] = &[0]; unsafe { CStr::from_ptr(SLICE.as_ptr()) } } } diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index 72d561fae3b..8089671f309 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -66,23 +66,11 @@ macro_rules! panic { panic!("explicit panic") }); ($msg:expr) => ({ - $crate::rt::begin_panic($msg, { - // static requires less code at runtime, more constant data - static _FILE_LINE_COL: (&'static str, u32, u32) = (file!(), line!(), - __rust_unstable_column!()); - &_FILE_LINE_COL - }) + $crate::rt::begin_panic($msg, &(file!(), line!(), __rust_unstable_column!())) }); ($fmt:expr, $($arg:tt)+) => ({ - $crate::rt::begin_panic_fmt(&format_args!($fmt, $($arg)+), { - // The leading _'s are to avoid dead code warnings if this is - // used inside a dead function. Just `#[allow(dead_code)]` is - // insufficient, since the user may have - // `#[forbid(dead_code)]` and which cannot be overridden. - static _FILE_LINE_COL: (&'static str, u32, u32) = (file!(), line!(), - __rust_unstable_column!()); - &_FILE_LINE_COL - }) + $crate::rt::begin_panic_fmt(&format_args!($fmt, $($arg)+), + &(file!(), line!(), __rust_unstable_column!())) }); } |
