thomcc / arcstr

Better reference counted strings for Rust
Apache License 2.0
111 stars 18 forks source link

Clippy warning on const ArcStr literal #64

Open kxxt opened 1 month ago

kxxt commented 1 month ago

I am getting the following clippy warning when using const ArcStr literals. IMO these warnings are harmless. It's probably a good idea to silence such warnings in arcstr::literal macro.

warning: a `const` item should never be interior mutable
   --> src/regex.rs:305:1
    |
305 | pub const SPACE: ArcStr = arcstr::literal!(" ");
    | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | |
    | 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
warning: a `const` item with interior mutability should not be borrowed
   --> src/tracer/state.rs:231:22
    |
231 |         let space = &SPACE;
    |                      ^^^^^
    |
    = 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
    = note: `#[warn(clippy::borrow_interior_mutable_const)]` on by default
thomcc commented 1 month ago

This is https://github.com/rust-lang/rust-clippy/issues/12951, which is being fixed, but I agree we should improve things in the meantime.