rust/clippy_utils
ceptontech 622a77d288 feat(search_is_some): Fix when the closure spans multiple lines
Previously the program only fixed the code when the closure supplied to
the method contained only 1 line.  This patch removes the restriction.

The code already works.  This patch only removes the extra check that
causes the restriction.  The test cases that can now be fixed are moved
into the files containing tests cases that can be fixed.

The unnecessary check has survived in the code this way.

- In Dec 2015, patch a6bd2d0622, pull request 524.  The lint was first
  added.  The program did not support fixing code automatically yet.  So
  the suggested fix was printed as a part of the diagnostic message.
  When the original code contained multiple lines, the suggested fix was
  omitted in order to keep the diagnostic message concise.

- In May 2019, patch bd0b75f6c3, pull request 4049.  Logic was added
  to strip the reference in the closure when the suggested replacement
  method required it.  Because the fix was still only printed when the
  code contained a single line, the new transformation was only done
  when the code contained a single line.

- In Aug 2019, patch 945d4cf69f, pull request 4454.  The lint was
  updated to fix code automatically.  Because the fixed code had only
  been printed in the diagnostic message for a single line, the fix was
  only added for a single line.

- In Nov 2021, patch 092fe209a6, pull request 7463.  The logic for
  transforming the closure was moved into another file.  A comment was
  added saying that it was only good for a single line because it had
  only been used for a single line.

changelog: [`search_is_some`] now fixes code spanning multiple lines
2025-10-24 14:33:47 -07:00
..
src feat(search_is_some): Fix when the closure spans multiple lines 2025-10-24 14:33:47 -07:00
Cargo.toml Merge commit '20ce69b9a6' into clippy-subtree-update 2025-09-18 17:21:44 +02:00
README.md Bump nightly version -> 2025-10-16 2025-10-16 15:57:16 +02:00

clippy-utils

Helpful tools for writing lints, provided as they are used in Clippy.

Usage

This crate is only guaranteed to build with this nightly toolchain:

nightly-2025-10-16

To use clippy-utils in your lint, add the following to your Cargo.toml:

clippy_utils = "0.1.XY"

XY is the version of the nightly toolchain above and can be determined with rustc +nightly-YYYY-MM-DD -V.

⚠️ Stability ⚠️

No stability guarantees are made for this crate! Use at your own risk.

Function signatures can change or be removed without replacement without any prior notice.

LICENSE

Copyright 2014-2025 The Rust Project Developers

Licensed under the Apache License, Version 2.0 <https://www.apache.org/licenses/LICENSE-2.0> or the MIT license <https://opensource.org/licenses/MIT>, at your option. Files in the project may not be copied, modified, or distributed except according to those terms.