rust-lang / rust-lang/rust-clippy
boxed_local false positive for ?Sized
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
fn lol(x: Box<[u8]>) {
unimplemented!();
}
warning: local variable doesn't need to be boxed here
--> src/lib.rs:1:8
|
1 | fn lol(x: Box<[u8]>) {
| ^
|
= note: `#[warn(clippy::boxed_local)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#boxed_local
This is kind of an interesting case; the suggestion isn't wrong per se, but it's definitely not optimal. The lint explainer as currently worded strongly suggests "an unboxed T would work fine", whereas with ?Sized values this obviously cannot be done. The owned value has to be boxed or otherwise behind an indirection.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the boxed_local warning with the linked Rust Playground example, then inspect the boxed_local lint and its explanation. Confirm how the lint handles Box<[u8]> and ?Sized values; done means the diagnostic no longer misleadingly suggests unboxing when indirection is required, with relevant behavior covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100