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

boxed_local false positive for ?Sized #4740

Open
Tracked by #12046
CAD97 opened this issue Oct 26, 2019 · 1 comment
Open
Tracked by #12046

boxed_local false positive for ?Sized #4740

CAD97 opened this issue Oct 26, 2019 · 1 comment
Labels
C-bug Category: Clippy is not doing the correct thing C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied L-suggestion Lint: Improving, adding or fixing lint suggestions

Comments

@CAD97
Copy link
Contributor

CAD97 commented Oct 26, 2019

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.

@flip1995
Copy link
Member

The lint triggering here is correct, we should suggest to turn this into &[u8] though. See #4351 (comment)

@flip1995 flip1995 added L-suggestion Lint: Improving, adding or fixing lint suggestions C-bug Category: Clippy is not doing the correct thing C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages labels Oct 26, 2019
@phansch phansch added the I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied label Dec 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied L-suggestion Lint: Improving, adding or fixing lint suggestions
Projects
None yet
Development

No branches or pull requests

3 participants