Skip to content

Commit b26166a

Browse files
committed
Drop 'static for pub const strings
Constant and static declaration have a 'static live time by default, that is already elided since 1.17. Clippy complains on this kind of strings that are present in the generated code. This patch remove the 'static live time for those strings. Fix rust-lang#1612 Signed-off-by: Alberto Planas <[email protected]>
1 parent 82462a3 commit b26166a

File tree

6 files changed

+6
-6
lines changed

6 files changed

+6
-6
lines changed

src/codegen/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ impl CodeGenerator for Var {
668668
let cstr = helpers::ast_ty::cstr_expr(string);
669669
result.push(quote! {
670670
#(#attrs)*
671-
pub const #canonical_ident : &'static #ty = #cstr ;
671+
pub const #canonical_ident : &#ty = #cstr ;
672672
});
673673
}
674674
Err(..) => {

tests/expectations/tests/libclang-3.9/constant-evaluate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ pub const BAZ: ::std::os::raw::c_longlong = 24;
2323
pub const fuzz: f64 = 51.0;
2424
pub const BAZZ: ::std::os::raw::c_char = 53;
2525
pub const WAT: ::std::os::raw::c_char = 0;
26-
pub const bytestring: &'static [u8; 4usize] = b"Foo\0";
26+
pub const bytestring: &[u8; 4usize] = b"Foo\0";
2727
pub const NOT_UTF8: [u8; 5usize] = [240u8, 40u8, 140u8, 40u8, 0u8];

tests/expectations/tests/libclang-4/constant-evaluate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ pub const BAZ: ::std::os::raw::c_longlong = 24;
2121
pub const fuzz: f64 = 51.0;
2222
pub const BAZZ: ::std::os::raw::c_char = 53;
2323
pub const WAT: ::std::os::raw::c_char = 0;
24-
pub const bytestring: &'static [u8; 4usize] = b"Foo\0";
24+
pub const bytestring: &[u8; 4usize] = b"Foo\0";
2525
pub const NOT_UTF8: [u8; 5usize] = [240u8, 40u8, 140u8, 40u8, 0u8];

tests/expectations/tests/libclang-5/constant-evaluate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ pub const BAZ: ::std::os::raw::c_longlong = 24;
2121
pub const fuzz: f64 = 51.0;
2222
pub const BAZZ: ::std::os::raw::c_char = 53;
2323
pub const WAT: ::std::os::raw::c_char = 0;
24-
pub const bytestring: &'static [u8; 4usize] = b"Foo\0";
24+
pub const bytestring: &[u8; 4usize] = b"Foo\0";
2525
pub const NOT_UTF8: [u8; 5usize] = [240u8, 40u8, 140u8, 40u8, 0u8];

tests/expectations/tests/libclang-9/constant-evaluate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ pub const BAZ: ::std::os::raw::c_longlong = 24;
2121
pub const fuzz: f64 = 51.0;
2222
pub const BAZZ: ::std::os::raw::c_char = 53;
2323
pub const WAT: ::std::os::raw::c_char = 0;
24-
pub const bytestring: &'static [u8; 4usize] = b"Foo\0";
24+
pub const bytestring: &[u8; 4usize] = b"Foo\0";
2525
pub const NOT_UTF8: [u8; 5usize] = [240u8, 40u8, 140u8, 40u8, 0u8];

tests/expectations/tests/macro_const.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
non_upper_case_globals
66
)]
77

8-
pub const foo: &'static [u8; 4usize] = b"bar\0";
8+
pub const foo: &[u8; 4usize] = b"bar\0";
99
pub const CHAR: u8 = 98u8;
1010
pub const CHARR: u8 = 0u8;
1111
pub const FLOAT: f64 = 5.09;

0 commit comments

Comments
 (0)