Skip to content

boxed_local false positive for ?Sized #4740

Open
@CAD97

Description

@CAD97

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingC-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedL-suggestionLint: Improving, adding or fixing lint suggestions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions