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_lifetimes: don't show function body? #5284

Closed
matthiaskrgr opened this issue Mar 7, 2020 · 0 comments · Fixed by #5323
Closed

needless_lifetimes: don't show function body? #5284

matthiaskrgr opened this issue Mar 7, 2020 · 0 comments · Fixed by #5323
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages good-first-issue These issues are a good way to get started with Clippy L-suggestion Lint: Improving, adding or fixing lint suggestions

Comments

@matthiaskrgr
Copy link
Member


warning: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
    --> src/librustc_infer/traits/error_reporting/mod.rs:995:1
     |
995  | / pub fn recursive_type_with_infinite_size_error(
996  | |     tcx: TyCtxt<'tcx>,
997  | |     type_def_id: DefId,
998  | | ) -> DiagnosticBuilder<'tcx> {
...    |
1015 | |     err
1016 | | }
     | |_^
     |
     = note: `#[warn(clippy::needless_lifetimes)]` on by default
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes

The generated preview spans the entire function, is this actually necessary?
Could we skip the function body and only show the signature that contains the lifetimes?
Or perhaps limit the span to the function return type instead of the end of the function?:

    --> src/librustc_infer/traits/error_reporting/mod.rs:995:1
     |
995  | / pub fn recursive_type_with_infinite_size_error(
996  | |     tcx: TyCtxt<'tcx>,
997  | |     type_def_id: DefId,
998  | | ) -> DiagnosticBuilder<'tcx> {
...  | |______________________________^
     |
     = note: `#[warn(clippy::needless_lifetimes)]` on by default
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes
@matthiaskrgr matthiaskrgr changed the title needless_lifetimes: don't show function body needless_lifetimes: don't show function body? Mar 7, 2020
@flip1995 flip1995 added L-suggestion Lint: Improving, adding or fixing lint suggestions good-first-issue These issues are a good way to get started with Clippy C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages labels Mar 9, 2020
rabisg0 added a commit to rabisg0/rust-clippy that referenced this issue Mar 16, 2020
Changes the span on which the lint is reported to point to only the
function return type instead of the entire function body.
Fixes rust-lang#5284
bors added a commit that referenced this issue Mar 20, 2020
Improvement: Don't show function body in needless_lifetimes

Changes the span on which the lint is reported to point to only the
function return type instead of the entire function body.
Fixes #5284

changelog: none
@bors bors closed this as completed in 0812a0a Mar 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages good-first-issue These issues are a good way to get started with Clippy L-suggestion Lint: Improving, adding or fixing lint suggestions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants