rust-lang / rust-lang/rust-clippy

boxed_local false positive for ?Sized

Open
#4,740 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug C-enhancement I-suggestion-causes-error L-suggestion
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

Playground

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.