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

Incorrect suggestions for significant_drop_in_scrutinee #13986

Open
samueltardieu opened this issue Jan 11, 2025 · 0 comments
Open

Incorrect suggestions for significant_drop_in_scrutinee #13986

samueltardieu opened this issue Jan 11, 2025 · 0 comments
Labels
C-bug Category: Clippy is not doing the correct thing I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied

Comments

@samueltardieu
Copy link
Contributor

Summary

The significant_drop_in_scrutinee lint gives suggestions that are only applicable when the expression being linted is a statement, not part as a larger expression.

Reproducer

I tried this code:

#![warn(clippy::significant_drop_in_scrutinee)]

#[clippy::has_significant_drop]
struct S;

fn main() {
    #[allow(clippy::match_single_binding)]
    let _ = match (S, S) {
        (S, S) => 0,
    };
}

I expected to see this happen:

A suggestion saying to use:

   let value = (S, S);
   let _ = match value {}

Instead, this happened:

1  | #![warn(clippy::significant_drop_in_scrutinee)]
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: try moving the temporary above the match
   |
8  ~     let _ = let value = (S, S);
9  ~     match value {

Version

rustc 1.86.0-nightly (b1a7dfb91 2025-01-10)
binary: rustc
commit-hash: b1a7dfb91106018f47ed9dc9b27aee1977682868
commit-date: 2025-01-10
host: x86_64-unknown-linux-gnu
release: 1.86.0-nightly
LLVM version: 19.1.6

Additional Labels

@rustbot label +I-suggestion-causes-error

@samueltardieu samueltardieu added the C-bug Category: Clippy is not doing the correct thing label Jan 11, 2025
@rustbot rustbot added the I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied label Jan 11, 2025
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-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied
Projects
None yet
Development

No branches or pull requests

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy