Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clippy considers HeaderName to be "interior mutable" #607

Closed
rawler opened this issue May 9, 2023 · 3 comments
Closed

Clippy considers HeaderName to be "interior mutable" #607

rawler opened this issue May 9, 2023 · 3 comments

Comments

@rawler
Copy link

rawler commented May 9, 2023

When augmenting the header constants defined in http::header with my own custom header, clippy warns me that HeaderName is "interior mutable".

warning: a const item should never be interior mutable
--> src/my_source.rs:39:1
|
39 | const X_REQUEST_ID_HEADER: HeaderName = HeaderName::from_static("x-request-id");
| -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| make this a static item (maybe with lazy_static)
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#declare_interior_mutable_const
= note: #[warn(clippy::declare_interior_mutable_const)] on by default

@rawler
Copy link
Author

rawler commented May 9, 2023

Haven't had time to dig into whether HeaderName really is interior-mutable yet, or if clippy is just misdetecting. If it really is correct, I'm guessing the same interior mutability could be detect by compiler when not used as const, preventing some optimizations at compile-time?

Regardess, this right now gets in the way from defining custom HeaderName as const.

@seanmonstar
Copy link
Member

See #599.

@seanmonstar seanmonstar closed this as not planned Won't fix, can't repro, duplicate, stale May 9, 2023
@rawler
Copy link
Author

rawler commented May 16, 2023

Ugh. I thought I search for duplicates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants