Skip to content

zero_ptr lint detected for any lazy_static code #1580

Closed
@vitiral

Description

@vitiral

I'm running clippy v0.0.115

This code

pub const ART_VALID_STR: &'static str = "(REQ|SPC|RSK|TST)(-[A-Z0-9_-]*[A-Z0-9_])?";

lazy_static!{
    // must start with artifact type, followed by "-", followed by at least 1 valid character
    // cannot end with "-"
    pub static ref ART_VALID: Regex = Regex::new(
        &format!("^{}$", ART_VALID_STR)).unwrap();
    pub static ref PARENT_PATH: PathBuf = PathBuf::from("PARENT");
    pub static ref INCREMENTING_ID: AtomicUsize = AtomicUsize::new(0);
}

Is generating this error repeatedely:

warning: `0 as *const _` detected. Consider using `ptr::null()`
  --> src/core/types.rs:26:1
   |
26 |   lazy_static!{
   |  _^ starting here...
27 | |     // must start with artifact type, followed by "-", followed by at least 1 valid character
28 | |     // cannot end with "-"
29 | |     pub static ref ART_VALID: Regex = Regex::new(
30 | |         &format!("^{}$", ART_VALID_STR)).unwrap();
31 | |     pub static ref PARENT_PATH: PathBuf = PathBuf::from("PARENT");
32 | |     pub static ref INCREMENTING_ID: AtomicUsize = AtomicUsize::new(0);
33 | | }
   | |_^ ...ending here
   |
   = note: #[warn(zero_ptr)] on by default
   = help: for further information visit https://github.com/Manishearth/rust-clippy/wiki#zero_ptr
   = note: this error originates in a macro outside of the current crate

This never happened before. All I did was update clippy to the latest version.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveT-middleType: Probably requires verifiying typesgood first issueThese issues are a good way to get started with Clippy

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions