Skip to content

False positive: const_static_lifetime associated constants #2456

Closed
@alexheretic

Description

@alexheretic

Clippy and rustc don't seem to agree when it comes to declaring static associated constant lifetimes.

trait Foo {
    const BAR: &'static str = "bar";
}

clippy

warning: Constants have by default a `'static` lifetime
 --> src/main.rs:5:17
  |
5 |     const BAR: &'static str = "bar";
  |                -^^^^^^^---- help: consider removing `'static`: `&str`

rustc

error[E0106]: missing lifetime specifier
 --> src/main.rs:5:16
  |
5 |     const BAR: &str = "bar";
  |                ^ expected lifetime parameter

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions