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

needless_late_init message could be easier to read #8530

Closed
rbtcollins opened this issue Mar 12, 2022 · 2 comments · Fixed by #8779
Closed

needless_late_init message could be easier to read #8530

rbtcollins opened this issue Mar 12, 2022 · 2 comments · Fixed by #8779
Assignees
Labels
good-first-issue These issues are a good way to get started with Clippy

Comments

@rbtcollins
Copy link

rbtcollins commented Mar 12, 2022

Description

Currently it reports the source line of the let; then the replacement code, but the actual original init is not shown.
e.g.

warning: unneeded late initalization
  --> src\cli\job.rs:82:9
   |
82 |         let mut info: JOBOBJECT_EXTENDED_LIMIT_INFORMATION;
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(clippy::needless_late_init)]` on by default
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_late_init
help: declare `info` here
   |
83 |         let mut info: JOBOBJECT_EXTENDED_LIMIT_INFORMATION = mem::zeroed();
   |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

could be instead
warning: unneeded late initalization
--> src\cli\job.rs:82:9
|
82 | let mut info: JOBOBJECT_EXTENDED_LIMIT_INFORMATION;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ created here
83 | info = mem::zeroed();
^^^^^^^^^^^^^^^^^^^^ initialised here
|
= note: #[warn(clippy::needless_late_init)] on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_late_init
help: declare info here
|
83 | let mut info: JOBOBJECT_EXTENDED_LIMIT_INFORMATION = mem::zeroed();
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Version

rustc 1.60.0-beta.3 (e5effbd0b 2022-03-07)
binary: rustc
commit-hash: e5effbd0b34c9ede216e21d3f60dcbad0b863676
commit-date: 2022-03-07
host: x86_64-pc-windows-msvc
release: 1.60.0-beta.3
LLVM version: 14.0.0

Additional Labels

No response

@Serial-ATA
Copy link
Contributor

@rustbot label +good-first-issue

@rustbot rustbot added the good-first-issue These issues are a good way to get started with Clippy label Apr 26, 2022
@spiral-ladder
Copy link
Contributor

@rustbot claim

bors added a commit that referenced this issue May 3, 2022
Easier readability for `needless_late_init` message

Closes #8530

Updated the lint to use a `MultiSpan`, showing where the `let` statement was first used and where the initialisation statement was done, as in the format described, for easier readability.

Was wondering why, when pushing the span label for the initialisation statement, that sometimes the prior statement above the initialisation statement gets pulled into the output as well - any insight is appreciated!
@bors bors closed this as completed in a10fe90 May 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good-first-issue These issues are a good way to get started with Clippy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants