You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
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.
When augmenting the header constants defined in
http::header
with my own custom header, clippy warns me thatHeaderName
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 defaultThe text was updated successfully, but these errors were encountered: