Closed lilyball closed 2 years ago
At the moment when static variables are expanded, no specific property additions are made, and it seems that some work needs to be done.
In the year since this issue was filed, has any progress been made here? Is there any problem with replacing the following lines: https://github.com/rust-lang-nursery/lazy-static.rs/blob/620be63b6ec4adf74870640ab1cf2c5280735f4e/src/lib.rs#L152-L160 With the following:
(@MAKE TY, $(#[$attr:meta])*, ($($vis:tt)*), $N:ident) => {
#[allow(missing_copy_implementations)]
#[allow(non_camel_case_types)]
#[allow(dead_code)]
$(#[$attr])*
$($vis)* struct $N {__private_field: ()}
#[doc(hidden)]
$(#[$attr])*
$($vis)* static $N: $N = $N {__private_field: ()};
};
Are there some attributes that should be applied to the static instead of the struct, and vice versa? Why even pass through attributes to the struct definition at all?
@Stzx said:
it seems that some work needs to be done
Any idea what work? As an outsider this seems a trivial issue. However, if there are additional considerations to be made I'm willing to put in the work to get this done.
Sorry to necro this issue, but it is still open and I've found a need for this functionality.
any update ?
Rust 1.59 , #[allow(non_upper_case_globals)] works
Not according to the Rust Playground
I've opened #197 that will just suppress the non_upper_case_globals
warning like we already do for non_camel_case_types
. It won't help users who have forbid(warnings)
enabled but is in line with the way we handle this class of warning already.
Adding the attribute
#[allow(non_upper_case_globals)]
doesn't work, since attributes I provide are applied to the synthesized type but not to the actualstatic
variable.produces
Playground link