Skip to content

False positive in collapsible_span_lint_calls internal lint #7698

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

Closed
Qwaz opened this issue Sep 21, 2021 · 1 comment
Closed

False positive in collapsible_span_lint_calls internal lint #7698

Qwaz opened this issue Sep 21, 2021 · 1 comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have

Comments

@Qwaz
Copy link
Contributor

Qwaz commented Sep 21, 2021

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
@Qwaz Qwaz added C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have labels Sep 21, 2021
Qwaz added a commit to Qwaz/rust-clippy that referenced this issue Sep 21, 2021
Qwaz added a commit to Qwaz/rust-clippy that referenced this issue Oct 3, 2021
Qwaz added a commit to Qwaz/rust-clippy that referenced this issue Oct 9, 2021
@y21
Copy link
Member

y21 commented Oct 22, 2024

span_lint_and_help (and all other functions) now take impl Into<MultiSpan>, so this should no longer be an issue.

@y21 y21 closed this as completed Oct 22, 2024
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 I-false-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
Development

No branches or pull requests

2 participants