Skip to content

borrow_interior_mutable_const interacts poorly with the http crate #3825

Closed
@sfackler

Description

@sfackler

The http crate defines constants for common header names, but any use of them triggers this lint:

use http::header::HOST;
use http::HeaderMap;

fn main() {
    let map = HeaderMap::new();
    println!("{}", map.contains_key(&HOST));
}
error: a const item with interior mutability should not be borrowed
 --> src/main.rs:6:38
  |
6 |     println!("{}", map.contains_key(&HOST));
  |                                      ^^^^
  |
  = note: #[deny(clippy::borrow_interior_mutable_const)] on by default
  = help: assign this const to a local or static variable, and use the variable here
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#borrow_interior_mutable_const

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions