Skip to content

False positive in collapsible_span_lint_calls internal lint #7698

Closed
@Qwaz

Description

@Qwaz

Lint name: collapsible_span_lint_calls

I tried this code:

span_lint_and_then(
    cx,
    UNINIT_VEC,
    vec![call_span, maybe_with_capacity_or_reserve.span],
    "calling `set_len()` immediately after reserving a buffer creates uninitialized values",
    |diag| {
        diag.help("initialize the buffer or wrap the content in `MaybeUninit`");
    },
);

Clippy suggests to collapse this into span_lint_and_help(). However, this is not possible because span_lint_and_then() takes S: Into<MultiSpan> while span_lint_and_help() only takes Span.

The issue can be easily fixed by either
(1) checking the type of the span and suppress the lint if it is not Span
(2) modifying the signature of span_lint_and_help() to accept Into<MultiSpan>

Meta

Rust version (rustc -Vv):

rustc 1.57.0-nightly (fdf65053e 2021-09-07)
binary: rustc
commit-hash: fdf65053e99e8966f9bd83b5a8491326cb33d638
commit-date: 2021-09-07
host: x86_64-unknown-linux-gnu
release: 1.57.0-nightly
LLVM version: 13.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't have

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions