Skip to content

needless_lifetimes: don't show function body? #5284

Closed
@matthiaskrgr

Description

@matthiaskrgr

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesL-suggestionLint: Improving, adding or fixing lint suggestionsgood first issueThese issues are a good way to get started with Clippy

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions