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 warning on const ArcStr literal #64

Open
kxxt opened this issue Aug 10, 2024 · 1 comment
Open

Clippy warning on const ArcStr literal #64

kxxt opened this issue Aug 10, 2024 · 1 comment

Comments

@kxxt
Copy link

kxxt commented Aug 10, 2024

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
Copy link
Owner

thomcc commented Aug 10, 2024

This is rust-lang/rust-clippy#12951, which is being fixed, but I agree we should improve things in the meantime.

@thomcc thomcc pinned this issue Aug 10, 2024
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