]> git.lizzy.rs Git - rust.git/commitdiff
Merge commit 'a98e7ab8b94485be6bd03e0c6b8682ecab5b52e6' into clippyup
authorflip1995 <philipp.krones@embecosm.com>
Thu, 27 Jan 2022 14:12:45 +0000 (15:12 +0100)
committerflip1995 <philipp.krones@embecosm.com>
Thu, 27 Jan 2022 14:12:45 +0000 (15:12 +0100)
99 files changed:
1  2 
src/tools/clippy/CHANGELOG.md
src/tools/clippy/clippy_dev/src/bless.rs
src/tools/clippy/clippy_dev/src/lint.rs
src/tools/clippy/clippy_lints/src/borrow_as_ptr.rs
src/tools/clippy/clippy_lints/src/casts/unnecessary_cast.rs
src/tools/clippy/clippy_lints/src/dereference.rs
src/tools/clippy/clippy_lints/src/enum_variants.rs
src/tools/clippy/clippy_lints/src/eq_op.rs
src/tools/clippy/clippy_lints/src/implicit_hasher.rs
src/tools/clippy/clippy_lints/src/lib.register_all.rs
src/tools/clippy/clippy_lints/src/lib.register_complexity.rs
src/tools/clippy/clippy_lints/src/lib.register_lints.rs
src/tools/clippy/clippy_lints/src/lib.rs
src/tools/clippy/clippy_lints/src/lifetimes.rs
src/tools/clippy/clippy_lints/src/manual_async_fn.rs
src/tools/clippy/clippy_lints/src/manual_bits.rs
src/tools/clippy/clippy_lints/src/map_clone.rs
src/tools/clippy/clippy_lints/src/matches.rs
src/tools/clippy/clippy_lints/src/methods/expect_fun_call.rs
src/tools/clippy/clippy_lints/src/methods/mod.rs
src/tools/clippy/clippy_lints/src/needless_question_mark.rs
src/tools/clippy/clippy_lints/src/octal_escapes.rs
src/tools/clippy/clippy_lints/src/ptr.rs
src/tools/clippy/clippy_lints/src/reference.rs
src/tools/clippy/clippy_lints/src/trait_bounds.rs
src/tools/clippy/clippy_lints/src/unit_return_expecting_ord.rs
src/tools/clippy/clippy_lints/src/unnested_or_patterns.rs
src/tools/clippy/clippy_lints/src/utils/conf.rs
src/tools/clippy/clippy_lints/src/utils/internal_lints.rs
src/tools/clippy/clippy_lints/src/utils/internal_lints/metadata_collector.rs
src/tools/clippy/clippy_utils/src/ast_utils.rs
src/tools/clippy/clippy_utils/src/lib.rs
src/tools/clippy/clippy_utils/src/numeric_literal.rs
src/tools/clippy/clippy_utils/src/sugg.rs
src/tools/clippy/clippy_utils/src/ty.rs
src/tools/clippy/rust-toolchain
src/tools/clippy/src/driver.rs
src/tools/clippy/tests/compile-test.rs
src/tools/clippy/tests/ui-toml/min_rust_version/min_rust_version.rs
src/tools/clippy/tests/ui-toml/min_rust_version/min_rust_version.stderr
src/tools/clippy/tests/ui/borrow_interior_mutable_const/others.rs
src/tools/clippy/tests/ui/borrow_interior_mutable_const/others.stderr
src/tools/clippy/tests/ui/bytecount.rs
src/tools/clippy/tests/ui/bytecount.stderr
src/tools/clippy/tests/ui/clone_on_copy.fixed
src/tools/clippy/tests/ui/clone_on_copy.rs
src/tools/clippy/tests/ui/clone_on_copy.stderr
src/tools/clippy/tests/ui/duration_subsec.fixed
src/tools/clippy/tests/ui/duration_subsec.rs
src/tools/clippy/tests/ui/enum_variants.rs
src/tools/clippy/tests/ui/eta.fixed
src/tools/clippy/tests/ui/eta.rs
src/tools/clippy/tests/ui/eta.stderr
src/tools/clippy/tests/ui/explicit_deref_methods.fixed
src/tools/clippy/tests/ui/explicit_deref_methods.rs
src/tools/clippy/tests/ui/for_loop_fixable.fixed
src/tools/clippy/tests/ui/for_loop_fixable.rs
src/tools/clippy/tests/ui/for_loop_fixable.stderr
src/tools/clippy/tests/ui/format.fixed
src/tools/clippy/tests/ui/format.rs
src/tools/clippy/tests/ui/format.stderr
src/tools/clippy/tests/ui/needless_borrow.fixed
src/tools/clippy/tests/ui/needless_borrow.rs
src/tools/clippy/tests/ui/needless_borrow.stderr
src/tools/clippy/tests/ui/needless_lifetimes.rs
src/tools/clippy/tests/ui/needless_lifetimes.stderr
src/tools/clippy/tests/ui/needless_question_mark.fixed
src/tools/clippy/tests/ui/needless_question_mark.rs
src/tools/clippy/tests/ui/needless_question_mark.stderr
src/tools/clippy/tests/ui/op_ref.rs
src/tools/clippy/tests/ui/op_ref.stderr
src/tools/clippy/tests/ui/ptr_arg.rs
src/tools/clippy/tests/ui/ptr_arg.stderr
src/tools/clippy/tests/ui/redundant_pattern_matching_option.fixed
src/tools/clippy/tests/ui/redundant_pattern_matching_option.rs
src/tools/clippy/tests/ui/rename.fixed
src/tools/clippy/tests/ui/rename.rs
src/tools/clippy/tests/ui/rename.stderr
src/tools/clippy/tests/ui/search_is_some_fixable_none.rs
src/tools/clippy/tests/ui/search_is_some_fixable_none.stderr
src/tools/clippy/tests/ui/search_is_some_fixable_some.rs
src/tools/clippy/tests/ui/search_is_some_fixable_some.stderr
src/tools/clippy/tests/ui/slow_vector_initialization.rs
src/tools/clippy/tests/ui/trait_duplication_in_bounds.rs
src/tools/clippy/tests/ui/trait_duplication_in_bounds.stderr
src/tools/clippy/tests/ui/unnecessary_cast.rs
src/tools/clippy/tests/ui/unnecessary_cast.stderr
src/tools/clippy/tests/ui/useless_asref.fixed
src/tools/clippy/tests/ui/useless_asref.rs
src/tools/clippy/tests/ui/write_literal.rs
src/tools/clippy/tests/ui/write_literal.stderr
src/tools/clippy/tests/ui/write_literal_2.rs
src/tools/clippy/tests/ui/write_literal_2.stderr
src/tools/clippy/tests/ui/write_with_newline.rs
src/tools/clippy/tests/ui/write_with_newline.stderr
src/tools/clippy/tests/ui/writeln_empty_string.fixed
src/tools/clippy/tests/ui/writeln_empty_string.rs
src/tools/clippy/tests/ui/writeln_empty_string.stderr
src/tools/clippy/util/gh-pages/index.html

index 258a8256f53177752b46ed1914cd5a1789e639aa,0000000000000000000000000000000000000000..d66e6cf7fb6596ad20f5cfb1bf9dfba0e409d624
mode 100644,000000..100644
--- /dev/null
@@@ -1,3391 -1,0 +1,3390 @@@
- * [`ref_in_deref`] Use parentheses correctly in suggestion
 +# Changelog
 +
 +All notable changes to this project will be documented in this file.
 +See [Changelog Update](doc/changelog_update.md) if you want to update this
 +document.
 +
 +## Unreleased / In Rust Nightly
 +
 +[e181011...master](https://github.com/rust-lang/rust-clippy/compare/e181011...master)
 +
 +## Rust 1.58 (beta)
 +
 +Current beta, release 2022-01-13
 +
 +[00e31fa...e181011](https://github.com/rust-lang/rust-clippy/compare/00e31fa...e181011)
 +
 +### New lints
 +
 +* [`transmute_num_to_bytes`]
 +  [#7805](https://github.com/rust-lang/rust-clippy/pull/7805)
 +* [`match_str_case_mismatch`]
 +  [#7806](https://github.com/rust-lang/rust-clippy/pull/7806)
 +* [`format_in_format_args`], [`to_string_in_format_args`]
 +  [#7743](https://github.com/rust-lang/rust-clippy/pull/7743)
 +* [`uninit_vec`]
 +  [#7682](https://github.com/rust-lang/rust-clippy/pull/7682)
 +* [`fn_to_numeric_cast_any`]
 +  [#7705](https://github.com/rust-lang/rust-clippy/pull/7705)
 +* [`undocumented_unsafe_blocks`]
 +  [#7748](https://github.com/rust-lang/rust-clippy/pull/7748)
 +* [`trailing_empty_array`]
 +  [#7838](https://github.com/rust-lang/rust-clippy/pull/7838)
 +* [`string_slice`]
 +  [#7878](https://github.com/rust-lang/rust-clippy/pull/7878)
 +
 +### Moves or deprecations of lints
 +
 +* Move [`non_send_fields_in_send_ty`] to `suspicious`
 +  [#7874](https://github.com/rust-lang/rust-clippy/pull/7874)
 +* Move [`non_ascii_literal`] to `restriction`
 +  [#7907](https://github.com/rust-lang/rust-clippy/pull/7907)
 +
 +### Changes that expand what code existing lints cover
 +
 +* [`question_mark`] now covers `Result`
 +  [#7840](https://github.com/rust-lang/rust-clippy/pull/7840)
 +* Make [`useless_format`] recognize bare `format!("")`
 +  [#7801](https://github.com/rust-lang/rust-clippy/pull/7801)
 +* Lint on underscored variables with no side effects in [`no_effect`]
 +  [#7775](https://github.com/rust-lang/rust-clippy/pull/7775)
 +* Expand [`match_ref_pats`] to check for multiple reference patterns
 +  [#7800](https://github.com/rust-lang/rust-clippy/pull/7800)
 +
 +### False positive fixes
 +
 +* Fix false positive of [`implicit_saturating_sub`] with `else` clause
 +  [#7832](https://github.com/rust-lang/rust-clippy/pull/7832)
 +* Fix [`question_mark`] when there is call in conditional predicate
 +  [#7860](https://github.com/rust-lang/rust-clippy/pull/7860)
 +* [`mut_mut`] no longer lints when type is defined in external macros
 +  [#7795](https://github.com/rust-lang/rust-clippy/pull/7795)
 +* Avoid [`eq_op`] in test functions
 +  [#7811](https://github.com/rust-lang/rust-clippy/pull/7811)
 +* [`cast_possible_truncation`] no longer lints when cast is coming from `signum`
 +  method call [#7850](https://github.com/rust-lang/rust-clippy/pull/7850)
 +* [`match_str_case_mismatch`] no longer lints on uncased characters
 +  [#7865](https://github.com/rust-lang/rust-clippy/pull/7865)
 +* [`ptr_arg`] no longer lints references to type aliases
 +  [#7890](https://github.com/rust-lang/rust-clippy/pull/7890)
 +* [`missing_safety_doc`] now also accepts "implementation safety" headers
 +  [#7856](https://github.com/rust-lang/rust-clippy/pull/7856)
 +* [`missing_safety_doc`] no longer lints if any parent has `#[doc(hidden)]`
 +  attribute [#7849](https://github.com/rust-lang/rust-clippy/pull/7849)
 +* [`if_not_else`] now ignores else-if statements
 +  [#7895](https://github.com/rust-lang/rust-clippy/pull/7895)
 +* Avoid linting [`cast_possible_truncation`] on bit-reducing operations
 +  [#7819](https://github.com/rust-lang/rust-clippy/pull/7819)
 +* Avoid linting [`field_reassign_with_default`] when `Drop` and `Copy` are
 +  involved [#7794](https://github.com/rust-lang/rust-clippy/pull/7794)
 +* [`unnecessary_sort_by`] now checks if argument implements `Ord` trait
 +  [#7824](https://github.com/rust-lang/rust-clippy/pull/7824)
 +* Fix false positive in [`match_overlapping_arm`]
 +  [#7847](https://github.com/rust-lang/rust-clippy/pull/7847)
 +* Prevent [`needless_lifetimes`] false positive in `async` function definition
 +  [#7901](https://github.com/rust-lang/rust-clippy/pull/7901)
 +
 +### Suggestion fixes/improvements
 +
 +* Keep an initial `::` when [`doc_markdown`] suggests to use ticks
 +  [#7916](https://github.com/rust-lang/rust-clippy/pull/7916)
 +* Add a machine applicable suggestion for the [`doc_markdown`] missing backticks
 +  lint [#7904](https://github.com/rust-lang/rust-clippy/pull/7904)
 +* [`equatable_if_let`] no longer expands macros in the suggestion
 +  [#7788](https://github.com/rust-lang/rust-clippy/pull/7788)
 +* Make [`shadow_reuse`] suggestion less verbose
 +  [#7782](https://github.com/rust-lang/rust-clippy/pull/7782)
 +
 +### ICE fixes
 +
 +* Fix ICE in [`enum_variant_names`]
 +  [#7873](https://github.com/rust-lang/rust-clippy/pull/7873)
 +* Fix ICE in [`undocumented_unsafe_blocks`]
 +  [#7891](https://github.com/rust-lang/rust-clippy/pull/7891)
 +
 +### Documentation improvements
 +
 +* Fixed naive doc formatting for `#[must_use]` lints ([`must_use_unit`],
 +  [`double_must_use`], [`must_use_candidate`], [`let_underscore_must_use`])
 +  [#7827](https://github.com/rust-lang/rust-clippy/pull/7827)
 +* Fix typo in example for [`match_result_ok`]
 +  [#7815](https://github.com/rust-lang/rust-clippy/pull/7815)
 +
 +### Others
 +
 +* Allow giving reasons for [`disallowed_types`]
 +  [#7791](https://github.com/rust-lang/rust-clippy/pull/7791)
 +* Fix [`manual_assert`] and [`match_wild_err_arm`] for `#![no_std]` and Rust
 +  2021. [#7851](https://github.com/rust-lang/rust-clippy/pull/7851)
 +* Fix regression in [`semicolon_if_nothing_returned`] on macros containing while
 +  loops [#7789](https://github.com/rust-lang/rust-clippy/pull/7789)
 +* Added a new configuration `literal-suffix-style` to enforce a certain style
 +  writing [`unseparated_literal_suffix`]
 +  [#7726](https://github.com/rust-lang/rust-clippy/pull/7726)
 +
 +## Rust 1.57
 +
 +Current stable, released 2021-12-02
 +
 +[7bfc26e...00e31fa](https://github.com/rust-lang/rust-clippy/compare/7bfc26e...00e31fa)
 +
 +### New Lints
 +
 +* [`negative_feature_names`]
 +  [#7539](https://github.com/rust-lang/rust-clippy/pull/7539)
 +* [`redundant_feature_names`]
 +  [#7539](https://github.com/rust-lang/rust-clippy/pull/7539)
 +* [`mod_module_files`]
 +  [#7543](https://github.com/rust-lang/rust-clippy/pull/7543)
 +* [`self_named_module_files`]
 +  [#7543](https://github.com/rust-lang/rust-clippy/pull/7543)
 +* [`manual_split_once`]
 +  [#7565](https://github.com/rust-lang/rust-clippy/pull/7565)
 +* [`derivable_impls`]
 +  [#7570](https://github.com/rust-lang/rust-clippy/pull/7570)
 +* [`needless_option_as_deref`]
 +  [#7596](https://github.com/rust-lang/rust-clippy/pull/7596)
 +* [`iter_not_returning_iterator`]
 +  [#7610](https://github.com/rust-lang/rust-clippy/pull/7610)
 +* [`same_name_method`]
 +  [#7653](https://github.com/rust-lang/rust-clippy/pull/7653)
 +* [`manual_assert`] [#7669](https://github.com/rust-lang/rust-clippy/pull/7669)
 +* [`non_send_fields_in_send_ty`]
 +  [#7709](https://github.com/rust-lang/rust-clippy/pull/7709)
 +* [`equatable_if_let`]
 +  [#7762](https://github.com/rust-lang/rust-clippy/pull/7762)
 +
 +### Moves and Deprecations
 +
 +* Move [`shadow_unrelated`] to `restriction`
 +  [#7338](https://github.com/rust-lang/rust-clippy/pull/7338)
 +* Move [`option_if_let_else`] to `nursery`
 +  [#7568](https://github.com/rust-lang/rust-clippy/pull/7568)
 +* Move [`branches_sharing_code`] to `nursery`
 +  [#7595](https://github.com/rust-lang/rust-clippy/pull/7595)
 +* Rename `if_let_some_result` to [`match_result_ok`] which now also handles
 +  `while let` cases [#7608](https://github.com/rust-lang/rust-clippy/pull/7608)
 +* Move [`many_single_char_names`] to `pedantic`
 +  [#7671](https://github.com/rust-lang/rust-clippy/pull/7671)
 +* Move [`float_cmp`] to `pedantic`
 +  [#7692](https://github.com/rust-lang/rust-clippy/pull/7692)
 +* Rename `box_vec` to [`box_collection`] and lint on more general cases
 +  [#7693](https://github.com/rust-lang/rust-clippy/pull/7693)
 +* Uplift `invalid_atomic_ordering` to rustc
 +  [rust-lang/rust#84039](https://github.com/rust-lang/rust/pull/84039)
 +
 +### Enhancements
 +
 +* Rewrite the `shadow*` lints, so that they find a lot more shadows and are not
 +  limited to certain patterns
 +  [#7338](https://github.com/rust-lang/rust-clippy/pull/7338)
 +* The `avoid-breaking-exported-api` configuration now also works for
 +  [`box_collection`], [`redundant_allocation`], [`rc_buffer`], [`vec_box`],
 +  [`option_option`], [`linkedlist`], [`rc_mutex`]
 +  [#7560](https://github.com/rust-lang/rust-clippy/pull/7560)
 +* [`unnecessary_unwrap`]: Now also checks for `expect`s
 +  [#7584](https://github.com/rust-lang/rust-clippy/pull/7584)
 +* [`disallowed_methods`]: Allow adding a reason that will be displayed with the
 +  lint message
 +  [#7621](https://github.com/rust-lang/rust-clippy/pull/7621)
 +* [`approx_constant`]: Now checks the MSRV for `LOG10_2` and `LOG2_10`
 +  [#7629](https://github.com/rust-lang/rust-clippy/pull/7629)
 +* [`approx_constant`]: Add `TAU`
 +  [#7642](https://github.com/rust-lang/rust-clippy/pull/7642)
 +* [`needless_borrow`]: Now also lints on needless mutable borrows
 +  [#7657](https://github.com/rust-lang/rust-clippy/pull/7657)
 +* [`missing_safety_doc`]: Now also lints on unsafe traits
 +  [#7734](https://github.com/rust-lang/rust-clippy/pull/7734)
 +
 +### False Positive Fixes
 +
 +* [`manual_map`]: No longer lints when the option is borrowed in the match and
 +  also consumed in the arm
 +  [#7531](https://github.com/rust-lang/rust-clippy/pull/7531)
 +* [`filter_next`]: No longer lints if `filter` method is not the
 +  `Iterator::filter` method
 +  [#7562](https://github.com/rust-lang/rust-clippy/pull/7562)
 +* [`manual_flatten`]: No longer lints if expression is used after `if let`
 +  [#7566](https://github.com/rust-lang/rust-clippy/pull/7566)
 +* [`option_if_let_else`]: Multiple fixes
 +  [#7573](https://github.com/rust-lang/rust-clippy/pull/7573)
 +    * `break` and `continue` statements local to the would-be closure are
 +      allowed
 +    * Don't lint in const contexts
 +    * Don't lint when yield expressions are used
 +    * Don't lint when the captures made by the would-be closure conflict with
 +      the other branch
 +    * Don't lint when a field of a local is used when the type could be
 +      potentially moved from
 +    * In some cases, don't lint when scrutinee expression conflicts with the
 +      captures of the would-be closure
 +* [`redundant_allocation`]: No longer lints on `Box<Box<dyn T>>` which replaces
 +  wide pointers with thin pointers
 +  [#7592](https://github.com/rust-lang/rust-clippy/pull/7592)
 +* [`bool_assert_comparison`]: No longer lints on types that do not implement the
 +  `Not` trait with `Output = bool`
 +  [#7605](https://github.com/rust-lang/rust-clippy/pull/7605)
 +* [`mut_range_bound`]: No longer lints on range bound mutations, that are
 +  immediately followed by a `break;`
 +  [#7607](https://github.com/rust-lang/rust-clippy/pull/7607)
 +* [`mutable_key_type`]: Improve accuracy and document remaining false positives
 +  and false negatives
 +  [#7640](https://github.com/rust-lang/rust-clippy/pull/7640)
 +* [`redundant_closure`]: Rewrite the lint to fix various false positives and
 +  false negatives [#7661](https://github.com/rust-lang/rust-clippy/pull/7661)
 +* [`large_enum_variant`]: No longer wrongly identifies the second largest
 +  variant [#7677](https://github.com/rust-lang/rust-clippy/pull/7677)
 +* [`needless_return`]: No longer lints on let-else expressions
 +  [#7685](https://github.com/rust-lang/rust-clippy/pull/7685)
 +* [`suspicious_else_formatting`]: No longer lints in proc-macros
 +  [#7707](https://github.com/rust-lang/rust-clippy/pull/7707)
 +* [`excessive_precision`]: No longer lints when in some cases the float was
 +  already written in the shortest form
 +  [#7722](https://github.com/rust-lang/rust-clippy/pull/7722)
 +* [`doc_markdown`]: No longer lints on intra-doc links
 +  [#7772](https://github.com/rust-lang/rust-clippy/pull/7772)
 +
 +### Suggestion Fixes/Improvements
 +
 +* [`unnecessary_operation`]: Recommend using an `assert!` instead of using a
 +  function call in an indexing operation
 +  [#7453](https://github.com/rust-lang/rust-clippy/pull/7453)
 +* [`manual_split_once`]: Produce semantically equivalent suggestion when
 +  `rsplitn` is used [#7663](https://github.com/rust-lang/rust-clippy/pull/7663)
 +* [`while_let_on_iterator`]: Produce correct suggestion when using `&mut`
 +  [#7690](https://github.com/rust-lang/rust-clippy/pull/7690)
 +* [`manual_assert`]: No better handles complex conditions
 +  [#7741](https://github.com/rust-lang/rust-clippy/pull/7741)
 +* Correctly handle signs in exponents in numeric literals lints
 +  [#7747](https://github.com/rust-lang/rust-clippy/pull/7747)
 +* [`suspicious_map`]: Now also suggests to use `inspect` as an alternative
 +  [#7770](https://github.com/rust-lang/rust-clippy/pull/7770)
 +* Drop exponent from suggestion if it is 0 in numeric literals lints
 +  [#7774](https://github.com/rust-lang/rust-clippy/pull/7774)
 +
 +### ICE Fixes
 +
 +* [`implicit_hasher`]
 +  [#7761](https://github.com/rust-lang/rust-clippy/pull/7761)
 +
 +### Others
 +
 +* Clippy now uses the 2021
 +  [Edition!](https://www.youtube.com/watch?v=q0aNduqb2Ro)
 +  [#7664](https://github.com/rust-lang/rust-clippy/pull/7664)
 +
 +## Rust 1.56
 +
 +Released 2021-10-21
 +
 +[74d1561...7bfc26e](https://github.com/rust-lang/rust-clippy/compare/74d1561...7bfc26e)
 +
 +### New Lints
 +
 +* [`unwrap_or_else_default`]
 +  [#7516](https://github.com/rust-lang/rust-clippy/pull/7516)
 +
 +### Enhancements
 +
 +* [`needless_continue`]: Now also lints in `loop { continue; }` case
 +  [#7477](https://github.com/rust-lang/rust-clippy/pull/7477)
 +* [`disallowed_types`]: Now also primitive types can be disallowed
 +  [#7488](https://github.com/rust-lang/rust-clippy/pull/7488)
 +* [`manual_swap`]: Now also lints on xor swaps
 +  [#7506](https://github.com/rust-lang/rust-clippy/pull/7506)
 +* [`map_flatten`]: Now also lints on the `Result` type
 +  [#7522](https://github.com/rust-lang/rust-clippy/pull/7522)
 +* [`no_effect`]: Now also lints on inclusive ranges
 +  [#7556](https://github.com/rust-lang/rust-clippy/pull/7556)
 +
 +### False Positive Fixes
 +
 +* [`nonstandard_macro_braces`]: No longer lints on similar named nested macros
 +  [#7478](https://github.com/rust-lang/rust-clippy/pull/7478)
 +* [`too_many_lines`]: No longer lints in closures to avoid duplicated diagnostics
 +  [#7534](https://github.com/rust-lang/rust-clippy/pull/7534)
 +* [`similar_names`]: No longer complains about `iter` and `item` being too
 +  similar [#7546](https://github.com/rust-lang/rust-clippy/pull/7546)
 +
 +### Suggestion Fixes/Improvements
 +
 +* [`similar_names`]: No longer suggests to insert or add an underscore as a fix
 +  [#7221](https://github.com/rust-lang/rust-clippy/pull/7221)
 +* [`new_without_default`]: No longer shows the full qualified type path when
 +  suggesting adding a `Default` implementation
 +  [#7493](https://github.com/rust-lang/rust-clippy/pull/7493)
 +* [`while_let_on_iterator`]: Now suggests re-borrowing mutable references
 +  [#7520](https://github.com/rust-lang/rust-clippy/pull/7520)
 +* [`extend_with_drain`]: Improve code suggestion for mutable and immutable
 +  references [#7533](https://github.com/rust-lang/rust-clippy/pull/7533)
 +* [`trivially_copy_pass_by_ref`]: Now properly handles `Self` type
 +  [#7535](https://github.com/rust-lang/rust-clippy/pull/7535)
 +* [`never_loop`]: Now suggests using `if let` instead of a `for` loop when
 +  applicable [#7541](https://github.com/rust-lang/rust-clippy/pull/7541)
 +
 +### Documentation Improvements
 +
 +* Clippy now uses a lint to generate its lint documentation. [Lints all the way
 +  down](https://en.wikipedia.org/wiki/Turtles_all_the_way_down).
 +  [#7502](https://github.com/rust-lang/rust-clippy/pull/7502)
 +* Reworked Clippy's website:
 +  [#7172](https://github.com/rust-lang/rust-clippy/issues/7172)
 +  [#7279](https://github.com/rust-lang/rust-clippy/pull/7279)
 +  * Added applicability information about lints
 +  * Added a link to jump into the implementation
 +  * Improved loading times
 +  * Adapted some styling
 +* `cargo clippy --help` now also explains the `--fix` and `--no-deps` flag
 +  [#7492](https://github.com/rust-lang/rust-clippy/pull/7492)
 +* [`unnested_or_patterns`]: Removed `or_patterns` feature gate in the code
 +  example [#7507](https://github.com/rust-lang/rust-clippy/pull/7507)
 +
 +## Rust 1.55
 +
 +Released 2021-09-09
 +
 +[3ae8faf...74d1561](https://github.com/rust-lang/rust-clippy/compare/3ae8faf...74d1561)
 +
 +### Important Changes
 +
 +* Stabilized `cargo clippy --fix` :tada:
 +  [#7405](https://github.com/rust-lang/rust-clippy/pull/7405)
 +
 +### New Lints
 +
 +* [`rc_mutex`]
 +  [#7316](https://github.com/rust-lang/rust-clippy/pull/7316)
 +* [`nonstandard_macro_braces`]
 +  [#7299](https://github.com/rust-lang/rust-clippy/pull/7299)
 +* [`strlen_on_c_strings`]
 +  [#7243](https://github.com/rust-lang/rust-clippy/pull/7243)
 +* [`self_named_constructors`]
 +  [#7403](https://github.com/rust-lang/rust-clippy/pull/7403)
 +* [`disallowed_script_idents`]
 +  [#7400](https://github.com/rust-lang/rust-clippy/pull/7400)
 +* [`disallowed_types`]
 +  [#7315](https://github.com/rust-lang/rust-clippy/pull/7315)
 +* [`missing_enforced_import_renames`]
 +  [#7300](https://github.com/rust-lang/rust-clippy/pull/7300)
 +* [`extend_with_drain`]
 +  [#7270](https://github.com/rust-lang/rust-clippy/pull/7270)
 +
 +### Moves and Deprecations
 +
 +* Moved [`from_iter_instead_of_collect`] to `pedantic`
 +  [#7375](https://github.com/rust-lang/rust-clippy/pull/7375)
 +* Added `suspicious` as a new lint group for *code that is most likely wrong or useless*
 +  [#7350](https://github.com/rust-lang/rust-clippy/pull/7350)
 +  * Moved [`blanket_clippy_restriction_lints`] to `suspicious`
 +  * Moved [`empty_loop`] to `suspicious`
 +  * Moved [`eval_order_dependence`] to `suspicious`
 +  * Moved [`float_equality_without_abs`] to `suspicious`
 +  * Moved [`for_loops_over_fallibles`] to `suspicious`
 +  * Moved [`misrefactored_assign_op`] to `suspicious`
 +  * Moved [`mut_range_bound`] to `suspicious`
 +  * Moved [`mutable_key_type`] to `suspicious`
 +  * Moved [`suspicious_arithmetic_impl`] to `suspicious`
 +  * Moved [`suspicious_assignment_formatting`] to `suspicious`
 +  * Moved [`suspicious_else_formatting`] to `suspicious`
 +  * Moved [`suspicious_map`] to `suspicious`
 +  * Moved [`suspicious_op_assign_impl`] to `suspicious`
 +  * Moved [`suspicious_unary_op_formatting`] to `suspicious`
 +
 +### Enhancements
 +
 +* [`while_let_on_iterator`]: Now suggests `&mut iter` inside closures
 +  [#7262](https://github.com/rust-lang/rust-clippy/pull/7262)
 +* [`doc_markdown`]:
 +  * Now detects unbalanced ticks
 +    [#7357](https://github.com/rust-lang/rust-clippy/pull/7357)
 +  * Add `FreeBSD` to the default configuration as an allowed identifier
 +    [#7334](https://github.com/rust-lang/rust-clippy/pull/7334)
 +* [`wildcard_enum_match_arm`], [`match_wildcard_for_single_variants`]: Now allows wildcards for enums with unstable
 +  or hidden variants
 +  [#7407](https://github.com/rust-lang/rust-clippy/pull/7407)
 +* [`redundant_allocation`]: Now additionally supports the `Arc<>` type
 +  [#7308](https://github.com/rust-lang/rust-clippy/pull/7308)
 +* [`blacklisted_name`]: Now allows blacklisted names in test code
 +  [#7379](https://github.com/rust-lang/rust-clippy/pull/7379)
 +* [`redundant_closure`]: Suggests `&mut` for `FnMut`
 +  [#7437](https://github.com/rust-lang/rust-clippy/pull/7437)
 +* [`disallowed_methods`], [`disallowed_types`]: The configuration values `disallowed-method` and `disallowed-type`
 +  no longer require fully qualified paths
 +  [#7345](https://github.com/rust-lang/rust-clippy/pull/7345)
 +* [`zst_offset`]: Fixed lint invocation after it was accidentally suppressed
 +  [#7396](https://github.com/rust-lang/rust-clippy/pull/7396)
 +
 +### False Positive Fixes
 +
 +* [`default_numeric_fallback`]: No longer lints on float literals as function arguments
 +  [#7446](https://github.com/rust-lang/rust-clippy/pull/7446)
 +* [`use_self`]: No longer lints on type parameters
 +  [#7288](https://github.com/rust-lang/rust-clippy/pull/7288)
 +* [`unimplemented`]: Now ignores the `assert` and `debug_assert` macros
 +  [#7439](https://github.com/rust-lang/rust-clippy/pull/7439)
 +* [`branches_sharing_code`]: Now always checks for block expressions
 +  [#7462](https://github.com/rust-lang/rust-clippy/pull/7462)
 +* [`field_reassign_with_default`]: No longer triggers in macros
 +  [#7160](https://github.com/rust-lang/rust-clippy/pull/7160)
 +* [`redundant_clone`]: No longer lints on required clones for borrowed data
 +  [#7346](https://github.com/rust-lang/rust-clippy/pull/7346)
 +* [`default_numeric_fallback`]: No longer triggers in external macros
 +  [#7325](https://github.com/rust-lang/rust-clippy/pull/7325)
 +* [`needless_bool`]: No longer lints in macros
 +  [#7442](https://github.com/rust-lang/rust-clippy/pull/7442)
 +* [`useless_format`]: No longer triggers when additional text is being appended
 +  [#7442](https://github.com/rust-lang/rust-clippy/pull/7442)
 +* [`assertions_on_constants`]: `cfg!(...)` is no longer considered to be a constant
 +  [#7319](https://github.com/rust-lang/rust-clippy/pull/7319)
 +
 +### Suggestion Fixes/Improvements
 +
 +* [`needless_collect`]: Now show correct lint messages for shadowed values
 +  [#7289](https://github.com/rust-lang/rust-clippy/pull/7289)
 +* [`wrong_pub_self_convention`]: The deprecated message now suggest the correct configuration value
 +  [#7382](https://github.com/rust-lang/rust-clippy/pull/7382)
 +* [`semicolon_if_nothing_returned`]: Allow missing semicolon in blocks with only one expression
 +  [#7326](https://github.com/rust-lang/rust-clippy/pull/7326)
 +
 +### ICE Fixes
 +
 +* [`zero_sized_map_values`]
 +  [#7470](https://github.com/rust-lang/rust-clippy/pull/7470)
 +* [`redundant_pattern_matching`]
 +  [#7471](https://github.com/rust-lang/rust-clippy/pull/7471)
 +* [`modulo_one`]
 +  [#7473](https://github.com/rust-lang/rust-clippy/pull/7473)
 +* [`use_self`]
 +  [#7428](https://github.com/rust-lang/rust-clippy/pull/7428)
 +
 +## Rust 1.54
 +
 +Released 2021-07-29
 +
 +[7c7683c...3ae8faf](https://github.com/rust-lang/rust-clippy/compare/7c7683c...3ae8faf)
 +
 +### New Lints
 +
 +- [`ref_binding_to_reference`]
 +  [#7105](https://github.com/rust-lang/rust-clippy/pull/7105)
 +- [`needless_bitwise_bool`]
 +  [#7133](https://github.com/rust-lang/rust-clippy/pull/7133)
 +- [`unused_async`] [#7225](https://github.com/rust-lang/rust-clippy/pull/7225)
 +- [`manual_str_repeat`]
 +  [#7265](https://github.com/rust-lang/rust-clippy/pull/7265)
 +- [`suspicious_splitn`]
 +  [#7292](https://github.com/rust-lang/rust-clippy/pull/7292)
 +
 +### Moves and Deprecations
 +
 +- Deprecate `pub_enum_variant_names` and `wrong_pub_self_convention` in favor of
 +  the new `avoid-breaking-exported-api` config option (see
 +  [Enhancements](#1-54-enhancements))
 +  [#7187](https://github.com/rust-lang/rust-clippy/pull/7187)
 +- Move [`inconsistent_struct_constructor`] to `pedantic`
 +  [#7193](https://github.com/rust-lang/rust-clippy/pull/7193)
 +- Move [`needless_borrow`] to `style` (now warn-by-default)
 +  [#7254](https://github.com/rust-lang/rust-clippy/pull/7254)
 +- Move [`suspicious_operation_groupings`] to `nursery`
 +  [#7266](https://github.com/rust-lang/rust-clippy/pull/7266)
 +- Move [`semicolon_if_nothing_returned`] to `pedantic`
 +  [#7268](https://github.com/rust-lang/rust-clippy/pull/7268)
 +
 +### Enhancements <a name="1-54-enhancements"></a>
 +
 +- [`while_let_on_iterator`]: Now also lints in nested loops
 +  [#6966](https://github.com/rust-lang/rust-clippy/pull/6966)
 +- [`single_char_pattern`]: Now also lints on `strip_prefix` and `strip_suffix`
 +  [#7156](https://github.com/rust-lang/rust-clippy/pull/7156)
 +- [`needless_collect`]: Now also lints on assignments with type annotations
 +  [#7163](https://github.com/rust-lang/rust-clippy/pull/7163)
 +- [`if_then_some_else_none`]: Now works with the MSRV config
 +  [#7177](https://github.com/rust-lang/rust-clippy/pull/7177)
 +- Add `avoid-breaking-exported-api` config option for the lints
 +  [`enum_variant_names`], [`large_types_passed_by_value`],
 +  [`trivially_copy_pass_by_ref`], [`unnecessary_wraps`],
 +  [`upper_case_acronyms`], and [`wrong_self_convention`]. We recommend to set
 +  this configuration option to `false` before a major release (1.0/2.0/...) to
 +  clean up the API [#7187](https://github.com/rust-lang/rust-clippy/pull/7187)
 +- [`needless_collect`]: Now lints on even more data structures
 +  [#7188](https://github.com/rust-lang/rust-clippy/pull/7188)
 +- [`missing_docs_in_private_items`]: No longer sees `#[<name> = "<value>"]` like
 +  attributes as sufficient documentation
 +  [#7281](https://github.com/rust-lang/rust-clippy/pull/7281)
 +- [`needless_collect`], [`short_circuit_statement`], [`unnecessary_operation`]:
 +  Now work as expected when used with `allow`
 +  [#7282](https://github.com/rust-lang/rust-clippy/pull/7282)
 +
 +### False Positive Fixes
 +
 +- [`implicit_return`]: Now takes all diverging functions in account to avoid
 +  false positives [#6951](https://github.com/rust-lang/rust-clippy/pull/6951)
 +- [`while_let_on_iterator`]: No longer lints when the iterator is a struct field
 +  and the struct is used in the loop
 +  [#6966](https://github.com/rust-lang/rust-clippy/pull/6966)
 +- [`multiple_inherent_impl`]: No longer lints with generic arguments
 +  [#7089](https://github.com/rust-lang/rust-clippy/pull/7089)
 +- [`comparison_chain`]: No longer lints in a `const` context
 +  [#7118](https://github.com/rust-lang/rust-clippy/pull/7118)
 +- [`while_immutable_condition`]: Fix false positive where mutation in the loop
 +  variable wasn't picked up
 +  [#7144](https://github.com/rust-lang/rust-clippy/pull/7144)
 +- [`default_trait_access`]: No longer lints in macros
 +  [#7150](https://github.com/rust-lang/rust-clippy/pull/7150)
 +- [`needless_question_mark`]: No longer lints when the inner value is implicitly
 +  dereferenced [#7165](https://github.com/rust-lang/rust-clippy/pull/7165)
 +- [`unused_unit`]: No longer lints when multiple macro contexts are involved
 +  [#7167](https://github.com/rust-lang/rust-clippy/pull/7167)
 +- [`eval_order_dependence`]: Fix false positive in async context
 +  [#7174](https://github.com/rust-lang/rust-clippy/pull/7174)
 +- [`unnecessary_filter_map`]: No longer lints if the `filter_map` changes the
 +  type [#7175](https://github.com/rust-lang/rust-clippy/pull/7175)
 +- [`wrong_self_convention`]: No longer lints in trait implementations of
 +  non-`Copy` types [#7182](https://github.com/rust-lang/rust-clippy/pull/7182)
 +- [`suboptimal_flops`]: No longer lints on `powi(2)`
 +  [#7201](https://github.com/rust-lang/rust-clippy/pull/7201)
 +- [`wrong_self_convention`]: No longer lints if there is no implicit `self`
 +  [#7215](https://github.com/rust-lang/rust-clippy/pull/7215)
 +- [`option_if_let_else`]: No longer lints on `else if let` pattern
 +  [#7216](https://github.com/rust-lang/rust-clippy/pull/7216)
 +- [`use_self`], [`useless_conversion`]: Fix false positives when generic
 +  arguments are involved
 +  [#7223](https://github.com/rust-lang/rust-clippy/pull/7223)
 +- [`manual_unwrap_or`]: Fix false positive with deref coercion
 +  [#7233](https://github.com/rust-lang/rust-clippy/pull/7233)
 +- [`similar_names`]: No longer lints on `wparam`/`lparam`
 +  [#7255](https://github.com/rust-lang/rust-clippy/pull/7255)
 +- [`redundant_closure`]: No longer lints on using the `vec![]` macro in a
 +  closure [#7263](https://github.com/rust-lang/rust-clippy/pull/7263)
 +
 +### Suggestion Fixes/Improvements
 +
 +- [`implicit_return`]
 +  [#6951](https://github.com/rust-lang/rust-clippy/pull/6951)
 +    - Fix suggestion for async functions
 +    - Improve suggestion with macros
 +    - Suggest to change `break` to `return` when appropriate
 +- [`while_let_on_iterator`]: Now suggests `&mut iter` when necessary
 +  [#6966](https://github.com/rust-lang/rust-clippy/pull/6966)
 +- [`match_single_binding`]: Improve suggestion when match scrutinee has side
 +  effects [#7095](https://github.com/rust-lang/rust-clippy/pull/7095)
 +- [`needless_borrow`]: Now suggests to also change usage sites as needed
 +  [#7105](https://github.com/rust-lang/rust-clippy/pull/7105)
 +- [`write_with_newline`]: Improve suggestion when only `\n` is written to the
 +  buffer [#7183](https://github.com/rust-lang/rust-clippy/pull/7183)
 +- [`from_iter_instead_of_collect`]: The suggestion is now auto applicable also
 +  when a `<_ as Trait>::_` is involved
 +  [#7264](https://github.com/rust-lang/rust-clippy/pull/7264)
 +- [`not_unsafe_ptr_arg_deref`]: Improved error message
 +  [#7294](https://github.com/rust-lang/rust-clippy/pull/7294)
 +
 +### ICE Fixes
 +
 +- Fix ICE when running Clippy on `libstd`
 +  [#7140](https://github.com/rust-lang/rust-clippy/pull/7140)
 +- [`implicit_return`]
 +  [#7242](https://github.com/rust-lang/rust-clippy/pull/7242)
 +
 +## Rust 1.53
 +
 +Released 2021-06-17
 +
 +[6ed6f1e...7c7683c](https://github.com/rust-lang/rust-clippy/compare/6ed6f1e...7c7683c)
 +
 +### New Lints
 +
 +* [`option_filter_map`]
 +  [#6342](https://github.com/rust-lang/rust-clippy/pull/6342)
 +* [`branches_sharing_code`]
 +  [#6463](https://github.com/rust-lang/rust-clippy/pull/6463)
 +* [`needless_for_each`]
 +  [#6706](https://github.com/rust-lang/rust-clippy/pull/6706)
 +* [`if_then_some_else_none`]
 +  [#6859](https://github.com/rust-lang/rust-clippy/pull/6859)
 +* [`non_octal_unix_permissions`]
 +  [#7001](https://github.com/rust-lang/rust-clippy/pull/7001)
 +* [`unnecessary_self_imports`]
 +  [#7072](https://github.com/rust-lang/rust-clippy/pull/7072)
 +* [`bool_assert_comparison`]
 +  [#7083](https://github.com/rust-lang/rust-clippy/pull/7083)
 +* [`cloned_instead_of_copied`]
 +  [#7098](https://github.com/rust-lang/rust-clippy/pull/7098)
 +* [`flat_map_option`]
 +  [#7101](https://github.com/rust-lang/rust-clippy/pull/7101)
 +
 +### Moves and Deprecations
 +
 +* Deprecate [`filter_map`] lint
 +  [#7059](https://github.com/rust-lang/rust-clippy/pull/7059)
 +* Move [`transmute_ptr_to_ptr`] to `pedantic`
 +  [#7102](https://github.com/rust-lang/rust-clippy/pull/7102)
 +
 +### Enhancements
 +
 +* [`mem_replace_with_default`]: Also lint on common std constructors
 +  [#6820](https://github.com/rust-lang/rust-clippy/pull/6820)
 +* [`wrong_self_convention`]: Also lint on `to_*_mut` methods
 +  [#6828](https://github.com/rust-lang/rust-clippy/pull/6828)
 +* [`wildcard_enum_match_arm`], [`match_wildcard_for_single_variants`]:
 +  [#6863](https://github.com/rust-lang/rust-clippy/pull/6863)
 +    * Attempt to find a common path prefix in suggestion
 +    * Don't lint on `Option` and `Result`
 +    * Consider `Self` prefix
 +* [`explicit_deref_methods`]: Also lint on chained `deref` calls
 +  [#6865](https://github.com/rust-lang/rust-clippy/pull/6865)
 +* [`or_fun_call`]: Also lint on `unsafe` blocks
 +  [#6928](https://github.com/rust-lang/rust-clippy/pull/6928)
 +* [`vec_box`], [`linkedlist`], [`option_option`]: Also lint in `const` and
 +  `static` items [#6938](https://github.com/rust-lang/rust-clippy/pull/6938)
 +* [`search_is_some`]: Also check for `is_none`
 +  [#6942](https://github.com/rust-lang/rust-clippy/pull/6942)
 +* [`string_lit_as_bytes`]: Also lint on `into_bytes`
 +  [#6959](https://github.com/rust-lang/rust-clippy/pull/6959)
 +* [`len_without_is_empty`]: Also lint if function signatures of `len` and
 +  `is_empty` don't match
 +  [#6980](https://github.com/rust-lang/rust-clippy/pull/6980)
 +* [`redundant_pattern_matching`]: Also lint if the pattern is a `&` pattern
 +  [#6991](https://github.com/rust-lang/rust-clippy/pull/6991)
 +* [`clone_on_copy`]: Also lint on chained method calls taking `self` by value
 +  [#7000](https://github.com/rust-lang/rust-clippy/pull/7000)
 +* [`missing_panics_doc`]: Also lint on `assert_eq!` and `assert_ne!`
 +  [#7029](https://github.com/rust-lang/rust-clippy/pull/7029)
 +* [`needless_return`]: Also lint in `async` functions
 +  [#7067](https://github.com/rust-lang/rust-clippy/pull/7067)
 +* [`unused_io_amount`]: Also lint on expressions like `_.read().ok()?`
 +  [#7100](https://github.com/rust-lang/rust-clippy/pull/7100)
 +* [`iter_cloned_collect`]: Also lint on large arrays, since const-generics are
 +  now stable [#7138](https://github.com/rust-lang/rust-clippy/pull/7138)
 +
 +### False Positive Fixes
 +
 +* [`upper_case_acronyms`]: No longer lints on public items
 +  [#6805](https://github.com/rust-lang/rust-clippy/pull/6805)
 +* [`suspicious_map`]: No longer lints when side effects may occur inside the
 +  `map` call [#6831](https://github.com/rust-lang/rust-clippy/pull/6831)
 +* [`manual_map`], [`manual_unwrap_or`]: No longer lints in `const` functions
 +  [#6917](https://github.com/rust-lang/rust-clippy/pull/6917)
 +* [`wrong_self_convention`]: Now respects `Copy` types
 +  [#6924](https://github.com/rust-lang/rust-clippy/pull/6924)
 +* [`needless_question_mark`]: No longer lints if the `?` and the `Some(..)` come
 +  from different macro contexts [#6935](https://github.com/rust-lang/rust-clippy/pull/6935)
 +* [`map_entry`]: Better detect if the entry API can be used
 +  [#6937](https://github.com/rust-lang/rust-clippy/pull/6937)
 +* [`or_fun_call`]: No longer lints on some `len` function calls
 +  [#6950](https://github.com/rust-lang/rust-clippy/pull/6950)
 +* [`new_ret_no_self`]: No longer lints when `Self` is returned with different
 +  generic arguments [#6952](https://github.com/rust-lang/rust-clippy/pull/6952)
 +* [`upper_case_acronyms`]: No longer lints on public items
 +  [#6981](https://github.com/rust-lang/rust-clippy/pull/6981)
 +* [`explicit_into_iter_loop`]: Only lint when `into_iter` is an implementation
 +  of `IntoIterator` [#6982](https://github.com/rust-lang/rust-clippy/pull/6982)
 +* [`expl_impl_clone_on_copy`]: Take generic constraints into account before
 +  suggesting to use `derive` instead
 +  [#6993](https://github.com/rust-lang/rust-clippy/pull/6993)
 +* [`missing_panics_doc`]: No longer lints when only debug-assertions are used
 +  [#6996](https://github.com/rust-lang/rust-clippy/pull/6996)
 +* [`clone_on_copy`]: Only lint when using the `Clone` trait
 +  [#7000](https://github.com/rust-lang/rust-clippy/pull/7000)
 +* [`wrong_self_convention`]: No longer lints inside a trait implementation
 +  [#7002](https://github.com/rust-lang/rust-clippy/pull/7002)
 +* [`redundant_clone`]: No longer lints when the cloned value is modified while
 +  the clone is in use
 +  [#7011](https://github.com/rust-lang/rust-clippy/pull/7011)
 +* [`same_item_push`]: No longer lints if the `Vec` is used in the loop body
 +  [#7018](https://github.com/rust-lang/rust-clippy/pull/7018)
 +* [`cargo_common_metadata`]: Remove author requirement
 +  [#7026](https://github.com/rust-lang/rust-clippy/pull/7026)
 +* [`panic_in_result_fn`]: No longer lints on `debug_assert` family
 +  [#7060](https://github.com/rust-lang/rust-clippy/pull/7060)
 +* [`panic`]: No longer wrongfully lints on `debug_assert` with message
 +  [#7063](https://github.com/rust-lang/rust-clippy/pull/7063)
 +* [`wrong_self_convention`]: No longer lints in trait implementations where no
 +  `self` is involved [#7064](https://github.com/rust-lang/rust-clippy/pull/7064)
 +* [`missing_const_for_fn`]: No longer lints when unstable `const` function is
 +  involved [#7076](https://github.com/rust-lang/rust-clippy/pull/7076)
 +* [`suspicious_else_formatting`]: Allow Allman style braces
 +  [#7087](https://github.com/rust-lang/rust-clippy/pull/7087)
 +* [`inconsistent_struct_constructor`]: No longer lints in macros
 +  [#7097](https://github.com/rust-lang/rust-clippy/pull/7097)
 +* [`single_component_path_imports`]: No longer lints on macro re-exports
 +  [#7120](https://github.com/rust-lang/rust-clippy/pull/7120)
 +
 +### Suggestion Fixes/Improvements
 +
 +* [`redundant_pattern_matching`]: Add a note when applying this lint would
 +  change the drop order
 +  [#6568](https://github.com/rust-lang/rust-clippy/pull/6568)
 +* [`write_literal`], [`print_literal`]: Add auto-applicable suggestion
 +  [#6821](https://github.com/rust-lang/rust-clippy/pull/6821)
 +* [`manual_map`]: Fix suggestion for complex `if let ... else` chains
 +  [#6856](https://github.com/rust-lang/rust-clippy/pull/6856)
 +* [`inconsistent_struct_constructor`]: Make lint description and message clearer
 +  [#6892](https://github.com/rust-lang/rust-clippy/pull/6892)
 +* [`map_entry`]: Now suggests `or_insert`, `insert_with` or `match _.entry(_)`
 +  as appropriate [#6937](https://github.com/rust-lang/rust-clippy/pull/6937)
 +* [`manual_flatten`]: Suggest to insert `copied` if necessary
 +  [#6962](https://github.com/rust-lang/rust-clippy/pull/6962)
 +* [`redundant_slicing`]: Fix suggestion when a re-borrow might be required or
 +  when the value is from a macro call
 +  [#6975](https://github.com/rust-lang/rust-clippy/pull/6975)
 +* [`match_wildcard_for_single_variants`]: Fix suggestion for hidden variant
 +  [#6988](https://github.com/rust-lang/rust-clippy/pull/6988)
 +* [`clone_on_copy`]: Correct suggestion when the cloned value is a macro call
 +  [#7000](https://github.com/rust-lang/rust-clippy/pull/7000)
 +* [`manual_map`]: Fix suggestion at the end of an if chain
 +  [#7004](https://github.com/rust-lang/rust-clippy/pull/7004)
 +* Fix needless parenthesis output in multiple lint suggestions
 +  [#7013](https://github.com/rust-lang/rust-clippy/pull/7013)
 +* [`needless_collect`]: Better explanation in the lint message
 +  [#7020](https://github.com/rust-lang/rust-clippy/pull/7020)
 +* [`useless_vec`]: Now considers mutability
 +  [#7036](https://github.com/rust-lang/rust-clippy/pull/7036)
 +* [`useless_format`]: Wrap the content in braces if necessary
 +  [#7092](https://github.com/rust-lang/rust-clippy/pull/7092)
 +* [`single_match`]: Don't suggest an equality check for types which don't
 +  implement `PartialEq`
 +  [#7093](https://github.com/rust-lang/rust-clippy/pull/7093)
 +* [`from_over_into`]: Mention type in help message
 +  [#7099](https://github.com/rust-lang/rust-clippy/pull/7099)
 +* [`manual_unwrap_or`]: Fix invalid code suggestion due to a macro call
 +  [#7136](https://github.com/rust-lang/rust-clippy/pull/7136)
 +
 +### ICE Fixes
 +
 +* [`macro_use_imports`]
 +  [#7022](https://github.com/rust-lang/rust-clippy/pull/7022)
 +* [`missing_panics_doc`]
 +  [#7034](https://github.com/rust-lang/rust-clippy/pull/7034)
 +* [`tabs_in_doc_comments`]
 +  [#7039](https://github.com/rust-lang/rust-clippy/pull/7039)
 +* [`missing_const_for_fn`]
 +  [#7128](https://github.com/rust-lang/rust-clippy/pull/7128)
 +
 +### Others
 +
 +* [Clippy's lint
 +  list](https://rust-lang.github.io/rust-clippy/master/index.html) now supports
 +  themes [#7030](https://github.com/rust-lang/rust-clippy/pull/7030)
 +* Lints that were uplifted to `rustc` now mention the new `rustc` name in the
 +  deprecation warning
 +  [#7056](https://github.com/rust-lang/rust-clippy/pull/7056)
 +
 +## Rust 1.52
 +
 +Released 2021-05-06
 +
 +[3e41797...6ed6f1e](https://github.com/rust-lang/rust-clippy/compare/3e41797...6ed6f1e)
 +
 +### New Lints
 +
 +* [`from_str_radix_10`]
 +  [#6717](https://github.com/rust-lang/rust-clippy/pull/6717)
 +* [`implicit_clone`]
 +  [#6730](https://github.com/rust-lang/rust-clippy/pull/6730)
 +* [`semicolon_if_nothing_returned`]
 +  [#6681](https://github.com/rust-lang/rust-clippy/pull/6681)
 +* [`manual_flatten`]
 +  [#6646](https://github.com/rust-lang/rust-clippy/pull/6646)
 +* [`inconsistent_struct_constructor`]
 +  [#6769](https://github.com/rust-lang/rust-clippy/pull/6769)
 +* [`iter_count`]
 +  [#6791](https://github.com/rust-lang/rust-clippy/pull/6791)
 +* [`default_numeric_fallback`]
 +  [#6662](https://github.com/rust-lang/rust-clippy/pull/6662)
 +* [`bytes_nth`]
 +  [#6695](https://github.com/rust-lang/rust-clippy/pull/6695)
 +* [`filter_map_identity`]
 +  [#6685](https://github.com/rust-lang/rust-clippy/pull/6685)
 +* [`manual_map`]
 +  [#6573](https://github.com/rust-lang/rust-clippy/pull/6573)
 +
 +### Moves and Deprecations
 +
 +* Moved [`upper_case_acronyms`] to `pedantic`
 +  [#6775](https://github.com/rust-lang/rust-clippy/pull/6775)
 +* Moved [`manual_map`] to `nursery`
 +  [#6796](https://github.com/rust-lang/rust-clippy/pull/6796)
 +* Moved [`unnecessary_wraps`] to `pedantic`
 +  [#6765](https://github.com/rust-lang/rust-clippy/pull/6765)
 +* Moved [`trivial_regex`] to `nursery`
 +  [#6696](https://github.com/rust-lang/rust-clippy/pull/6696)
 +* Moved [`naive_bytecount`] to `pedantic`
 +  [#6825](https://github.com/rust-lang/rust-clippy/pull/6825)
 +* Moved [`upper_case_acronyms`] to `style`
 +  [#6788](https://github.com/rust-lang/rust-clippy/pull/6788)
 +* Moved [`manual_map`] to `style`
 +  [#6801](https://github.com/rust-lang/rust-clippy/pull/6801)
 +
 +### Enhancements
 +
 +* [`disallowed_methods`]: Now supports functions in addition to methods
 +  [#6674](https://github.com/rust-lang/rust-clippy/pull/6674)
 +* [`upper_case_acronyms`]: Added a new configuration `upper-case-acronyms-aggressive` to
 +  trigger the lint if there is more than one uppercase character next to each other
 +  [#6788](https://github.com/rust-lang/rust-clippy/pull/6788)
 +* [`collapsible_match`]: Now supports block comparison with different value names
 +  [#6754](https://github.com/rust-lang/rust-clippy/pull/6754)
 +* [`unnecessary_wraps`]: Will now suggest removing unnecessary wrapped return unit type, like `Option<()>`
 +  [#6665](https://github.com/rust-lang/rust-clippy/pull/6665)
 +* Improved value usage detection in closures
 +  [#6698](https://github.com/rust-lang/rust-clippy/pull/6698)
 +
 +### False Positive Fixes
 +
 +* [`use_self`]: No longer lints in macros
 +  [#6833](https://github.com/rust-lang/rust-clippy/pull/6833)
 +* [`use_self`]: Fixed multiple false positives for: generics, associated types and derive implementations
 +  [#6179](https://github.com/rust-lang/rust-clippy/pull/6179)
 +* [`missing_inline_in_public_items`]: No longer lints for procedural macros
 +  [#6814](https://github.com/rust-lang/rust-clippy/pull/6814)
 +* [`inherent_to_string`]: No longer lints on functions with function generics
 +  [#6771](https://github.com/rust-lang/rust-clippy/pull/6771)
 +* [`doc_markdown`]: Add `OpenDNS` to the default configuration as an allowed identifier
 +  [#6783](https://github.com/rust-lang/rust-clippy/pull/6783)
 +* [`missing_panics_doc`]: No longer lints on [`unreachable!`](https://doc.rust-lang.org/std/macro.unreachable.html)
 +  [#6700](https://github.com/rust-lang/rust-clippy/pull/6700)
 +* [`collapsible_if`]: No longer lints on if statements with attributes
 +  [#6701](https://github.com/rust-lang/rust-clippy/pull/6701)
 +* [`match_same_arms`]: Only considers empty blocks as equal if the tokens contained are the same
 +  [#6843](https://github.com/rust-lang/rust-clippy/pull/6843)
 +* [`redundant_closure`]: Now ignores macros
 +  [#6871](https://github.com/rust-lang/rust-clippy/pull/6871)
 +* [`manual_map`]: Fixed false positives when control flow statements like `return`, `break` etc. are used
 +  [#6801](https://github.com/rust-lang/rust-clippy/pull/6801)
 +* [`vec_init_then_push`]: Fixed false positives for loops and if statements
 +  [#6697](https://github.com/rust-lang/rust-clippy/pull/6697)
 +* [`len_without_is_empty`]: Will now consider multiple impl blocks and `#[allow]` on
 +  the `len` method as well as the type definition.
 +  [#6853](https://github.com/rust-lang/rust-clippy/pull/6853)
 +* [`let_underscore_drop`]: Only lints on types which implement `Drop`
 +  [#6682](https://github.com/rust-lang/rust-clippy/pull/6682)
 +* [`unit_arg`]: No longer lints on unit arguments when they come from a path expression.
 +  [#6601](https://github.com/rust-lang/rust-clippy/pull/6601)
 +* [`cargo_common_metadata`]: No longer lints if
 +  [`publish = false`](https://doc.rust-lang.org/cargo/reference/manifest.html#the-publish-field)
 +  is defined in the manifest
 +  [#6650](https://github.com/rust-lang/rust-clippy/pull/6650)
 +
 +### Suggestion Fixes/Improvements
 +
 +* [`collapsible_match`]: Fixed lint message capitalization
 +  [#6766](https://github.com/rust-lang/rust-clippy/pull/6766)
 +* [`or_fun_call`]: Improved suggestions for `or_insert(vec![])`
 +  [#6790](https://github.com/rust-lang/rust-clippy/pull/6790)
 +* [`manual_map`]: No longer expands macros in the suggestions
 +  [#6801](https://github.com/rust-lang/rust-clippy/pull/6801)
 +* Aligned Clippy's lint messages with the rustc dev guide
 +  [#6787](https://github.com/rust-lang/rust-clippy/pull/6787)
 +
 +### ICE Fixes
 +
 +* [`zero_sized_map_values`]
 +  [#6866](https://github.com/rust-lang/rust-clippy/pull/6866)
 +
 +### Documentation Improvements
 +
 +* [`useless_format`]: Improved the documentation example
 +  [#6854](https://github.com/rust-lang/rust-clippy/pull/6854)
 +* Clippy's [`README.md`]: Includes a new subsection on running Clippy as a rustc wrapper
 +  [#6782](https://github.com/rust-lang/rust-clippy/pull/6782)
 +
 +### Others
 +* Running `cargo clippy` after `cargo check` now works as expected
 +  (`cargo clippy` and `cargo check` no longer shares the same build cache)
 +  [#6687](https://github.com/rust-lang/rust-clippy/pull/6687)
 +* Cargo now re-runs Clippy if arguments after `--` provided to `cargo clippy` are changed.
 +  [#6834](https://github.com/rust-lang/rust-clippy/pull/6834)
 +* Extracted Clippy's `utils` module into the new `clippy_utils` crate
 +  [#6756](https://github.com/rust-lang/rust-clippy/pull/6756)
 +* Clippy lintcheck tool improvements
 +  [#6800](https://github.com/rust-lang/rust-clippy/pull/6800)
 +  [#6735](https://github.com/rust-lang/rust-clippy/pull/6735)
 +  [#6764](https://github.com/rust-lang/rust-clippy/pull/6764)
 +  [#6708](https://github.com/rust-lang/rust-clippy/pull/6708)
 +  [#6780](https://github.com/rust-lang/rust-clippy/pull/6780)
 +  [#6686](https://github.com/rust-lang/rust-clippy/pull/6686)
 +
 +## Rust 1.51
 +
 +Released 2021-03-25
 +
 +[4911ab1...3e41797](https://github.com/rust-lang/rust-clippy/compare/4911ab1...3e41797)
 +
 +### New Lints
 +
 +* [`upper_case_acronyms`]
 +  [#6475](https://github.com/rust-lang/rust-clippy/pull/6475)
 +* [`from_over_into`] [#6476](https://github.com/rust-lang/rust-clippy/pull/6476)
 +* [`case_sensitive_file_extension_comparisons`]
 +  [#6500](https://github.com/rust-lang/rust-clippy/pull/6500)
 +* [`needless_question_mark`]
 +  [#6507](https://github.com/rust-lang/rust-clippy/pull/6507)
 +* [`missing_panics_doc`]
 +  [#6523](https://github.com/rust-lang/rust-clippy/pull/6523)
 +* [`redundant_slicing`]
 +  [#6528](https://github.com/rust-lang/rust-clippy/pull/6528)
 +* [`vec_init_then_push`]
 +  [#6538](https://github.com/rust-lang/rust-clippy/pull/6538)
 +* [`ptr_as_ptr`] [#6542](https://github.com/rust-lang/rust-clippy/pull/6542)
 +* [`collapsible_else_if`] (split out from `collapsible_if`)
 +  [#6544](https://github.com/rust-lang/rust-clippy/pull/6544)
 +* [`inspect_for_each`] [#6577](https://github.com/rust-lang/rust-clippy/pull/6577)
 +* [`manual_filter_map`]
 +  [#6591](https://github.com/rust-lang/rust-clippy/pull/6591)
 +* [`exhaustive_enums`]
 +  [#6617](https://github.com/rust-lang/rust-clippy/pull/6617)
 +* [`exhaustive_structs`]
 +  [#6617](https://github.com/rust-lang/rust-clippy/pull/6617)
 +
 +### Moves and Deprecations
 +
 +* Replace [`find_map`] with [`manual_find_map`]
 +  [#6591](https://github.com/rust-lang/rust-clippy/pull/6591)
 +* `unknown_clippy_lints` Now integrated in the `unknown_lints` rustc lint
 +  [#6653](https://github.com/rust-lang/rust-clippy/pull/6653)
 +
 +### Enhancements
 +
 +* [`ptr_arg`] Now also suggests to use `&Path` instead of `&PathBuf`
 +  [#6506](https://github.com/rust-lang/rust-clippy/pull/6506)
 +* [`cast_ptr_alignment`] Also lint when the `pointer::cast` method is used
 +  [#6557](https://github.com/rust-lang/rust-clippy/pull/6557)
 +* [`collapsible_match`] Now also deals with `&` and `*` operators in the `match`
 +  scrutinee [#6619](https://github.com/rust-lang/rust-clippy/pull/6619)
 +
 +### False Positive Fixes
 +
 +* [`similar_names`] Ignore underscore prefixed names
 +  [#6403](https://github.com/rust-lang/rust-clippy/pull/6403)
 +* [`print_literal`] and [`write_literal`] No longer lint numeric literals
 +  [#6408](https://github.com/rust-lang/rust-clippy/pull/6408)
 +* [`large_enum_variant`] No longer lints in external macros
 +  [#6485](https://github.com/rust-lang/rust-clippy/pull/6485)
 +* [`empty_enum`] Only lint if `never_type` feature is enabled
 +  [#6513](https://github.com/rust-lang/rust-clippy/pull/6513)
 +* [`field_reassign_with_default`] No longer lints in macros
 +  [#6553](https://github.com/rust-lang/rust-clippy/pull/6553)
 +* [`size_of_in_element_count`] No longer lints when dividing by element size
 +  [#6578](https://github.com/rust-lang/rust-clippy/pull/6578)
 +* [`needless_return`] No longer lints in macros
 +  [#6586](https://github.com/rust-lang/rust-clippy/pull/6586)
 +* [`match_overlapping_arm`] No longer lint when first arm is completely included
 +  in second arm [#6603](https://github.com/rust-lang/rust-clippy/pull/6603)
 +* [`doc_markdown`] Add `WebGL` to the default configuration as an allowed
 +  identifier [#6605](https://github.com/rust-lang/rust-clippy/pull/6605)
 +
 +### Suggestion Fixes/Improvements
 +
 +* [`field_reassign_with_default`] Don't expand macro in lint suggestion
 +  [#6531](https://github.com/rust-lang/rust-clippy/pull/6531)
 +* [`match_like_matches_macro`] Strip references in suggestion
 +  [#6532](https://github.com/rust-lang/rust-clippy/pull/6532)
 +* [`single_match`] Suggest `if` over `if let` when possible
 +  [#6574](https://github.com/rust-lang/rust-clippy/pull/6574)
- [`ref_in_deref`]: https://rust-lang.github.io/rust-clippy/master/index.html#ref_in_deref
++* `ref_in_deref` Use parentheses correctly in suggestion
 +  [#6609](https://github.com/rust-lang/rust-clippy/pull/6609)
 +* [`stable_sort_primitive`] Clarify error message
 +  [#6611](https://github.com/rust-lang/rust-clippy/pull/6611)
 +
 +### ICE Fixes
 +
 +* [`zero_sized_map_values`]
 +  [#6582](https://github.com/rust-lang/rust-clippy/pull/6582)
 +
 +### Documentation Improvements
 +
 +* Improve search performance on the Clippy website and make it possible to
 +  directly search for lints on the GitHub issue tracker
 +  [#6483](https://github.com/rust-lang/rust-clippy/pull/6483)
 +* Clean up `README.md` by removing outdated paragraph
 +  [#6488](https://github.com/rust-lang/rust-clippy/pull/6488)
 +* [`await_holding_refcell_ref`] and [`await_holding_lock`]
 +  [#6585](https://github.com/rust-lang/rust-clippy/pull/6585)
 +* [`as_conversions`] [#6608](https://github.com/rust-lang/rust-clippy/pull/6608)
 +
 +### Others
 +
 +* Clippy now has a [Roadmap] for 2021. If you like to get involved in a bigger
 +  project, take a look at the [Roadmap project page]. All issues listed there
 +  are actively mentored
 +  [#6462](https://github.com/rust-lang/rust-clippy/pull/6462)
 +* The Clippy version number now corresponds to the Rust version number
 +  [#6526](https://github.com/rust-lang/rust-clippy/pull/6526)
 +* Fix oversight which caused Clippy to lint deps in some environments, where
 +  `CLIPPY_TESTS=true` was set somewhere
 +  [#6575](https://github.com/rust-lang/rust-clippy/pull/6575)
 +* Add `cargo dev-lintcheck` tool to the Clippy Dev Tool
 +  [#6469](https://github.com/rust-lang/rust-clippy/pull/6469)
 +
 +[Roadmap]: https://github.com/rust-lang/rust-clippy/blob/master/doc/roadmap-2021.md
 +[Roadmap project page]: https://github.com/rust-lang/rust-clippy/projects/3
 +
 +## Rust 1.50
 +
 +Released 2021-02-11
 +
 +[b20d4c1...4bd77a1](https://github.com/rust-lang/rust-clippy/compare/b20d4c1...4bd77a1)
 +
 +### New Lints
 +
 +* [`suspicious_operation_groupings`] [#6086](https://github.com/rust-lang/rust-clippy/pull/6086)
 +* [`size_of_in_element_count`] [#6394](https://github.com/rust-lang/rust-clippy/pull/6394)
 +* [`unnecessary_wraps`] [#6070](https://github.com/rust-lang/rust-clippy/pull/6070)
 +* [`let_underscore_drop`] [#6305](https://github.com/rust-lang/rust-clippy/pull/6305)
 +* [`collapsible_match`] [#6402](https://github.com/rust-lang/rust-clippy/pull/6402)
 +* [`redundant_else`] [#6330](https://github.com/rust-lang/rust-clippy/pull/6330)
 +* [`zero_sized_map_values`] [#6218](https://github.com/rust-lang/rust-clippy/pull/6218)
 +* [`print_stderr`] [#6367](https://github.com/rust-lang/rust-clippy/pull/6367)
 +* [`string_from_utf8_as_bytes`] [#6134](https://github.com/rust-lang/rust-clippy/pull/6134)
 +
 +### Moves and Deprecations
 +
 +* Previously deprecated [`str_to_string`] and [`string_to_string`] have been un-deprecated
 +  as `restriction` lints [#6333](https://github.com/rust-lang/rust-clippy/pull/6333)
 +* Deprecate `panic_params` lint. This is now available in rustc as `non_fmt_panics`
 +  [#6351](https://github.com/rust-lang/rust-clippy/pull/6351)
 +* Move [`map_err_ignore`] to `restriction`
 +  [#6416](https://github.com/rust-lang/rust-clippy/pull/6416)
 +* Move [`await_holding_refcell_ref`] to `pedantic`
 +  [#6354](https://github.com/rust-lang/rust-clippy/pull/6354)
 +* Move [`await_holding_lock`] to `pedantic`
 +  [#6354](https://github.com/rust-lang/rust-clippy/pull/6354)
 +
 +### Enhancements
 +
 +* Add the `unreadable-literal-lint-fractions` configuration to disable
 +  the `unreadable_literal` lint for fractions
 +  [#6421](https://github.com/rust-lang/rust-clippy/pull/6421)
 +* [`clone_on_copy`]: Now shows the type in the lint message
 +  [#6443](https://github.com/rust-lang/rust-clippy/pull/6443)
 +* [`redundant_pattern_matching`]: Now also lints on `std::task::Poll`
 +  [#6339](https://github.com/rust-lang/rust-clippy/pull/6339)
 +* [`redundant_pattern_matching`]: Additionally also lints on `std::net::IpAddr`
 +  [#6377](https://github.com/rust-lang/rust-clippy/pull/6377)
 +* [`search_is_some`]: Now suggests `contains` instead of `find(foo).is_some()`
 +  [#6119](https://github.com/rust-lang/rust-clippy/pull/6119)
 +* [`clone_double_ref`]: Now prints the reference type in the lint message
 +  [#6442](https://github.com/rust-lang/rust-clippy/pull/6442)
 +* [`modulo_one`]: Now also lints on -1.
 +  [#6360](https://github.com/rust-lang/rust-clippy/pull/6360)
 +* [`empty_loop`]: Now lints no_std crates, too
 +  [#6205](https://github.com/rust-lang/rust-clippy/pull/6205)
 +* [`or_fun_call`]: Now also lints when indexing `HashMap` or `BTreeMap`
 +  [#6267](https://github.com/rust-lang/rust-clippy/pull/6267)
 +* [`wrong_self_convention`]: Now also lints in trait definitions
 +  [#6316](https://github.com/rust-lang/rust-clippy/pull/6316)
 +* [`needless_borrow`]: Print the type in the lint message
 +  [#6449](https://github.com/rust-lang/rust-clippy/pull/6449)
 +
 +[msrv_readme]: https://github.com/rust-lang/rust-clippy#specifying-the-minimum-supported-rust-version
 +
 +### False Positive Fixes
 +
 +* [`manual_range_contains`]: No longer lints in `const fn`
 +  [#6382](https://github.com/rust-lang/rust-clippy/pull/6382)
 +* [`unnecessary_lazy_evaluations`]: No longer lints if closure argument is used
 +  [#6370](https://github.com/rust-lang/rust-clippy/pull/6370)
 +* [`match_single_binding`]: Now ignores cases with `#[cfg()]` macros
 +  [#6435](https://github.com/rust-lang/rust-clippy/pull/6435)
 +* [`match_like_matches_macro`]: No longer lints on arms with attributes
 +  [#6290](https://github.com/rust-lang/rust-clippy/pull/6290)
 +* [`map_clone`]: No longer lints with deref and clone
 +  [#6269](https://github.com/rust-lang/rust-clippy/pull/6269)
 +* [`map_clone`]: No longer lints in the case of &mut
 +  [#6301](https://github.com/rust-lang/rust-clippy/pull/6301)
 +* [`needless_update`]: Now ignores `non_exhaustive` structs
 +  [#6464](https://github.com/rust-lang/rust-clippy/pull/6464)
 +* [`needless_collect`]: No longer lints when a collect is needed multiple times
 +  [#6313](https://github.com/rust-lang/rust-clippy/pull/6313)
 +* [`unnecessary_cast`] No longer lints cfg-dependent types
 +  [#6369](https://github.com/rust-lang/rust-clippy/pull/6369)
 +* [`declare_interior_mutable_const`] and [`borrow_interior_mutable_const`]:
 +  Both now ignore enums with frozen variants
 +  [#6110](https://github.com/rust-lang/rust-clippy/pull/6110)
 +* [`field_reassign_with_default`] No longer lint for private fields
 +  [#6537](https://github.com/rust-lang/rust-clippy/pull/6537)
 +
 +
 +### Suggestion Fixes/Improvements
 +
 +* [`vec_box`]: Provide correct type scope suggestion
 +  [#6271](https://github.com/rust-lang/rust-clippy/pull/6271)
 +* [`manual_range_contains`]: Give correct suggestion when using floats
 +  [#6320](https://github.com/rust-lang/rust-clippy/pull/6320)
 +* [`unnecessary_lazy_evaluations`]: Don't always mark suggestion as MachineApplicable
 +  [#6272](https://github.com/rust-lang/rust-clippy/pull/6272)
 +* [`manual_async_fn`]: Improve suggestion formatting
 +  [#6294](https://github.com/rust-lang/rust-clippy/pull/6294)
 +* [`unnecessary_cast`]: Fix incorrectly formatted float literal suggestion
 +  [#6362](https://github.com/rust-lang/rust-clippy/pull/6362)
 +
 +### ICE Fixes
 +
 +* Fix a crash in [`from_iter_instead_of_collect`]
 +  [#6304](https://github.com/rust-lang/rust-clippy/pull/6304)
 +* Fix a silent crash when parsing doc comments in [`needless_doctest_main`]
 +  [#6458](https://github.com/rust-lang/rust-clippy/pull/6458)
 +
 +### Documentation Improvements
 +
 +* The lint website search has been improved ([#6477](https://github.com/rust-lang/rust-clippy/pull/6477)):
 +  * Searching for lints with dashes and spaces is possible now. For example
 +    `missing-errors-doc` and `missing errors doc` are now valid aliases for lint names
 +  * Improved fuzzy search in lint descriptions
 +* Various README improvements
 +  [#6287](https://github.com/rust-lang/rust-clippy/pull/6287)
 +* Add known problems to [`comparison_chain`] documentation
 +  [#6390](https://github.com/rust-lang/rust-clippy/pull/6390)
 +* Fix example used in [`cargo_common_metadata`]
 +  [#6293](https://github.com/rust-lang/rust-clippy/pull/6293)
 +* Improve [`map_clone`] documentation
 +  [#6340](https://github.com/rust-lang/rust-clippy/pull/6340)
 +
 +### Others
 +
 +* You can now tell Clippy about the MSRV your project supports. Please refer to
 +  the specific README section to learn more about MSRV support [here][msrv_readme]
 +  [#6201](https://github.com/rust-lang/rust-clippy/pull/6201)
 +* Add `--no-deps` option to avoid running on path dependencies in workspaces
 +  [#6188](https://github.com/rust-lang/rust-clippy/pull/6188)
 +
 +## Rust 1.49
 +
 +Released 2020-12-31
 +
 +[e636b88...b20d4c1](https://github.com/rust-lang/rust-clippy/compare/e636b88...b20d4c1)
 +
 +### New Lints
 +
 +* [`field_reassign_with_default`] [#5911](https://github.com/rust-lang/rust-clippy/pull/5911)
 +* [`await_holding_refcell_ref`] [#6029](https://github.com/rust-lang/rust-clippy/pull/6029)
 +* [`disallowed_methods`] [#6081](https://github.com/rust-lang/rust-clippy/pull/6081)
 +* [`inline_asm_x86_att_syntax`] [#6092](https://github.com/rust-lang/rust-clippy/pull/6092)
 +* [`inline_asm_x86_intel_syntax`] [#6092](https://github.com/rust-lang/rust-clippy/pull/6092)
 +* [`from_iter_instead_of_collect`] [#6101](https://github.com/rust-lang/rust-clippy/pull/6101)
 +* [`mut_mutex_lock`] [#6103](https://github.com/rust-lang/rust-clippy/pull/6103)
 +* [`single_element_loop`] [#6109](https://github.com/rust-lang/rust-clippy/pull/6109)
 +* [`manual_unwrap_or`] [#6123](https://github.com/rust-lang/rust-clippy/pull/6123)
 +* [`large_types_passed_by_value`] [#6135](https://github.com/rust-lang/rust-clippy/pull/6135)
 +* [`result_unit_err`] [#6157](https://github.com/rust-lang/rust-clippy/pull/6157)
 +* [`ref_option_ref`] [#6165](https://github.com/rust-lang/rust-clippy/pull/6165)
 +* [`manual_range_contains`] [#6177](https://github.com/rust-lang/rust-clippy/pull/6177)
 +* [`unusual_byte_groupings`] [#6183](https://github.com/rust-lang/rust-clippy/pull/6183)
 +* [`comparison_to_empty`] [#6226](https://github.com/rust-lang/rust-clippy/pull/6226)
 +* [`map_collect_result_unit`] [#6227](https://github.com/rust-lang/rust-clippy/pull/6227)
 +* [`manual_ok_or`] [#6233](https://github.com/rust-lang/rust-clippy/pull/6233)
 +
 +### Moves and Deprecations
 +
 +* Rename `single_char_push_str` to [`single_char_add_str`]
 +  [#6037](https://github.com/rust-lang/rust-clippy/pull/6037)
 +* Rename `zero_width_space` to [`invisible_characters`]
 +  [#6105](https://github.com/rust-lang/rust-clippy/pull/6105)
 +* Deprecate `drop_bounds` (uplifted)
 +  [#6111](https://github.com/rust-lang/rust-clippy/pull/6111)
 +* Move [`string_lit_as_bytes`] to `nursery`
 +  [#6117](https://github.com/rust-lang/rust-clippy/pull/6117)
 +* Move [`rc_buffer`] to `restriction`
 +  [#6128](https://github.com/rust-lang/rust-clippy/pull/6128)
 +
 +### Enhancements
 +
 +* [`manual_memcpy`]: Also lint when there are loop counters (and produce a
 +  reliable suggestion)
 +  [#5727](https://github.com/rust-lang/rust-clippy/pull/5727)
 +* [`single_char_add_str`]: Also lint on `String::insert_str`
 +  [#6037](https://github.com/rust-lang/rust-clippy/pull/6037)
 +* [`invisible_characters`]: Also lint the characters `\u{AD}` and `\u{2060}`
 +  [#6105](https://github.com/rust-lang/rust-clippy/pull/6105)
 +* [`eq_op`]: Also lint on the `assert_*!` macro family
 +  [#6167](https://github.com/rust-lang/rust-clippy/pull/6167)
 +* [`items_after_statements`]: Also lint in local macro expansions
 +  [#6176](https://github.com/rust-lang/rust-clippy/pull/6176)
 +* [`unnecessary_cast`]: Also lint casts on integer and float literals
 +  [#6187](https://github.com/rust-lang/rust-clippy/pull/6187)
 +* [`manual_unwrap_or`]: Also lint `Result::unwrap_or`
 +  [#6190](https://github.com/rust-lang/rust-clippy/pull/6190)
 +* [`match_like_matches_macro`]: Also lint when `match` has more than two arms
 +  [#6216](https://github.com/rust-lang/rust-clippy/pull/6216)
 +* [`integer_arithmetic`]: Better handle `/` an `%` operators
 +  [#6229](https://github.com/rust-lang/rust-clippy/pull/6229)
 +
 +### False Positive Fixes
 +
 +* [`needless_lifetimes`]: Bail out if the function has a `where` clause with the
 +  lifetime [#5978](https://github.com/rust-lang/rust-clippy/pull/5978)
 +* [`explicit_counter_loop`]: No longer lints, when loop counter is used after it
 +  is incremented [#6076](https://github.com/rust-lang/rust-clippy/pull/6076)
 +* [`or_fun_call`]: Revert changes addressing the handling of `const fn`
 +  [#6077](https://github.com/rust-lang/rust-clippy/pull/6077)
 +* [`needless_range_loop`]: No longer lints, when the iterable is used in the
 +  range [#6102](https://github.com/rust-lang/rust-clippy/pull/6102)
 +* [`inconsistent_digit_grouping`]: Fix bug when using floating point exponent
 +  [#6104](https://github.com/rust-lang/rust-clippy/pull/6104)
 +* [`mistyped_literal_suffixes`]: No longer lints on the fractional part of a
 +  float (e.g. `713.32_64`)
 +  [#6114](https://github.com/rust-lang/rust-clippy/pull/6114)
 +* [`invalid_regex`]: No longer lint on unicode characters within `bytes::Regex`
 +  [#6132](https://github.com/rust-lang/rust-clippy/pull/6132)
 +* [`boxed_local`]: No longer lints on `extern fn` arguments
 +  [#6133](https://github.com/rust-lang/rust-clippy/pull/6133)
 +* [`needless_lifetimes`]: Fix regression, where lifetime is used in `where`
 +  clause [#6198](https://github.com/rust-lang/rust-clippy/pull/6198)
 +
 +### Suggestion Fixes/Improvements
 +
 +* [`unnecessary_sort_by`]: Avoid dereferencing the suggested closure parameter
 +  [#6078](https://github.com/rust-lang/rust-clippy/pull/6078)
 +* [`needless_arbitrary_self_type`]: Correctly handle expanded code
 +  [#6093](https://github.com/rust-lang/rust-clippy/pull/6093)
 +* [`useless_format`]: Preserve raw strings in suggestion
 +  [#6151](https://github.com/rust-lang/rust-clippy/pull/6151)
 +* [`empty_loop`]: Suggest alternatives
 +  [#6162](https://github.com/rust-lang/rust-clippy/pull/6162)
 +* [`borrowed_box`]: Correctly add parentheses in suggestion
 +  [#6200](https://github.com/rust-lang/rust-clippy/pull/6200)
 +* [`unused_unit`]: Improve suggestion formatting
 +  [#6247](https://github.com/rust-lang/rust-clippy/pull/6247)
 +
 +### Documentation Improvements
 +
 +* Some doc improvements:
 +    * [`rc_buffer`] [#6090](https://github.com/rust-lang/rust-clippy/pull/6090)
 +    * [`empty_loop`] [#6162](https://github.com/rust-lang/rust-clippy/pull/6162)
 +* [`doc_markdown`]: Document problematic link text style
 +  [#6107](https://github.com/rust-lang/rust-clippy/pull/6107)
 +
 +## Rust 1.48
 +
 +Released 2020-11-19
 +
 +[09bd400...e636b88](https://github.com/rust-lang/rust-clippy/compare/09bd400...e636b88)
 +
 +### New lints
 +
 +* [`self_assignment`] [#5894](https://github.com/rust-lang/rust-clippy/pull/5894)
 +* [`unnecessary_lazy_evaluations`] [#5720](https://github.com/rust-lang/rust-clippy/pull/5720)
 +* [`manual_strip`] [#6038](https://github.com/rust-lang/rust-clippy/pull/6038)
 +* [`map_err_ignore`] [#5998](https://github.com/rust-lang/rust-clippy/pull/5998)
 +* [`rc_buffer`] [#6044](https://github.com/rust-lang/rust-clippy/pull/6044)
 +* [`to_string_in_display`] [#5831](https://github.com/rust-lang/rust-clippy/pull/5831)
 +* `single_char_push_str` [#5881](https://github.com/rust-lang/rust-clippy/pull/5881)
 +
 +### Moves and Deprecations
 +
 +* Downgrade [`verbose_bit_mask`] to pedantic
 +  [#6036](https://github.com/rust-lang/rust-clippy/pull/6036)
 +
 +### Enhancements
 +
 +* Extend [`precedence`] to handle chains of methods combined with unary negation
 +  [#5928](https://github.com/rust-lang/rust-clippy/pull/5928)
 +* [`useless_vec`]: add a configuration value for the maximum allowed size on the stack
 +  [#5907](https://github.com/rust-lang/rust-clippy/pull/5907)
 +* [`suspicious_arithmetic_impl`]: extend to implementations of `BitAnd`, `BitOr`, `BitXor`, `Rem`, `Shl`, and `Shr`
 +  [#5884](https://github.com/rust-lang/rust-clippy/pull/5884)
 +* `invalid_atomic_ordering`: detect misuse of `compare_exchange`, `compare_exchange_weak`, and `fetch_update`
 +  [#6025](https://github.com/rust-lang/rust-clippy/pull/6025)
 +* Avoid [`redundant_pattern_matching`] triggering in macros
 +  [#6069](https://github.com/rust-lang/rust-clippy/pull/6069)
 +* [`option_if_let_else`]: distinguish pure from impure `else` expressions
 +  [#5937](https://github.com/rust-lang/rust-clippy/pull/5937)
 +* [`needless_doctest_main`]: parse doctests instead of using textual search
 +  [#5912](https://github.com/rust-lang/rust-clippy/pull/5912)
 +* [`wildcard_imports`]: allow `prelude` to appear in any segment of an import
 +  [#5929](https://github.com/rust-lang/rust-clippy/pull/5929)
 +* Re-enable [`len_zero`] for ranges now that `range_is_empty` is stable
 +  [#5961](https://github.com/rust-lang/rust-clippy/pull/5961)
 +* [`option_as_ref_deref`]: catch fully-qualified calls to `Deref::deref` and `DerefMut::deref_mut`
 +  [#5933](https://github.com/rust-lang/rust-clippy/pull/5933)
 +
 +### False Positive Fixes
 +
 +* [`useless_attribute`]: permit allowing [`wildcard_imports`] and [`enum_glob_use`]
 +  [#5994](https://github.com/rust-lang/rust-clippy/pull/5994)
 +* [`transmute_ptr_to_ptr`]: avoid suggesting dereferencing raw pointers in const contexts
 +  [#5999](https://github.com/rust-lang/rust-clippy/pull/5999)
 +* [`redundant_closure_call`]: take into account usages of the closure in nested functions and closures
 +  [#5920](https://github.com/rust-lang/rust-clippy/pull/5920)
 +* Fix false positive in [`borrow_interior_mutable_const`] when referencing a field behind a pointer
 +  [#5949](https://github.com/rust-lang/rust-clippy/pull/5949)
 +* [`doc_markdown`]: allow using "GraphQL" without backticks
 +  [#5996](https://github.com/rust-lang/rust-clippy/pull/5996)
 +* [`to_string_in_display`]: avoid linting when calling `to_string()` on anything that is not `self`
 +  [#5971](https://github.com/rust-lang/rust-clippy/pull/5971)
 +* [`indexing_slicing`] and [`out_of_bounds_indexing`] treat references to arrays as arrays
 +  [#6034](https://github.com/rust-lang/rust-clippy/pull/6034)
 +* [`should_implement_trait`]: ignore methods with lifetime parameters
 +  [#5725](https://github.com/rust-lang/rust-clippy/pull/5725)
 +* [`needless_return`]: avoid linting if a temporary borrows a local variable
 +  [#5903](https://github.com/rust-lang/rust-clippy/pull/5903)
 +* Restrict [`unnecessary_sort_by`] to non-reference, Copy types
 +  [#6006](https://github.com/rust-lang/rust-clippy/pull/6006)
 +* Avoid suggesting `from_bits`/`to_bits` in const contexts in [`transmute_int_to_float`]
 +  [#5919](https://github.com/rust-lang/rust-clippy/pull/5919)
 +* [`declare_interior_mutable_const`] and [`borrow_interior_mutable_const`]: improve detection of interior mutable types
 +  [#6046](https://github.com/rust-lang/rust-clippy/pull/6046)
 +
 +### Suggestion Fixes/Improvements
 +
 +* [`let_and_return`]: add a cast to the suggestion when the return expression has adjustments
 +  [#5946](https://github.com/rust-lang/rust-clippy/pull/5946)
 +* [`useless_conversion`]: show the type in the error message
 +  [#6035](https://github.com/rust-lang/rust-clippy/pull/6035)
 +* [`unnecessary_mut_passed`]: discriminate between functions and methods in the error message
 +  [#5892](https://github.com/rust-lang/rust-clippy/pull/5892)
 +* [`float_cmp`] and [`float_cmp_const`]: change wording to make margin of error less ambiguous
 +  [#6043](https://github.com/rust-lang/rust-clippy/pull/6043)
 +* [`default_trait_access`]: do not use unnecessary type parameters in the suggestion
 +  [#5993](https://github.com/rust-lang/rust-clippy/pull/5993)
 +* [`collapsible_if`]: don't use expanded code in the suggestion
 +  [#5992](https://github.com/rust-lang/rust-clippy/pull/5992)
 +* Do not suggest empty format strings in [`print_with_newline`] and [`write_with_newline`]
 +  [#6042](https://github.com/rust-lang/rust-clippy/pull/6042)
 +* [`unit_arg`]: improve the readability of the suggestion
 +  [#5931](https://github.com/rust-lang/rust-clippy/pull/5931)
 +* [`stable_sort_primitive`]: print the type that is being sorted in the lint message
 +  [#5935](https://github.com/rust-lang/rust-clippy/pull/5935)
 +* Show line count and max lines in [`too_many_lines`] lint message
 +  [#6009](https://github.com/rust-lang/rust-clippy/pull/6009)
 +* Keep parentheses in the suggestion of [`useless_conversion`] where applicable
 +  [#5900](https://github.com/rust-lang/rust-clippy/pull/5900)
 +* [`option_map_unit_fn`] and [`result_map_unit_fn`]: print the unit type `()` explicitly
 +  [#6024](https://github.com/rust-lang/rust-clippy/pull/6024)
 +* [`redundant_allocation`]: suggest replacing `Rc<Box<T>>` with `Rc<T>`
 +  [#5899](https://github.com/rust-lang/rust-clippy/pull/5899)
 +* Make lint messages adhere to rustc dev guide conventions
 +  [#5893](https://github.com/rust-lang/rust-clippy/pull/5893)
 +
 +### ICE Fixes
 +
 +* Fix ICE in [`repeat_once`]
 +  [#5948](https://github.com/rust-lang/rust-clippy/pull/5948)
 +
 +### Documentation Improvements
 +
 +* [`mutable_key_type`]: explain potential for false positives when the interior mutable type is not accessed in the `Hash` implementation
 +  [#6019](https://github.com/rust-lang/rust-clippy/pull/6019)
 +* [`unnecessary_mut_passed`]: fix typo
 +  [#5913](https://github.com/rust-lang/rust-clippy/pull/5913)
 +* Add example of false positive to [`ptr_arg`] docs.
 +  [#5885](https://github.com/rust-lang/rust-clippy/pull/5885)
 +* [`box_vec`](https://rust-lang.github.io/rust-clippy/master/index.html#box_collection), [`vec_box`] and [`borrowed_box`]: add link to the documentation of `Box`
 +  [#6023](https://github.com/rust-lang/rust-clippy/pull/6023)
 +
 +## Rust 1.47
 +
 +Released 2020-10-08
 +
 +[c2c07fa...09bd400](https://github.com/rust-lang/rust-clippy/compare/c2c07fa...09bd400)
 +
 +### New lints
 +
 +* [`derive_ord_xor_partial_ord`] [#5848](https://github.com/rust-lang/rust-clippy/pull/5848)
 +* [`trait_duplication_in_bounds`] [#5852](https://github.com/rust-lang/rust-clippy/pull/5852)
 +* [`map_identity`] [#5694](https://github.com/rust-lang/rust-clippy/pull/5694)
 +* [`unit_return_expecting_ord`] [#5737](https://github.com/rust-lang/rust-clippy/pull/5737)
 +* [`pattern_type_mismatch`] [#4841](https://github.com/rust-lang/rust-clippy/pull/4841)
 +* [`repeat_once`] [#5773](https://github.com/rust-lang/rust-clippy/pull/5773)
 +* [`same_item_push`] [#5825](https://github.com/rust-lang/rust-clippy/pull/5825)
 +* [`needless_arbitrary_self_type`] [#5869](https://github.com/rust-lang/rust-clippy/pull/5869)
 +* [`match_like_matches_macro`] [#5769](https://github.com/rust-lang/rust-clippy/pull/5769)
 +* [`stable_sort_primitive`] [#5809](https://github.com/rust-lang/rust-clippy/pull/5809)
 +* [`blanket_clippy_restriction_lints`] [#5750](https://github.com/rust-lang/rust-clippy/pull/5750)
 +* [`option_if_let_else`] [#5301](https://github.com/rust-lang/rust-clippy/pull/5301)
 +
 +### Moves and Deprecations
 +
 +* Deprecate [`regex_macro`] lint
 +  [#5760](https://github.com/rust-lang/rust-clippy/pull/5760)
 +* Move [`range_minus_one`] to `pedantic`
 +  [#5752](https://github.com/rust-lang/rust-clippy/pull/5752)
 +
 +### Enhancements
 +
 +* Improve [`needless_collect`] by catching `collect` calls followed by `iter` or `into_iter` calls
 +  [#5837](https://github.com/rust-lang/rust-clippy/pull/5837)
 +* [`panic`], [`todo`], [`unimplemented`] and [`unreachable`] now detect calls with formatting
 +  [#5811](https://github.com/rust-lang/rust-clippy/pull/5811)
 +* Detect more cases of [`suboptimal_flops`] and [`imprecise_flops`]
 +  [#5443](https://github.com/rust-lang/rust-clippy/pull/5443)
 +* Handle asymmetrical implementations of `PartialEq` in [`cmp_owned`]
 +  [#5701](https://github.com/rust-lang/rust-clippy/pull/5701)
 +* Make it possible to allow [`unsafe_derive_deserialize`]
 +  [#5870](https://github.com/rust-lang/rust-clippy/pull/5870)
 +* Catch `ord.min(a).max(b)` where a < b in [`min_max`]
 +  [#5871](https://github.com/rust-lang/rust-clippy/pull/5871)
 +* Make [`clone_on_copy`] suggestion machine applicable
 +  [#5745](https://github.com/rust-lang/rust-clippy/pull/5745)
 +* Enable [`len_zero`] on ranges now that `is_empty` is stable on them
 +  [#5961](https://github.com/rust-lang/rust-clippy/pull/5961)
 +
 +### False Positive Fixes
 +
 +* Avoid triggering [`or_fun_call`] with const fns that take no arguments
 +  [#5889](https://github.com/rust-lang/rust-clippy/pull/5889)
 +* Fix [`redundant_closure_call`] false positive for closures that have multiple calls
 +  [#5800](https://github.com/rust-lang/rust-clippy/pull/5800)
 +* Don't lint cases involving `ManuallyDrop` in [`redundant_clone`]
 +  [#5824](https://github.com/rust-lang/rust-clippy/pull/5824)
 +* Treat a single expression the same as a single statement in the 2nd arm of a match in [`single_match_else`]
 +  [#5771](https://github.com/rust-lang/rust-clippy/pull/5771)
 +* Don't trigger [`unnested_or_patterns`] if the feature `or_patterns` is not enabled
 +  [#5758](https://github.com/rust-lang/rust-clippy/pull/5758)
 +* Avoid linting if key borrows in [`unnecessary_sort_by`]
 +  [#5756](https://github.com/rust-lang/rust-clippy/pull/5756)
 +* Consider `Try` impl for `Poll` when generating suggestions in [`try_err`]
 +  [#5857](https://github.com/rust-lang/rust-clippy/pull/5857)
 +* Take input lifetimes into account in `manual_async_fn`
 +  [#5859](https://github.com/rust-lang/rust-clippy/pull/5859)
 +* Fix multiple false positives in [`type_repetition_in_bounds`] and add a configuration option
 +  [#5761](https://github.com/rust-lang/rust-clippy/pull/5761)
 +* Limit the [`suspicious_arithmetic_impl`] lint to one binary operation
 +  [#5820](https://github.com/rust-lang/rust-clippy/pull/5820)
 +
 +### Suggestion Fixes/Improvements
 +
 +* Improve readability of [`shadow_unrelated`] suggestion by truncating the RHS snippet
 +  [#5788](https://github.com/rust-lang/rust-clippy/pull/5788)
 +* Suggest `filter_map` instead of `flat_map` when mapping to `Option` in [`map_flatten`]
 +  [#5846](https://github.com/rust-lang/rust-clippy/pull/5846)
 +* Ensure suggestion is shown correctly for long method call chains in [`iter_nth_zero`]
 +  [#5793](https://github.com/rust-lang/rust-clippy/pull/5793)
 +* Drop borrow operator in suggestions of [`redundant_pattern_matching`]
 +  [#5815](https://github.com/rust-lang/rust-clippy/pull/5815)
 +* Add suggestion for [`iter_skip_next`]
 +  [#5843](https://github.com/rust-lang/rust-clippy/pull/5843)
 +* Improve [`collapsible_if`] fix suggestion
 +  [#5732](https://github.com/rust-lang/rust-clippy/pull/5732)
 +
 +### ICE Fixes
 +
 +* Fix ICE caused by [`needless_collect`]
 +  [#5877](https://github.com/rust-lang/rust-clippy/pull/5877)
 +* Fix ICE caused by [`unnested_or_patterns`]
 +  [#5784](https://github.com/rust-lang/rust-clippy/pull/5784)
 +
 +### Documentation Improvements
 +
 +* Fix grammar of [`await_holding_lock`] documentation
 +  [#5748](https://github.com/rust-lang/rust-clippy/pull/5748)
 +
 +### Others
 +
 +* Make lints adhere to the rustc dev guide
 +  [#5888](https://github.com/rust-lang/rust-clippy/pull/5888)
 +
 +## Rust 1.46
 +
 +Released 2020-08-27
 +
 +[7ea7cd1...c2c07fa](https://github.com/rust-lang/rust-clippy/compare/7ea7cd1...c2c07fa)
 +
 +### New lints
 +
 +* [`unnested_or_patterns`] [#5378](https://github.com/rust-lang/rust-clippy/pull/5378)
 +* [`iter_next_slice`] [#5597](https://github.com/rust-lang/rust-clippy/pull/5597)
 +* [`unnecessary_sort_by`] [#5623](https://github.com/rust-lang/rust-clippy/pull/5623)
 +* [`vec_resize_to_zero`] [#5637](https://github.com/rust-lang/rust-clippy/pull/5637)
 +
 +### Moves and Deprecations
 +
 +* Move [`cast_ptr_alignment`] to pedantic [#5667](https://github.com/rust-lang/rust-clippy/pull/5667)
 +
 +### Enhancements
 +
 +* Improve [`mem_replace_with_uninit`] lint [#5695](https://github.com/rust-lang/rust-clippy/pull/5695)
 +
 +### False Positive Fixes
 +
 +* [`len_zero`]: Avoid linting ranges when the `range_is_empty` feature is not enabled
 +  [#5656](https://github.com/rust-lang/rust-clippy/pull/5656)
 +* [`let_and_return`]: Don't lint if a temporary borrow is involved
 +  [#5680](https://github.com/rust-lang/rust-clippy/pull/5680)
 +* [`reversed_empty_ranges`]: Avoid linting `N..N` in for loop arguments in
 +  [#5692](https://github.com/rust-lang/rust-clippy/pull/5692)
 +* [`if_same_then_else`]: Don't assume multiplication is always commutative
 +  [#5702](https://github.com/rust-lang/rust-clippy/pull/5702)
 +* [`blacklisted_name`]: Remove `bar` from the default configuration
 +  [#5712](https://github.com/rust-lang/rust-clippy/pull/5712)
 +* [`redundant_pattern_matching`]: Avoid suggesting non-`const fn` calls in const contexts
 +  [#5724](https://github.com/rust-lang/rust-clippy/pull/5724)
 +
 +### Suggestion Fixes/Improvements
 +
 +* Fix suggestion of [`unit_arg`] lint, so that it suggest semantic equivalent code
 +  [#4455](https://github.com/rust-lang/rust-clippy/pull/4455)
 +* Add auto applicable suggestion to [`macro_use_imports`]
 +  [#5279](https://github.com/rust-lang/rust-clippy/pull/5279)
 +
 +### ICE Fixes
 +
 +* Fix ICE in the `consts` module of Clippy [#5709](https://github.com/rust-lang/rust-clippy/pull/5709)
 +
 +### Documentation Improvements
 +
 +* Improve code examples across multiple lints [#5664](https://github.com/rust-lang/rust-clippy/pull/5664)
 +
 +### Others
 +
 +* Introduce a `--rustc` flag to `clippy-driver`, which turns `clippy-driver`
 +  into `rustc` and passes all the given arguments to `rustc`. This is especially
 +  useful for tools that need the `rustc` version Clippy was compiled with,
 +  instead of the Clippy version. E.g. `clippy-driver --rustc --version` will
 +  print the output of `rustc --version`.
 +  [#5178](https://github.com/rust-lang/rust-clippy/pull/5178)
 +* New issue templates now make it easier to complain if Clippy is too annoying
 +  or not annoying enough! [#5735](https://github.com/rust-lang/rust-clippy/pull/5735)
 +
 +## Rust 1.45
 +
 +Released 2020-07-16
 +
 +[891e1a8...7ea7cd1](https://github.com/rust-lang/rust-clippy/compare/891e1a8...7ea7cd1)
 +
 +### New lints
 +
 +* [`match_wildcard_for_single_variants`] [#5582](https://github.com/rust-lang/rust-clippy/pull/5582)
 +* [`unsafe_derive_deserialize`] [#5493](https://github.com/rust-lang/rust-clippy/pull/5493)
 +* [`if_let_mutex`] [#5332](https://github.com/rust-lang/rust-clippy/pull/5332)
 +* [`mismatched_target_os`] [#5506](https://github.com/rust-lang/rust-clippy/pull/5506)
 +* [`await_holding_lock`] [#5439](https://github.com/rust-lang/rust-clippy/pull/5439)
 +* [`match_on_vec_items`] [#5522](https://github.com/rust-lang/rust-clippy/pull/5522)
 +* [`manual_async_fn`] [#5576](https://github.com/rust-lang/rust-clippy/pull/5576)
 +* [`reversed_empty_ranges`] [#5583](https://github.com/rust-lang/rust-clippy/pull/5583)
 +* [`manual_non_exhaustive`] [#5550](https://github.com/rust-lang/rust-clippy/pull/5550)
 +
 +### Moves and Deprecations
 +
 +* Downgrade [`match_bool`] to pedantic [#5408](https://github.com/rust-lang/rust-clippy/pull/5408)
 +* Downgrade [`match_wild_err_arm`] to pedantic and update help messages. [#5622](https://github.com/rust-lang/rust-clippy/pull/5622)
 +* Downgrade [`useless_let_if_seq`] to nursery. [#5599](https://github.com/rust-lang/rust-clippy/pull/5599)
 +* Generalize `option_and_then_some` and rename to [`bind_instead_of_map`]. [#5529](https://github.com/rust-lang/rust-clippy/pull/5529)
 +* Rename `identity_conversion` to [`useless_conversion`]. [#5568](https://github.com/rust-lang/rust-clippy/pull/5568)
 +* Merge `block_in_if_condition_expr` and `block_in_if_condition_stmt` into [`blocks_in_if_conditions`].
 +[#5563](https://github.com/rust-lang/rust-clippy/pull/5563)
 +* Merge `option_map_unwrap_or`, `option_map_unwrap_or_else` and `result_map_unwrap_or_else` into [`map_unwrap_or`].
 +[#5563](https://github.com/rust-lang/rust-clippy/pull/5563)
 +* Merge `option_unwrap_used` and `result_unwrap_used` into [`unwrap_used`].
 +[#5563](https://github.com/rust-lang/rust-clippy/pull/5563)
 +* Merge `option_expect_used` and `result_expect_used` into [`expect_used`].
 +[#5563](https://github.com/rust-lang/rust-clippy/pull/5563)
 +* Merge `for_loop_over_option` and `for_loop_over_result` into [`for_loops_over_fallibles`].
 +[#5563](https://github.com/rust-lang/rust-clippy/pull/5563)
 +
 +### Enhancements
 +
 +* Avoid running cargo lints when not enabled to improve performance. [#5505](https://github.com/rust-lang/rust-clippy/pull/5505)
 +* Extend [`useless_conversion`] with `TryFrom` and `TryInto`. [#5631](https://github.com/rust-lang/rust-clippy/pull/5631)
 +* Lint also in type parameters and where clauses in [`unused_unit`]. [#5592](https://github.com/rust-lang/rust-clippy/pull/5592)
 +* Do not suggest deriving `Default` in [`new_without_default`]. [#5616](https://github.com/rust-lang/rust-clippy/pull/5616)
 +
 +### False Positive Fixes
 +
 +* [`while_let_on_iterator`] [#5525](https://github.com/rust-lang/rust-clippy/pull/5525)
 +* [`empty_line_after_outer_attr`] [#5609](https://github.com/rust-lang/rust-clippy/pull/5609)
 +* [`unnecessary_unwrap`] [#5558](https://github.com/rust-lang/rust-clippy/pull/5558)
 +* [`comparison_chain`] [#5596](https://github.com/rust-lang/rust-clippy/pull/5596)
 +* Don't trigger [`used_underscore_binding`] in await desugaring. [#5535](https://github.com/rust-lang/rust-clippy/pull/5535)
 +* Don't trigger [`borrowed_box`] on mutable references. [#5491](https://github.com/rust-lang/rust-clippy/pull/5491)
 +* Allow `1 << 0` in [`identity_op`]. [#5602](https://github.com/rust-lang/rust-clippy/pull/5602)
 +* Allow `use super::*;` glob imports in [`wildcard_imports`]. [#5564](https://github.com/rust-lang/rust-clippy/pull/5564)
 +* Whitelist more words in [`doc_markdown`]. [#5611](https://github.com/rust-lang/rust-clippy/pull/5611)
 +* Skip dev and build deps in [`multiple_crate_versions`]. [#5636](https://github.com/rust-lang/rust-clippy/pull/5636)
 +* Honor `allow` attribute on arguments in [`ptr_arg`]. [#5647](https://github.com/rust-lang/rust-clippy/pull/5647)
 +* Honor lint level attributes for [`redundant_field_names`], [`just_underscores_and_digits`], [`many_single_char_names`]
 +and [`similar_names`]. [#5651](https://github.com/rust-lang/rust-clippy/pull/5651)
 +* Ignore calls to `len` in [`or_fun_call`]. [#4429](https://github.com/rust-lang/rust-clippy/pull/4429)
 +
 +### Suggestion Improvements
 +
 +* Simplify suggestions in [`manual_memcpy`]. [#5536](https://github.com/rust-lang/rust-clippy/pull/5536)
 +* Fix suggestion in [`redundant_pattern_matching`] for macros. [#5511](https://github.com/rust-lang/rust-clippy/pull/5511)
 +* Avoid suggesting `copied()` for mutable references in [`map_clone`]. [#5530](https://github.com/rust-lang/rust-clippy/pull/5530)
 +* Improve help message for [`clone_double_ref`]. [#5547](https://github.com/rust-lang/rust-clippy/pull/5547)
 +
 +### ICE Fixes
 +
 +* Fix ICE caused in unwrap module. [#5590](https://github.com/rust-lang/rust-clippy/pull/5590)
 +* Fix ICE on rustc test issue-69020-assoc-const-arith-overflow.rs [#5499](https://github.com/rust-lang/rust-clippy/pull/5499)
 +
 +### Documentation
 +
 +* Clarify the documentation of [`unnecessary_mut_passed`]. [#5639](https://github.com/rust-lang/rust-clippy/pull/5639)
 +* Extend example for [`unneeded_field_pattern`]. [#5541](https://github.com/rust-lang/rust-clippy/pull/5541)
 +
 +## Rust 1.44
 +
 +Released 2020-06-04
 +
 +[204bb9b...891e1a8](https://github.com/rust-lang/rust-clippy/compare/204bb9b...891e1a8)
 +
 +### New lints
 +
 +* [`explicit_deref_methods`] [#5226](https://github.com/rust-lang/rust-clippy/pull/5226)
 +* [`implicit_saturating_sub`] [#5427](https://github.com/rust-lang/rust-clippy/pull/5427)
 +* [`macro_use_imports`] [#5230](https://github.com/rust-lang/rust-clippy/pull/5230)
 +* [`verbose_file_reads`] [#5272](https://github.com/rust-lang/rust-clippy/pull/5272)
 +* [`future_not_send`] [#5423](https://github.com/rust-lang/rust-clippy/pull/5423)
 +* [`redundant_pub_crate`] [#5319](https://github.com/rust-lang/rust-clippy/pull/5319)
 +* [`large_const_arrays`] [#5248](https://github.com/rust-lang/rust-clippy/pull/5248)
 +* [`result_map_or_into_option`] [#5415](https://github.com/rust-lang/rust-clippy/pull/5415)
 +* [`redundant_allocation`] [#5349](https://github.com/rust-lang/rust-clippy/pull/5349)
 +* [`fn_address_comparisons`] [#5294](https://github.com/rust-lang/rust-clippy/pull/5294)
 +* [`vtable_address_comparisons`] [#5294](https://github.com/rust-lang/rust-clippy/pull/5294)
 +
 +
 +### Moves and Deprecations
 +
 +* Deprecate [`replace_consts`] lint [#5380](https://github.com/rust-lang/rust-clippy/pull/5380)
 +* Move [`cognitive_complexity`] to nursery [#5428](https://github.com/rust-lang/rust-clippy/pull/5428)
 +* Move [`useless_transmute`] to nursery [#5364](https://github.com/rust-lang/rust-clippy/pull/5364)
 +* Downgrade [`inefficient_to_string`] to pedantic [#5412](https://github.com/rust-lang/rust-clippy/pull/5412)
 +* Downgrade [`option_option`] to pedantic [#5401](https://github.com/rust-lang/rust-clippy/pull/5401)
 +* Downgrade [`unreadable_literal`] to pedantic [#5419](https://github.com/rust-lang/rust-clippy/pull/5419)
 +* Downgrade [`let_unit_value`] to pedantic [#5409](https://github.com/rust-lang/rust-clippy/pull/5409)
 +* Downgrade [`trivially_copy_pass_by_ref`] to pedantic [#5410](https://github.com/rust-lang/rust-clippy/pull/5410)
 +* Downgrade [`implicit_hasher`] to pedantic [#5411](https://github.com/rust-lang/rust-clippy/pull/5411)
 +
 +### Enhancements
 +
 +* On _nightly_ you can now use `cargo clippy --fix -Z unstable-options` to
 +  auto-fix lints that support this [#5363](https://github.com/rust-lang/rust-clippy/pull/5363)
 +* Make [`redundant_clone`] also trigger on cases where the cloned value is not
 +  consumed. [#5304](https://github.com/rust-lang/rust-clippy/pull/5304)
 +* Expand [`integer_arithmetic`] to also disallow bit-shifting [#5430](https://github.com/rust-lang/rust-clippy/pull/5430)
 +* [`option_as_ref_deref`] now detects more deref cases [#5425](https://github.com/rust-lang/rust-clippy/pull/5425)
 +* [`large_enum_variant`] now report the sizes of the largest and second-largest variants [#5466](https://github.com/rust-lang/rust-clippy/pull/5466)
 +* [`bool_comparison`] now also checks for inequality comparisons that can be
 +  written more concisely [#5365](https://github.com/rust-lang/rust-clippy/pull/5365)
 +* Expand [`clone_on_copy`] to work in method call arguments as well [#5441](https://github.com/rust-lang/rust-clippy/pull/5441)
 +* [`redundant_pattern_matching`] now also handles `while let` [#5483](https://github.com/rust-lang/rust-clippy/pull/5483)
 +* [`integer_arithmetic`] now also lints references of integers [#5329](https://github.com/rust-lang/rust-clippy/pull/5329)
 +* Expand [`float_cmp_const`] to also work on arrays [#5345](https://github.com/rust-lang/rust-clippy/pull/5345)
 +* Trigger [`map_flatten`] when map is called on an `Option` [#5473](https://github.com/rust-lang/rust-clippy/pull/5473)
 +
 +### False Positive Fixes
 +
 +* [`many_single_char_names`] [#5468](https://github.com/rust-lang/rust-clippy/pull/5468)
 +* [`should_implement_trait`] [#5437](https://github.com/rust-lang/rust-clippy/pull/5437)
 +* [`unused_self`] [#5387](https://github.com/rust-lang/rust-clippy/pull/5387)
 +* [`redundant_clone`] [#5453](https://github.com/rust-lang/rust-clippy/pull/5453)
 +* [`precedence`] [#5445](https://github.com/rust-lang/rust-clippy/pull/5445)
 +* [`suspicious_op_assign_impl`] [#5424](https://github.com/rust-lang/rust-clippy/pull/5424)
 +* [`needless_lifetimes`] [#5293](https://github.com/rust-lang/rust-clippy/pull/5293)
 +* [`redundant_pattern`] [#5287](https://github.com/rust-lang/rust-clippy/pull/5287)
 +* [`inconsistent_digit_grouping`] [#5451](https://github.com/rust-lang/rust-clippy/pull/5451)
 +
 +
 +### Suggestion Improvements
 +
 +* Improved [`question_mark`] lint suggestion so that it doesn't add redundant `as_ref()` [#5481](https://github.com/rust-lang/rust-clippy/pull/5481)
 +* Improve the suggested placeholder in [`option_map_unit_fn`] [#5292](https://github.com/rust-lang/rust-clippy/pull/5292)
 +* Improve suggestion for [`match_single_binding`] when triggered inside a closure [#5350](https://github.com/rust-lang/rust-clippy/pull/5350)
 +
 +### ICE Fixes
 +
 +* Handle the unstable `trivial_bounds` feature [#5296](https://github.com/rust-lang/rust-clippy/pull/5296)
 +* `shadow_*` lints [#5297](https://github.com/rust-lang/rust-clippy/pull/5297)
 +
 +### Documentation
 +
 +* Fix documentation generation for configurable lints [#5353](https://github.com/rust-lang/rust-clippy/pull/5353)
 +* Update documentation for [`new_ret_no_self`] [#5448](https://github.com/rust-lang/rust-clippy/pull/5448)
 +* The documentation for [`option_option`] now suggest using a tri-state enum [#5403](https://github.com/rust-lang/rust-clippy/pull/5403)
 +* Fix bit mask example in [`verbose_bit_mask`] documentation [#5454](https://github.com/rust-lang/rust-clippy/pull/5454)
 +* [`wildcard_imports`] documentation now mentions that `use ...::prelude::*` is
 +  not linted [#5312](https://github.com/rust-lang/rust-clippy/pull/5312)
 +
 +## Rust 1.43
 +
 +Released 2020-04-23
 +
 +[4ee1206...204bb9b](https://github.com/rust-lang/rust-clippy/compare/4ee1206...204bb9b)
 +
 +### New lints
 +
 +* [`imprecise_flops`] [#4897](https://github.com/rust-lang/rust-clippy/pull/4897)
 +* [`suboptimal_flops`] [#4897](https://github.com/rust-lang/rust-clippy/pull/4897)
 +* [`wildcard_imports`] [#5029](https://github.com/rust-lang/rust-clippy/pull/5029)
 +* [`single_component_path_imports`] [#5058](https://github.com/rust-lang/rust-clippy/pull/5058)
 +* [`match_single_binding`] [#5061](https://github.com/rust-lang/rust-clippy/pull/5061)
 +* [`let_underscore_lock`] [#5101](https://github.com/rust-lang/rust-clippy/pull/5101)
 +* [`struct_excessive_bools`] [#5125](https://github.com/rust-lang/rust-clippy/pull/5125)
 +* [`fn_params_excessive_bools`] [#5125](https://github.com/rust-lang/rust-clippy/pull/5125)
 +* [`option_env_unwrap`] [#5148](https://github.com/rust-lang/rust-clippy/pull/5148)
 +* [`lossy_float_literal`] [#5202](https://github.com/rust-lang/rust-clippy/pull/5202)
 +* [`rest_pat_in_fully_bound_structs`] [#5258](https://github.com/rust-lang/rust-clippy/pull/5258)
 +
 +### Moves and Deprecations
 +
 +* Move [`unneeded_field_pattern`] to pedantic group [#5200](https://github.com/rust-lang/rust-clippy/pull/5200)
 +
 +### Enhancements
 +
 +* Make [`missing_errors_doc`] lint also trigger on `async` functions
 +  [#5181](https://github.com/rust-lang/rust-clippy/pull/5181)
 +* Add more constants to [`approx_constant`] [#5193](https://github.com/rust-lang/rust-clippy/pull/5193)
 +* Extend [`question_mark`] lint [#5266](https://github.com/rust-lang/rust-clippy/pull/5266)
 +
 +### False Positive Fixes
 +
 +* [`use_debug`] [#5047](https://github.com/rust-lang/rust-clippy/pull/5047)
 +* [`unnecessary_unwrap`] [#5132](https://github.com/rust-lang/rust-clippy/pull/5132)
 +* [`zero_prefixed_literal`] [#5170](https://github.com/rust-lang/rust-clippy/pull/5170)
 +* [`missing_const_for_fn`] [#5216](https://github.com/rust-lang/rust-clippy/pull/5216)
 +
 +### Suggestion Improvements
 +
 +* Improve suggestion when blocks of code are suggested [#5134](https://github.com/rust-lang/rust-clippy/pull/5134)
 +
 +### ICE Fixes
 +
 +* `misc_early` lints [#5129](https://github.com/rust-lang/rust-clippy/pull/5129)
 +* [`missing_errors_doc`] [#5213](https://github.com/rust-lang/rust-clippy/pull/5213)
 +* Fix ICE when evaluating `usize`s [#5256](https://github.com/rust-lang/rust-clippy/pull/5256)
 +
 +### Documentation
 +
 +* Improve documentation of [`iter_nth_zero`]
 +* Add documentation pages for stable releases [#5171](https://github.com/rust-lang/rust-clippy/pull/5171)
 +
 +### Others
 +
 +* Clippy now completely runs on GitHub Actions [#5190](https://github.com/rust-lang/rust-clippy/pull/5190)
 +
 +
 +## Rust 1.42
 +
 +Released 2020-03-12
 +
 +[69f99e7...4ee1206](https://github.com/rust-lang/rust-clippy/compare/69f99e7...4ee1206)
 +
 +### New lints
 +
 +* [`filetype_is_file`] [#4543](https://github.com/rust-lang/rust-clippy/pull/4543)
 +* [`let_underscore_must_use`] [#4823](https://github.com/rust-lang/rust-clippy/pull/4823)
 +* [`modulo_arithmetic`] [#4867](https://github.com/rust-lang/rust-clippy/pull/4867)
 +* [`mem_replace_with_default`] [#4881](https://github.com/rust-lang/rust-clippy/pull/4881)
 +* [`mutable_key_type`] [#4885](https://github.com/rust-lang/rust-clippy/pull/4885)
 +* [`option_as_ref_deref`] [#4945](https://github.com/rust-lang/rust-clippy/pull/4945)
 +* [`wildcard_in_or_patterns`] [#4960](https://github.com/rust-lang/rust-clippy/pull/4960)
 +* [`iter_nth_zero`] [#4966](https://github.com/rust-lang/rust-clippy/pull/4966)
 +* `invalid_atomic_ordering` [#4999](https://github.com/rust-lang/rust-clippy/pull/4999)
 +* [`skip_while_next`] [#5067](https://github.com/rust-lang/rust-clippy/pull/5067)
 +
 +### Moves and Deprecations
 +
 +* Move [`transmute_float_to_int`] from nursery to complexity group
 +  [#5015](https://github.com/rust-lang/rust-clippy/pull/5015)
 +* Move [`range_plus_one`] to pedantic group [#5057](https://github.com/rust-lang/rust-clippy/pull/5057)
 +* Move [`debug_assert_with_mut_call`] to nursery group [#5106](https://github.com/rust-lang/rust-clippy/pull/5106)
 +* Deprecate `unused_label` [#4930](https://github.com/rust-lang/rust-clippy/pull/4930)
 +
 +### Enhancements
 +
 +* Lint vectored IO in [`unused_io_amount`] [#5027](https://github.com/rust-lang/rust-clippy/pull/5027)
 +* Make [`vec_box`] configurable by adding a size threshold [#5081](https://github.com/rust-lang/rust-clippy/pull/5081)
 +* Also lint constants in [`cmp_nan`] [#4910](https://github.com/rust-lang/rust-clippy/pull/4910)
 +* Fix false negative in [`expect_fun_call`] [#4915](https://github.com/rust-lang/rust-clippy/pull/4915)
 +* Fix false negative in [`redundant_clone`] [#5017](https://github.com/rust-lang/rust-clippy/pull/5017)
 +
 +### False Positive Fixes
 +
 +* [`map_clone`] [#4937](https://github.com/rust-lang/rust-clippy/pull/4937)
 +* [`replace_consts`] [#4977](https://github.com/rust-lang/rust-clippy/pull/4977)
 +* [`let_and_return`] [#5008](https://github.com/rust-lang/rust-clippy/pull/5008)
 +* [`eq_op`] [#5079](https://github.com/rust-lang/rust-clippy/pull/5079)
 +* [`possible_missing_comma`] [#5083](https://github.com/rust-lang/rust-clippy/pull/5083)
 +* [`debug_assert_with_mut_call`] [#5106](https://github.com/rust-lang/rust-clippy/pull/5106)
 +* Don't trigger [`let_underscore_must_use`] in external macros
 +  [#5082](https://github.com/rust-lang/rust-clippy/pull/5082)
 +* Don't trigger [`empty_loop`] in `no_std` crates [#5086](https://github.com/rust-lang/rust-clippy/pull/5086)
 +
 +### Suggestion Improvements
 +
 +* `option_map_unwrap_or` [#4634](https://github.com/rust-lang/rust-clippy/pull/4634)
 +* [`wildcard_enum_match_arm`] [#4934](https://github.com/rust-lang/rust-clippy/pull/4934)
 +* [`cognitive_complexity`] [#4935](https://github.com/rust-lang/rust-clippy/pull/4935)
 +* [`decimal_literal_representation`] [#4956](https://github.com/rust-lang/rust-clippy/pull/4956)
 +* `unknown_clippy_lints` [#4963](https://github.com/rust-lang/rust-clippy/pull/4963)
 +* [`explicit_into_iter_loop`] [#4978](https://github.com/rust-lang/rust-clippy/pull/4978)
 +* [`useless_attribute`] [#5022](https://github.com/rust-lang/rust-clippy/pull/5022)
 +* `if_let_some_result` [#5032](https://github.com/rust-lang/rust-clippy/pull/5032)
 +
 +### ICE fixes
 +
 +* [`unsound_collection_transmute`] [#4975](https://github.com/rust-lang/rust-clippy/pull/4975)
 +
 +### Documentation
 +
 +* Improve documentation of [`empty_enum`], [`replace_consts`], [`redundant_clone`], and [`iterator_step_by_zero`]
 +
 +
 +## Rust 1.41
 +
 +Released 2020-01-30
 +
 +[c8e3cfb...69f99e7](https://github.com/rust-lang/rust-clippy/compare/c8e3cfb...69f99e7)
 +
 +* New Lints:
 +  * [`exit`] [#4697](https://github.com/rust-lang/rust-clippy/pull/4697)
 +  * [`to_digit_is_some`] [#4801](https://github.com/rust-lang/rust-clippy/pull/4801)
 +  * [`tabs_in_doc_comments`] [#4806](https://github.com/rust-lang/rust-clippy/pull/4806)
 +  * [`large_stack_arrays`] [#4807](https://github.com/rust-lang/rust-clippy/pull/4807)
 +  * [`same_functions_in_if_condition`] [#4814](https://github.com/rust-lang/rust-clippy/pull/4814)
 +  * [`zst_offset`] [#4816](https://github.com/rust-lang/rust-clippy/pull/4816)
 +  * [`as_conversions`] [#4821](https://github.com/rust-lang/rust-clippy/pull/4821)
 +  * [`missing_errors_doc`] [#4884](https://github.com/rust-lang/rust-clippy/pull/4884)
 +  * [`transmute_float_to_int`] [#4889](https://github.com/rust-lang/rust-clippy/pull/4889)
 +* Remove plugin interface, see
 +  [Inside Rust Blog](https://blog.rust-lang.org/inside-rust/2019/11/04/Clippy-removes-plugin-interface.html) for
 +  details [#4714](https://github.com/rust-lang/rust-clippy/pull/4714)
 +* Move [`use_self`] to nursery group [#4863](https://github.com/rust-lang/rust-clippy/pull/4863)
 +* Deprecate `into_iter_on_array` [#4788](https://github.com/rust-lang/rust-clippy/pull/4788)
 +* Expand [`string_lit_as_bytes`] to also trigger when literal has escapes
 +  [#4808](https://github.com/rust-lang/rust-clippy/pull/4808)
 +* Fix false positive in `comparison_chain` [#4842](https://github.com/rust-lang/rust-clippy/pull/4842)
 +* Fix false positive in `while_immutable_condition` [#4730](https://github.com/rust-lang/rust-clippy/pull/4730)
 +* Fix false positive in `explicit_counter_loop` [#4803](https://github.com/rust-lang/rust-clippy/pull/4803)
 +* Fix false positive in `must_use_candidate` [#4794](https://github.com/rust-lang/rust-clippy/pull/4794)
 +* Fix false positive in `print_with_newline` and `write_with_newline`
 +  [#4769](https://github.com/rust-lang/rust-clippy/pull/4769)
 +* Fix false positive in `derive_hash_xor_eq` [#4766](https://github.com/rust-lang/rust-clippy/pull/4766)
 +* Fix false positive in `missing_inline_in_public_items` [#4870](https://github.com/rust-lang/rust-clippy/pull/4870)
 +* Fix false positive in `string_add` [#4880](https://github.com/rust-lang/rust-clippy/pull/4880)
 +* Fix false positive in `float_arithmetic` [#4851](https://github.com/rust-lang/rust-clippy/pull/4851)
 +* Fix false positive in `cast_sign_loss` [#4883](https://github.com/rust-lang/rust-clippy/pull/4883)
 +* Fix false positive in `manual_swap` [#4877](https://github.com/rust-lang/rust-clippy/pull/4877)
 +* Fix ICEs occurring while checking some block expressions [#4772](https://github.com/rust-lang/rust-clippy/pull/4772)
 +* Fix ICE in `use_self` [#4776](https://github.com/rust-lang/rust-clippy/pull/4776)
 +* Fix ICEs related to `const_generics` [#4780](https://github.com/rust-lang/rust-clippy/pull/4780)
 +* Display help when running `clippy-driver` without arguments, instead of ICEing
 +  [#4810](https://github.com/rust-lang/rust-clippy/pull/4810)
 +* Clippy has its own ICE message now [#4588](https://github.com/rust-lang/rust-clippy/pull/4588)
 +* Show deprecated lints in the documentation again [#4757](https://github.com/rust-lang/rust-clippy/pull/4757)
 +* Improve Documentation by adding positive examples to some lints
 +  [#4832](https://github.com/rust-lang/rust-clippy/pull/4832)
 +
 +## Rust 1.40
 +
 +Released 2019-12-19
 +
 +[4e7e71b...c8e3cfb](https://github.com/rust-lang/rust-clippy/compare/4e7e71b...c8e3cfb)
 +
 +* New Lints:
 +  * [`unneeded_wildcard_pattern`] [#4537](https://github.com/rust-lang/rust-clippy/pull/4537)
 +  * [`needless_doctest_main`] [#4603](https://github.com/rust-lang/rust-clippy/pull/4603)
 +  * [`suspicious_unary_op_formatting`] [#4615](https://github.com/rust-lang/rust-clippy/pull/4615)
 +  * [`debug_assert_with_mut_call`] [#4680](https://github.com/rust-lang/rust-clippy/pull/4680)
 +  * [`unused_self`] [#4619](https://github.com/rust-lang/rust-clippy/pull/4619)
 +  * [`inefficient_to_string`] [#4683](https://github.com/rust-lang/rust-clippy/pull/4683)
 +  * [`must_use_unit`] [#4560](https://github.com/rust-lang/rust-clippy/pull/4560)
 +  * [`must_use_candidate`] [#4560](https://github.com/rust-lang/rust-clippy/pull/4560)
 +  * [`double_must_use`] [#4560](https://github.com/rust-lang/rust-clippy/pull/4560)
 +  * [`comparison_chain`] [#4569](https://github.com/rust-lang/rust-clippy/pull/4569)
 +  * [`unsound_collection_transmute`] [#4592](https://github.com/rust-lang/rust-clippy/pull/4592)
 +  * [`panic`] [#4657](https://github.com/rust-lang/rust-clippy/pull/4657)
 +  * [`unreachable`] [#4657](https://github.com/rust-lang/rust-clippy/pull/4657)
 +  * [`todo`] [#4657](https://github.com/rust-lang/rust-clippy/pull/4657)
 +  * `option_expect_used` [#4657](https://github.com/rust-lang/rust-clippy/pull/4657)
 +  * `result_expect_used` [#4657](https://github.com/rust-lang/rust-clippy/pull/4657)
 +* Move `redundant_clone` to perf group [#4509](https://github.com/rust-lang/rust-clippy/pull/4509)
 +* Move `manual_mul_add` to nursery group [#4736](https://github.com/rust-lang/rust-clippy/pull/4736)
 +* Expand `unit_cmp` to also work with `assert_eq!`, `debug_assert_eq!`, `assert_ne!` and `debug_assert_ne!` [#4613](https://github.com/rust-lang/rust-clippy/pull/4613)
 +* Expand `integer_arithmetic` to also detect mutating arithmetic like `+=` [#4585](https://github.com/rust-lang/rust-clippy/pull/4585)
 +* Fix false positive in `nonminimal_bool` [#4568](https://github.com/rust-lang/rust-clippy/pull/4568)
 +* Fix false positive in `missing_safety_doc` [#4611](https://github.com/rust-lang/rust-clippy/pull/4611)
 +* Fix false positive in `cast_sign_loss` [#4614](https://github.com/rust-lang/rust-clippy/pull/4614)
 +* Fix false positive in `redundant_clone` [#4509](https://github.com/rust-lang/rust-clippy/pull/4509)
 +* Fix false positive in `try_err` [#4721](https://github.com/rust-lang/rust-clippy/pull/4721)
 +* Fix false positive in `toplevel_ref_arg` [#4570](https://github.com/rust-lang/rust-clippy/pull/4570)
 +* Fix false positive in `multiple_inherent_impl` [#4593](https://github.com/rust-lang/rust-clippy/pull/4593)
 +* Improve more suggestions and tests in preparation for the unstable `cargo fix --clippy` [#4575](https://github.com/rust-lang/rust-clippy/pull/4575)
 +* Improve suggestion for `zero_ptr` [#4599](https://github.com/rust-lang/rust-clippy/pull/4599)
 +* Improve suggestion for `explicit_counter_loop` [#4691](https://github.com/rust-lang/rust-clippy/pull/4691)
 +* Improve suggestion for `mul_add` [#4602](https://github.com/rust-lang/rust-clippy/pull/4602)
 +* Improve suggestion for `assertions_on_constants` [#4635](https://github.com/rust-lang/rust-clippy/pull/4635)
 +* Fix ICE in `use_self` [#4671](https://github.com/rust-lang/rust-clippy/pull/4671)
 +* Fix ICE when encountering const casts [#4590](https://github.com/rust-lang/rust-clippy/pull/4590)
 +
 +## Rust 1.39
 +
 +Released 2019-11-07
 +
 +[3aea860...4e7e71b](https://github.com/rust-lang/rust-clippy/compare/3aea860...4e7e71b)
 +
 +* New Lints:
 +  * [`uninit_assumed_init`] [#4479](https://github.com/rust-lang/rust-clippy/pull/4479)
 +  * [`flat_map_identity`] [#4231](https://github.com/rust-lang/rust-clippy/pull/4231)
 +  * [`missing_safety_doc`] [#4535](https://github.com/rust-lang/rust-clippy/pull/4535)
 +  * [`mem_replace_with_uninit`] [#4511](https://github.com/rust-lang/rust-clippy/pull/4511)
 +  * [`suspicious_map`] [#4394](https://github.com/rust-lang/rust-clippy/pull/4394)
 +  * `option_and_then_some` [#4386](https://github.com/rust-lang/rust-clippy/pull/4386)
 +  * [`manual_saturating_arithmetic`] [#4498](https://github.com/rust-lang/rust-clippy/pull/4498)
 +* Deprecate `unused_collect` lint. This is fully covered by rustc's `#[must_use]` on `collect` [#4348](https://github.com/rust-lang/rust-clippy/pull/4348)
 +* Move `type_repetition_in_bounds` to pedantic group [#4403](https://github.com/rust-lang/rust-clippy/pull/4403)
 +* Move `cast_lossless` to pedantic group [#4539](https://github.com/rust-lang/rust-clippy/pull/4539)
 +* `temporary_cstring_as_ptr` now catches more cases [#4425](https://github.com/rust-lang/rust-clippy/pull/4425)
 +* `use_self` now works in constructors, too [#4525](https://github.com/rust-lang/rust-clippy/pull/4525)
 +* `cargo_common_metadata` now checks for license files [#4518](https://github.com/rust-lang/rust-clippy/pull/4518)
 +* `cognitive_complexity` now includes the measured complexity in the warning message [#4469](https://github.com/rust-lang/rust-clippy/pull/4469)
 +* Fix false positives in `block_in_if_*` lints [#4458](https://github.com/rust-lang/rust-clippy/pull/4458)
 +* Fix false positive in `cast_lossless` [#4473](https://github.com/rust-lang/rust-clippy/pull/4473)
 +* Fix false positive in `clone_on_copy` [#4411](https://github.com/rust-lang/rust-clippy/pull/4411)
 +* Fix false positive in `deref_addrof` [#4487](https://github.com/rust-lang/rust-clippy/pull/4487)
 +* Fix false positive in `too_many_lines` [#4490](https://github.com/rust-lang/rust-clippy/pull/4490)
 +* Fix false positive in `new_ret_no_self` [#4365](https://github.com/rust-lang/rust-clippy/pull/4365)
 +* Fix false positive in `manual_swap` [#4478](https://github.com/rust-lang/rust-clippy/pull/4478)
 +* Fix false positive in `missing_const_for_fn` [#4450](https://github.com/rust-lang/rust-clippy/pull/4450)
 +* Fix false positive in `extra_unused_lifetimes` [#4477](https://github.com/rust-lang/rust-clippy/pull/4477)
 +* Fix false positive in `inherent_to_string` [#4460](https://github.com/rust-lang/rust-clippy/pull/4460)
 +* Fix false positive in `map_entry` [#4495](https://github.com/rust-lang/rust-clippy/pull/4495)
 +* Fix false positive in `unused_unit` [#4445](https://github.com/rust-lang/rust-clippy/pull/4445)
 +* Fix false positive in `redundant_pattern` [#4489](https://github.com/rust-lang/rust-clippy/pull/4489)
 +* Fix false positive in `wrong_self_convention` [#4369](https://github.com/rust-lang/rust-clippy/pull/4369)
 +* Improve various suggestions and tests in preparation for the unstable `cargo fix --clippy` [#4558](https://github.com/rust-lang/rust-clippy/pull/4558)
 +* Improve suggestions for `redundant_pattern_matching` [#4352](https://github.com/rust-lang/rust-clippy/pull/4352)
 +* Improve suggestions for `explicit_write` [#4544](https://github.com/rust-lang/rust-clippy/pull/4544)
 +* Improve suggestion for `or_fun_call` [#4522](https://github.com/rust-lang/rust-clippy/pull/4522)
 +* Improve suggestion for `match_as_ref` [#4446](https://github.com/rust-lang/rust-clippy/pull/4446)
 +* Improve suggestion for `unnecessary_fold_span` [#4382](https://github.com/rust-lang/rust-clippy/pull/4382)
 +* Add suggestions for `unseparated_literal_suffix` [#4401](https://github.com/rust-lang/rust-clippy/pull/4401)
 +* Add suggestions for `char_lit_as_u8` [#4418](https://github.com/rust-lang/rust-clippy/pull/4418)
 +
 +## Rust 1.38
 +
 +Released 2019-09-26
 +
 +[e3cb40e...3aea860](https://github.com/rust-lang/rust-clippy/compare/e3cb40e...3aea860)
 +
 +* New Lints:
 +  * [`main_recursion`] [#4203](https://github.com/rust-lang/rust-clippy/pull/4203)
 +  * [`inherent_to_string`] [#4259](https://github.com/rust-lang/rust-clippy/pull/4259)
 +  * [`inherent_to_string_shadow_display`] [#4259](https://github.com/rust-lang/rust-clippy/pull/4259)
 +  * [`type_repetition_in_bounds`] [#3766](https://github.com/rust-lang/rust-clippy/pull/3766)
 +  * [`try_err`] [#4222](https://github.com/rust-lang/rust-clippy/pull/4222)
 +* Move `{unnnecessary,panicking}_unwrap` out of nursery [#4307](https://github.com/rust-lang/rust-clippy/pull/4307)
 +* Extend the `use_self` lint to suggest uses of `Self::Variant` [#4308](https://github.com/rust-lang/rust-clippy/pull/4308)
 +* Improve suggestion for needless return [#4262](https://github.com/rust-lang/rust-clippy/pull/4262)
 +* Add auto-fixable suggestion for `let_unit` [#4337](https://github.com/rust-lang/rust-clippy/pull/4337)
 +* Fix false positive in `pub_enum_variant_names` and `enum_variant_names` [#4345](https://github.com/rust-lang/rust-clippy/pull/4345)
 +* Fix false positive in `cast_ptr_alignment` [#4257](https://github.com/rust-lang/rust-clippy/pull/4257)
 +* Fix false positive in `string_lit_as_bytes` [#4233](https://github.com/rust-lang/rust-clippy/pull/4233)
 +* Fix false positive in `needless_lifetimes` [#4266](https://github.com/rust-lang/rust-clippy/pull/4266)
 +* Fix false positive in `float_cmp` [#4275](https://github.com/rust-lang/rust-clippy/pull/4275)
 +* Fix false positives in `needless_return` [#4274](https://github.com/rust-lang/rust-clippy/pull/4274)
 +* Fix false negative in `match_same_arms` [#4246](https://github.com/rust-lang/rust-clippy/pull/4246)
 +* Fix incorrect suggestion for `needless_bool` [#4335](https://github.com/rust-lang/rust-clippy/pull/4335)
 +* Improve suggestion for `cast_ptr_alignment` [#4257](https://github.com/rust-lang/rust-clippy/pull/4257)
 +* Improve suggestion for `single_char_literal` [#4361](https://github.com/rust-lang/rust-clippy/pull/4361)
 +* Improve suggestion for `len_zero` [#4314](https://github.com/rust-lang/rust-clippy/pull/4314)
 +* Fix ICE in `implicit_hasher` [#4268](https://github.com/rust-lang/rust-clippy/pull/4268)
 +* Fix allow bug in `trivially_copy_pass_by_ref` [#4250](https://github.com/rust-lang/rust-clippy/pull/4250)
 +
 +## Rust 1.37
 +
 +Released 2019-08-15
 +
 +[082cfa7...e3cb40e](https://github.com/rust-lang/rust-clippy/compare/082cfa7...e3cb40e)
 +
 +* New Lints:
 +  * [`checked_conversions`] [#4088](https://github.com/rust-lang/rust-clippy/pull/4088)
 +  * [`get_last_with_len`] [#3832](https://github.com/rust-lang/rust-clippy/pull/3832)
 +  * [`integer_division`] [#4195](https://github.com/rust-lang/rust-clippy/pull/4195)
 +* Renamed Lint: `const_static_lifetime` is now called [`redundant_static_lifetimes`].
 +  The lint now covers statics in addition to consts [#4162](https://github.com/rust-lang/rust-clippy/pull/4162)
 +* [`match_same_arms`] now warns for all identical arms, instead of only the first one [#4102](https://github.com/rust-lang/rust-clippy/pull/4102)
 +* [`needless_return`] now works with void functions [#4220](https://github.com/rust-lang/rust-clippy/pull/4220)
 +* Fix false positive in [`redundant_closure`] [#4190](https://github.com/rust-lang/rust-clippy/pull/4190)
 +* Fix false positive in [`useless_attribute`] [#4107](https://github.com/rust-lang/rust-clippy/pull/4107)
 +* Fix incorrect suggestion for [`float_cmp`] [#4214](https://github.com/rust-lang/rust-clippy/pull/4214)
 +* Add suggestions for [`print_with_newline`] and [`write_with_newline`] [#4136](https://github.com/rust-lang/rust-clippy/pull/4136)
 +* Improve suggestions for `option_map_unwrap_or_else` and `result_map_unwrap_or_else` [#4164](https://github.com/rust-lang/rust-clippy/pull/4164)
 +* Improve suggestions for [`non_ascii_literal`] [#4119](https://github.com/rust-lang/rust-clippy/pull/4119)
 +* Improve diagnostics for [`let_and_return`] [#4137](https://github.com/rust-lang/rust-clippy/pull/4137)
 +* Improve diagnostics for [`trivially_copy_pass_by_ref`] [#4071](https://github.com/rust-lang/rust-clippy/pull/4071)
 +* Add macro check for [`unreadable_literal`] [#4099](https://github.com/rust-lang/rust-clippy/pull/4099)
 +
 +## Rust 1.36
 +
 +Released 2019-07-04
 +
 +[eb9f9b1...082cfa7](https://github.com/rust-lang/rust-clippy/compare/eb9f9b1...082cfa7)
 +
 +* New lints: [`find_map`], [`filter_map_next`] [#4039](https://github.com/rust-lang/rust-clippy/pull/4039)
 +* New lint: [`path_buf_push_overwrite`] [#3954](https://github.com/rust-lang/rust-clippy/pull/3954)
 +* Move `path_buf_push_overwrite` to the nursery [#4013](https://github.com/rust-lang/rust-clippy/pull/4013)
 +* Split [`redundant_closure`] into [`redundant_closure`] and [`redundant_closure_for_method_calls`] [#4110](https://github.com/rust-lang/rust-clippy/pull/4101)
 +* Allow allowing of [`toplevel_ref_arg`] lint [#4007](https://github.com/rust-lang/rust-clippy/pull/4007)
 +* Fix false negative in [`or_fun_call`] pertaining to nested constructors [#4084](https://github.com/rust-lang/rust-clippy/pull/4084)
 +* Fix false positive in [`or_fun_call`] pertaining to enum variant constructors [#4018](https://github.com/rust-lang/rust-clippy/pull/4018)
 +* Fix false positive in [`useless_let_if_seq`] pertaining to interior mutability [#4035](https://github.com/rust-lang/rust-clippy/pull/4035)
 +* Fix false positive in [`redundant_closure`] pertaining to non-function types [#4008](https://github.com/rust-lang/rust-clippy/pull/4008)
 +* Fix false positive in [`let_and_return`] pertaining to attributes on `let`s [#4024](https://github.com/rust-lang/rust-clippy/pull/4024)
 +* Fix false positive in [`module_name_repetitions`] lint pertaining to attributes [#4006](https://github.com/rust-lang/rust-clippy/pull/4006)
 +* Fix false positive on [`assertions_on_constants`] pertaining to `debug_assert!` [#3989](https://github.com/rust-lang/rust-clippy/pull/3989)
 +* Improve suggestion in [`map_clone`] to suggest `.copied()` where applicable  [#3970](https://github.com/rust-lang/rust-clippy/pull/3970) [#4043](https://github.com/rust-lang/rust-clippy/pull/4043)
 +* Improve suggestion for [`search_is_some`] [#4049](https://github.com/rust-lang/rust-clippy/pull/4049)
 +* Improve suggestion applicability for [`naive_bytecount`] [#3984](https://github.com/rust-lang/rust-clippy/pull/3984)
 +* Improve suggestion applicability for [`while_let_loop`] [#3975](https://github.com/rust-lang/rust-clippy/pull/3975)
 +* Improve diagnostics for [`too_many_arguments`] [#4053](https://github.com/rust-lang/rust-clippy/pull/4053)
 +* Improve diagnostics for [`cast_lossless`] [#4021](https://github.com/rust-lang/rust-clippy/pull/4021)
 +* Deal with macro checks in desugarings better [#4082](https://github.com/rust-lang/rust-clippy/pull/4082)
 +* Add macro check for [`unnecessary_cast`]  [#4026](https://github.com/rust-lang/rust-clippy/pull/4026)
 +* Remove [`approx_constant`]'s documentation's "Known problems" section. [#4027](https://github.com/rust-lang/rust-clippy/pull/4027)
 +* Fix ICE in [`suspicious_else_formatting`] [#3960](https://github.com/rust-lang/rust-clippy/pull/3960)
 +* Fix ICE in [`decimal_literal_representation`] [#3931](https://github.com/rust-lang/rust-clippy/pull/3931)
 +
 +
 +## Rust 1.35
 +
 +Released 2019-05-20
 +
 +[1fac380..37f5c1e](https://github.com/rust-lang/rust-clippy/compare/1fac380...37f5c1e)
 +
 +* New lint: `drop_bounds` to detect `T: Drop` bounds
 +* Split [`redundant_closure`] into [`redundant_closure`] and [`redundant_closure_for_method_calls`] [#4110](https://github.com/rust-lang/rust-clippy/pull/4101)
 +* Rename `cyclomatic_complexity` to [`cognitive_complexity`], start work on making lint more practical for Rust code
 +* Move [`get_unwrap`] to the restriction category
 +* Improve suggestions for [`iter_cloned_collect`]
 +* Improve suggestions for [`cast_lossless`] to suggest suffixed literals
 +* Fix false positives in [`print_with_newline`] and [`write_with_newline`] pertaining to raw strings
 +* Fix false positive in [`needless_range_loop`] pertaining to structs without a `.iter()`
 +* Fix false positive in [`bool_comparison`] pertaining to non-bool types
 +* Fix false positive in [`redundant_closure`] pertaining to differences in borrows
 +* Fix false positive in `option_map_unwrap_or` on non-copy types
 +* Fix false positives in [`missing_const_for_fn`] pertaining to macros and trait method impls
 +* Fix false positive in [`needless_pass_by_value`] pertaining to procedural macros
 +* Fix false positive in [`needless_continue`] pertaining to loop labels
 +* Fix false positive for [`boxed_local`] pertaining to arguments moved into closures
 +* Fix false positive for [`use_self`] in nested functions
 +* Fix suggestion for [`expect_fun_call`] (https://github.com/rust-lang/rust-clippy/pull/3846)
 +* Fix suggestion for [`explicit_counter_loop`] to deal with parenthesizing range variables
 +* Fix suggestion for [`single_char_pattern`] to correctly escape single quotes
 +* Avoid triggering [`redundant_closure`] in macros
 +* ICE fixes: [#3805](https://github.com/rust-lang/rust-clippy/pull/3805), [#3772](https://github.com/rust-lang/rust-clippy/pull/3772), [#3741](https://github.com/rust-lang/rust-clippy/pull/3741)
 +
 +## Rust 1.34
 +
 +Released 2019-04-10
 +
 +[1b89724...1fac380](https://github.com/rust-lang/rust-clippy/compare/1b89724...1fac380)
 +
 +* New lint: [`assertions_on_constants`] to detect for example `assert!(true)`
 +* New lint: [`dbg_macro`] to detect uses of the `dbg!` macro
 +* New lint: [`missing_const_for_fn`] that can suggest functions to be made `const`
 +* New lint: [`too_many_lines`] to detect functions with excessive LOC. It can be
 +  configured using the `too-many-lines-threshold` configuration.
 +* New lint: [`wildcard_enum_match_arm`] to check for wildcard enum matches using `_`
 +* Expand `redundant_closure` to also work for methods (not only functions)
 +* Fix ICEs in `vec_box`, `needless_pass_by_value` and `implicit_hasher`
 +* Fix false positive in `cast_sign_loss`
 +* Fix false positive in `integer_arithmetic`
 +* Fix false positive in `unit_arg`
 +* Fix false positives in `implicit_return`
 +* Add suggestion to `explicit_write`
 +* Improve suggestions for `question_mark` lint
 +* Fix incorrect suggestion for `cast_lossless`
 +* Fix incorrect suggestion for `expect_fun_call`
 +* Fix incorrect suggestion for `needless_bool`
 +* Fix incorrect suggestion for `needless_range_loop`
 +* Fix incorrect suggestion for `use_self`
 +* Fix incorrect suggestion for `while_let_on_iterator`
 +* Clippy is now slightly easier to invoke in non-cargo contexts. See
 +  [#3665][pull3665] for more details.
 +* We now have [improved documentation][adding_lints] on how to add new lints
 +
 +## Rust 1.33
 +
 +Released 2019-02-26
 +
 +[b2601be...1b89724](https://github.com/rust-lang/rust-clippy/compare/b2601be...1b89724)
 +
 +* New lints: [`implicit_return`], [`vec_box`], [`cast_ref_to_mut`]
 +* The `rust-clippy` repository is now part of the `rust-lang` org.
 +* Rename `stutter` to `module_name_repetitions`
 +* Merge `new_without_default_derive` into `new_without_default` lint
 +* Move `large_digit_groups` from `style` group to `pedantic`
 +* Expand `bool_comparison` to check for `<`, `<=`, `>`, `>=`, and `!=`
 +  comparisons against booleans
 +* Expand `no_effect` to detect writes to constants such as `A_CONST.field = 2`
 +* Expand `redundant_clone` to work on struct fields
 +* Expand `suspicious_else_formatting` to detect `if .. {..} {..}`
 +* Expand `use_self` to work on tuple structs and also in local macros
 +* Fix ICE in `result_map_unit_fn` and `option_map_unit_fn`
 +* Fix false positives in `implicit_return`
 +* Fix false positives in `use_self`
 +* Fix false negative in `clone_on_copy`
 +* Fix false positive in `doc_markdown`
 +* Fix false positive in `empty_loop`
 +* Fix false positive in `if_same_then_else`
 +* Fix false positive in `infinite_iter`
 +* Fix false positive in `question_mark`
 +* Fix false positive in `useless_asref`
 +* Fix false positive in `wildcard_dependencies`
 +* Fix false positive in `write_with_newline`
 +* Add suggestion to `explicit_write`
 +* Improve suggestions for `question_mark` lint
 +* Fix incorrect suggestion for `get_unwrap`
 +
 +## Rust 1.32
 +
 +Released 2019-01-17
 +
 +[2e26fdc2...b2601be](https://github.com/rust-lang/rust-clippy/compare/2e26fdc2...b2601be)
 +
 +* New lints: [`slow_vector_initialization`], `mem_discriminant_non_enum`,
 +  [`redundant_clone`], [`wildcard_dependencies`],
 +  [`into_iter_on_ref`], `into_iter_on_array`, [`deprecated_cfg_attr`],
 +  [`cargo_common_metadata`]
 +* Add support for `u128` and `i128` to integer related lints
 +* Add float support to `mistyped_literal_suffixes`
 +* Fix false positives in `use_self`
 +* Fix false positives in `missing_comma`
 +* Fix false positives in `new_ret_no_self`
 +* Fix false positives in `possible_missing_comma`
 +* Fix false positive in `integer_arithmetic` in constant items
 +* Fix false positive in `needless_borrow`
 +* Fix false positive in `out_of_bounds_indexing`
 +* Fix false positive in `new_without_default_derive`
 +* Fix false positive in `string_lit_as_bytes`
 +* Fix false negative in `out_of_bounds_indexing`
 +* Fix false negative in `use_self`. It will now also check existential types
 +* Fix incorrect suggestion for `redundant_closure_call`
 +* Fix various suggestions that contained expanded macros
 +* Fix `bool_comparison` triggering 3 times on on on the same code
 +* Expand `trivially_copy_pass_by_ref` to work on trait methods
 +* Improve suggestion for `needless_range_loop`
 +* Move `needless_pass_by_value` from `pedantic` group to `style`
 +
 +## Rust 1.31
 +
 +Released 2018-12-06
 +
 +[125907ad..2e26fdc2](https://github.com/rust-lang/rust-clippy/compare/125907ad..2e26fdc2)
 +
 +* Clippy has been relicensed under a dual MIT / Apache license.
 +  See [#3093](https://github.com/rust-lang/rust-clippy/issues/3093) for more
 +  information.
 +* With Rust 1.31, Clippy is no longer available via crates.io. The recommended
 +  installation method is via `rustup component add clippy`.
 +* New lints: [`redundant_pattern_matching`], [`unnecessary_filter_map`],
 +  [`unused_unit`], [`map_flatten`], [`mem_replace_option_with_none`]
 +* Fix ICE in `if_let_redundant_pattern_matching`
 +* Fix ICE in `needless_pass_by_value` when encountering a generic function
 +  argument with a lifetime parameter
 +* Fix ICE in `needless_range_loop`
 +* Fix ICE in `single_char_pattern` when encountering a constant value
 +* Fix false positive in `assign_op_pattern`
 +* Fix false positive in `boxed_local` on trait implementations
 +* Fix false positive in `cmp_owned`
 +* Fix false positive in `collapsible_if` when conditionals have comments
 +* Fix false positive in `double_parens`
 +* Fix false positive in `excessive_precision`
 +* Fix false positive in `explicit_counter_loop`
 +* Fix false positive in `fn_to_numeric_cast_with_truncation`
 +* Fix false positive in `map_clone`
 +* Fix false positive in `new_ret_no_self`
 +* Fix false positive in `new_without_default` when `new` is unsafe
 +* Fix false positive in `type_complexity` when using extern types
 +* Fix false positive in `useless_format`
 +* Fix false positive in `wrong_self_convention`
 +* Fix incorrect suggestion for `excessive_precision`
 +* Fix incorrect suggestion for `expect_fun_call`
 +* Fix incorrect suggestion for `get_unwrap`
 +* Fix incorrect suggestion for `useless_format`
 +* `fn_to_numeric_cast_with_truncation` lint can be disabled again
 +* Improve suggestions for `manual_memcpy`
 +* Improve help message for `needless_lifetimes`
 +
 +## Rust 1.30
 +
 +Released 2018-10-25
 +
 +[14207503...125907ad](https://github.com/rust-lang/rust-clippy/compare/14207503...125907ad)
 +
 +* Deprecate `assign_ops` lint
 +* New lints: [`mistyped_literal_suffixes`], [`ptr_offset_with_cast`],
 +  [`needless_collect`], [`copy_iterator`]
 +* `cargo clippy -V` now includes the Clippy commit hash of the Rust
 +  Clippy component
 +* Fix ICE in `implicit_hasher`
 +* Fix ICE when encountering `println!("{}" a);`
 +* Fix ICE when encountering a macro call in match statements
 +* Fix false positive in `default_trait_access`
 +* Fix false positive in `trivially_copy_pass_by_ref`
 +* Fix false positive in `similar_names`
 +* Fix false positive in `redundant_field_name`
 +* Fix false positive in `expect_fun_call`
 +* Fix false negative in `identity_conversion`
 +* Fix false negative in `explicit_counter_loop`
 +* Fix `range_plus_one` suggestion and false negative
 +* `print_with_newline` / `write_with_newline`: don't warn about string with several `\n`s in them
 +* Fix `useless_attribute` to also whitelist `unused_extern_crates`
 +* Fix incorrect suggestion for `single_char_pattern`
 +* Improve suggestion for `identity_conversion` lint
 +* Move `explicit_iter_loop` and `explicit_into_iter_loop` from `style` group to `pedantic`
 +* Move `range_plus_one` and `range_minus_one` from `nursery` group to `complexity`
 +* Move `shadow_unrelated` from `restriction` group to `pedantic`
 +* Move `indexing_slicing` from `pedantic` group to `restriction`
 +
 +## Rust 1.29
 +
 +Released 2018-09-13
 +
 +[v0.0.212...14207503](https://github.com/rust-lang/rust-clippy/compare/v0.0.212...14207503)
 +
 +* :tada: :tada: **Rust 1.29 is the first stable Rust that includes a bundled Clippy** :tada:
 +  :tada:
 +  You can now run `rustup component add clippy-preview` and then `cargo
 +  clippy` to run Clippy. This should put an end to the continuous nightly
 +  upgrades for Clippy users.
 +* Clippy now follows the Rust versioning scheme instead of its own
 +* Fix ICE when encountering a `while let (..) = x.iter()` construct
 +* Fix false positives in `use_self`
 +* Fix false positive in `trivially_copy_pass_by_ref`
 +* Fix false positive in `useless_attribute` lint
 +* Fix false positive in `print_literal`
 +* Fix `use_self` regressions
 +* Improve lint message for `neg_cmp_op_on_partial_ord`
 +* Improve suggestion highlight for `single_char_pattern`
 +* Improve suggestions for various print/write macro lints
 +* Improve website header
 +
 +## 0.0.212 (2018-07-10)
 +* Rustup to *rustc 1.29.0-nightly (e06c87544 2018-07-06)*
 +
 +## 0.0.211
 +* Rustup to *rustc 1.28.0-nightly (e3bf634e0 2018-06-28)*
 +
 +## 0.0.210
 +* Rustup to *rustc 1.28.0-nightly (01cc982e9 2018-06-24)*
 +
 +## 0.0.209
 +* Rustup to *rustc 1.28.0-nightly (523097979 2018-06-18)*
 +
 +## 0.0.208
 +* Rustup to *rustc 1.28.0-nightly (86a8f1a63 2018-06-17)*
 +
 +## 0.0.207
 +* Rustup to *rustc 1.28.0-nightly (2a0062974 2018-06-09)*
 +
 +## 0.0.206
 +* Rustup to *rustc 1.28.0-nightly (5bf68db6e 2018-05-28)*
 +
 +## 0.0.205
 +* Rustup to *rustc 1.28.0-nightly (990d8aa74 2018-05-25)*
 +* Rename `unused_lifetimes` to `extra_unused_lifetimes` because of naming conflict with new rustc lint
 +
 +## 0.0.204
 +* Rustup to *rustc 1.28.0-nightly (71e87be38 2018-05-22)*
 +
 +## 0.0.203
 +* Rustup to *rustc 1.28.0-nightly (a3085756e 2018-05-19)*
 +* Clippy attributes are now of the form `clippy::cyclomatic_complexity` instead of `clippy(cyclomatic_complexity)`
 +
 +## 0.0.202
 +* Rustup to *rustc 1.28.0-nightly (952f344cd 2018-05-18)*
 +
 +## 0.0.201
 +* Rustup to *rustc 1.27.0-nightly (2f2a11dfc 2018-05-16)*
 +
 +## 0.0.200
 +* Rustup to *rustc 1.27.0-nightly (9fae15374 2018-05-13)*
 +
 +## 0.0.199
 +* Rustup to *rustc 1.27.0-nightly (ff2ac35db 2018-05-12)*
 +
 +## 0.0.198
 +* Rustup to *rustc 1.27.0-nightly (acd3871ba 2018-05-10)*
 +
 +## 0.0.197
 +* Rustup to *rustc 1.27.0-nightly (428ea5f6b 2018-05-06)*
 +
 +## 0.0.196
 +* Rustup to *rustc 1.27.0-nightly (e82261dfb 2018-05-03)*
 +
 +## 0.0.195
 +* Rustup to *rustc 1.27.0-nightly (ac3c2288f 2018-04-18)*
 +
 +## 0.0.194
 +* Rustup to *rustc 1.27.0-nightly (bd40cbbe1 2018-04-14)*
 +* New lints: [`cast_ptr_alignment`], [`transmute_ptr_to_ptr`], [`write_literal`], [`write_with_newline`], [`writeln_empty_string`]
 +
 +## 0.0.193
 +* Rustup to *rustc 1.27.0-nightly (eeea94c11 2018-04-06)*
 +
 +## 0.0.192
 +* Rustup to *rustc 1.27.0-nightly (fb44b4c0e 2018-04-04)*
 +* New lint: [`print_literal`]
 +
 +## 0.0.191
 +* Rustup to *rustc 1.26.0-nightly (ae544ee1c 2018-03-29)*
 +* Lint audit; categorize lints as style, correctness, complexity, pedantic, nursery, restriction.
 +
 +## 0.0.190
 +* Fix a bunch of intermittent cargo bugs
 +
 +## 0.0.189
 +* Rustup to *rustc 1.26.0-nightly (5508b2714 2018-03-18)*
 +
 +## 0.0.188
 +* Rustup to *rustc 1.26.0-nightly (392645394 2018-03-15)*
 +* New lint: [`while_immutable_condition`]
 +
 +## 0.0.187
 +* Rustup to *rustc 1.26.0-nightly (322d7f7b9 2018-02-25)*
 +* New lints: [`redundant_field_names`], [`suspicious_arithmetic_impl`], [`suspicious_op_assign_impl`]
 +
 +## 0.0.186
 +* Rustup to *rustc 1.25.0-nightly (0c6091fbd 2018-02-04)*
 +* Various false positive fixes
 +
 +## 0.0.185
 +* Rustup to *rustc 1.25.0-nightly (56733bc9f 2018-02-01)*
 +* New lint: [`question_mark`]
 +
 +## 0.0.184
 +* Rustup to *rustc 1.25.0-nightly (90eb44a58 2018-01-29)*
 +* New lints: [`double_comparisons`], [`empty_line_after_outer_attr`]
 +
 +## 0.0.183
 +* Rustup to *rustc 1.25.0-nightly (21882aad7 2018-01-28)*
 +* New lint: [`misaligned_transmute`]
 +
 +## 0.0.182
 +* Rustup to *rustc 1.25.0-nightly (a0dcecff9 2018-01-24)*
 +* New lint: [`decimal_literal_representation`]
 +
 +## 0.0.181
 +* Rustup to *rustc 1.25.0-nightly (97520ccb1 2018-01-21)*
 +* New lints: [`else_if_without_else`], [`option_option`], [`unit_arg`], [`unnecessary_fold`]
 +* Removed `unit_expr`
 +* Various false positive fixes for [`needless_pass_by_value`]
 +
 +## 0.0.180
 +* Rustup to *rustc 1.25.0-nightly (3f92e8d89 2018-01-14)*
 +
 +## 0.0.179
 +* Rustup to *rustc 1.25.0-nightly (61452e506 2018-01-09)*
 +
 +## 0.0.178
 +* Rustup to *rustc 1.25.0-nightly (ee220daca 2018-01-07)*
 +
 +## 0.0.177
 +* Rustup to *rustc 1.24.0-nightly (250b49205 2017-12-21)*
 +* New lint: [`match_as_ref`]
 +
 +## 0.0.176
 +* Rustup to *rustc 1.24.0-nightly (0077d128d 2017-12-14)*
 +
 +## 0.0.175
 +* Rustup to *rustc 1.24.0-nightly (bb42071f6 2017-12-01)*
 +
 +## 0.0.174
 +* Rustup to *rustc 1.23.0-nightly (63739ab7b 2017-11-21)*
 +
 +## 0.0.173
 +* Rustup to *rustc 1.23.0-nightly (33374fa9d 2017-11-20)*
 +
 +## 0.0.172
 +* Rustup to *rustc 1.23.0-nightly (d0f8e2913 2017-11-16)*
 +
 +## 0.0.171
 +* Rustup to *rustc 1.23.0-nightly (ff0f5de3b 2017-11-14)*
 +
 +## 0.0.170
 +* Rustup to *rustc 1.23.0-nightly (d6b06c63a 2017-11-09)*
 +
 +## 0.0.169
 +* Rustup to *rustc 1.23.0-nightly (3b82e4c74 2017-11-05)*
 +* New lints: [`just_underscores_and_digits`], `result_map_unwrap_or_else`, [`transmute_bytes_to_str`]
 +
 +## 0.0.168
 +* Rustup to *rustc 1.23.0-nightly (f0fe716db 2017-10-30)*
 +
 +## 0.0.167
 +* Rustup to *rustc 1.23.0-nightly (90ef3372e 2017-10-29)*
 +* New lints: `const_static_lifetime`, [`erasing_op`], [`fallible_impl_from`], [`println_empty_string`], [`useless_asref`]
 +
 +## 0.0.166
 +* Rustup to *rustc 1.22.0-nightly (b7960878b 2017-10-18)*
 +* New lints: [`explicit_write`], `identity_conversion`, [`implicit_hasher`], `invalid_ref`, [`option_map_or_none`],
 +  [`range_minus_one`], [`range_plus_one`], [`transmute_int_to_bool`], [`transmute_int_to_char`],
 +  [`transmute_int_to_float`]
 +
 +## 0.0.165
 +* Rust upgrade to rustc 1.22.0-nightly (0e6f4cf51 2017-09-27)
 +* New lint: [`mut_range_bound`]
 +
 +## 0.0.164
 +* Update to *rustc 1.22.0-nightly (6c476ce46 2017-09-25)*
 +* New lint: [`int_plus_one`]
 +
 +## 0.0.163
 +* Update to *rustc 1.22.0-nightly (14039a42a 2017-09-22)*
 +
 +## 0.0.162
 +* Update to *rustc 1.22.0-nightly (0701b37d9 2017-09-18)*
 +* New lint: [`chars_last_cmp`]
 +* Improved suggestions for [`needless_borrow`], [`ptr_arg`],
 +
 +## 0.0.161
 +* Update to *rustc 1.22.0-nightly (539f2083d 2017-09-13)*
 +
 +## 0.0.160
 +* Update to *rustc 1.22.0-nightly (dd08c3070 2017-09-12)*
 +
 +## 0.0.159
 +* Update to *rustc 1.22.0-nightly (eba374fb2 2017-09-11)*
 +* New lint: [`clone_on_ref_ptr`]
 +
 +## 0.0.158
 +* New lint: [`manual_memcpy`]
 +* [`cast_lossless`] no longer has redundant parentheses in its suggestions
 +* Update to *rustc 1.22.0-nightly (dead08cb3 2017-09-08)*
 +
 +## 0.0.157 - 2017-09-04
 +* Update to *rustc 1.22.0-nightly (981ce7d8d 2017-09-03)*
 +* New lint: `unit_expr`
 +
 +## 0.0.156 - 2017-09-03
 +* Update to *rustc 1.22.0-nightly (744dd6c1d 2017-09-02)*
 +
 +## 0.0.155
 +* Update to *rustc 1.21.0-nightly (c11f689d2 2017-08-29)*
 +* New lint: [`infinite_iter`], [`maybe_infinite_iter`], [`cast_lossless`]
 +
 +## 0.0.154
 +* Update to *rustc 1.21.0-nightly (2c0558f63 2017-08-24)*
 +* Fix [`use_self`] triggering inside derives
 +* Add support for linting an entire workspace with `cargo clippy --all`
 +* New lint: [`naive_bytecount`]
 +
 +## 0.0.153
 +* Update to *rustc 1.21.0-nightly (8c303ed87 2017-08-20)*
 +* New lint: [`use_self`]
 +
 +## 0.0.152
 +* Update to *rustc 1.21.0-nightly (df511d554 2017-08-14)*
 +
 +## 0.0.151
 +* Update to *rustc 1.21.0-nightly (13d94d5fa 2017-08-10)*
 +
 +## 0.0.150
 +* Update to *rustc 1.21.0-nightly (215e0b10e 2017-08-08)*
 +
 +## 0.0.148
 +* Update to *rustc 1.21.0-nightly (37c7d0ebb 2017-07-31)*
 +* New lints: [`unreadable_literal`], [`inconsistent_digit_grouping`], [`large_digit_groups`]
 +
 +## 0.0.147
 +* Update to *rustc 1.21.0-nightly (aac223f4f 2017-07-30)*
 +
 +## 0.0.146
 +* Update to *rustc 1.21.0-nightly (52a330969 2017-07-27)*
 +* Fixes false positives in `inline_always`
 +* Fixes false negatives in `panic_params`
 +
 +## 0.0.145
 +* Update to *rustc 1.20.0-nightly (afe145d22 2017-07-23)*
 +
 +## 0.0.144
 +* Update to *rustc 1.20.0-nightly (086eaa78e 2017-07-15)*
 +
 +## 0.0.143
 +* Update to *rustc 1.20.0-nightly (d84693b93 2017-07-09)*
 +* Fix `cargo clippy` crashing on `dylib` projects
 +* Fix false positives around `nested_while_let` and `never_loop`
 +
 +## 0.0.142
 +* Update to *rustc 1.20.0-nightly (067971139 2017-07-02)*
 +
 +## 0.0.141
 +* Rewrite of the `doc_markdown` lint.
 +* Deprecated [`range_step_by_zero`]
 +* New lint: [`iterator_step_by_zero`]
 +* New lint: [`needless_borrowed_reference`]
 +* Update to *rustc 1.20.0-nightly (69c65d296 2017-06-28)*
 +
 +## 0.0.140 - 2017-06-16
 +* Update to *rustc 1.19.0-nightly (258ae6dd9 2017-06-15)*
 +
 +## 0.0.139 — 2017-06-10
 +* Update to *rustc 1.19.0-nightly (4bf5c99af 2017-06-10)*
 +* Fix bugs with for loop desugaring
 +* Check for [`AsRef`]/[`AsMut`] arguments in [`wrong_self_convention`]
 +
 +## 0.0.138 — 2017-06-05
 +* Update to *rustc 1.19.0-nightly (0418fa9d3 2017-06-04)*
 +
 +## 0.0.137 — 2017-06-05
 +* Update to *rustc 1.19.0-nightly (6684d176c 2017-06-03)*
 +
 +## 0.0.136 — 2017—05—26
 +* Update to *rustc 1.19.0-nightly (557967766 2017-05-26)*
 +
 +## 0.0.135 — 2017—05—24
 +* Update to *rustc 1.19.0-nightly (5b13bff52 2017-05-23)*
 +
 +## 0.0.134 — 2017—05—19
 +* Update to *rustc 1.19.0-nightly (0ed1ec9f9 2017-05-18)*
 +
 +## 0.0.133 — 2017—05—14
 +* Update to *rustc 1.19.0-nightly (826d8f385 2017-05-13)*
 +
 +## 0.0.132 — 2017—05—05
 +* Fix various bugs and some ices
 +
 +## 0.0.131 — 2017—05—04
 +* Update to *rustc 1.19.0-nightly (2d4ed8e0c 2017-05-03)*
 +
 +## 0.0.130 — 2017—05—03
 +* Update to *rustc 1.19.0-nightly (6a5fc9eec 2017-05-02)*
 +
 +## 0.0.129 — 2017-05-01
 +* Update to *rustc 1.19.0-nightly (06fb4d256 2017-04-30)*
 +
 +## 0.0.128 — 2017-04-28
 +* Update to *rustc 1.18.0-nightly (94e884b63 2017-04-27)*
 +
 +## 0.0.127 — 2017-04-27
 +* Update to *rustc 1.18.0-nightly (036983201 2017-04-26)*
 +* New lint: [`needless_continue`]
 +
 +## 0.0.126 — 2017-04-24
 +* Update to *rustc 1.18.0-nightly (2bd4b5c6d 2017-04-23)*
 +
 +## 0.0.125 — 2017-04-19
 +* Update to *rustc 1.18.0-nightly (9f2abadca 2017-04-18)*
 +
 +## 0.0.124 — 2017-04-16
 +* Update to *rustc 1.18.0-nightly (d5cf1cb64 2017-04-15)*
 +
 +## 0.0.123 — 2017-04-07
 +* Fix various false positives
 +
 +## 0.0.122 — 2017-04-07
 +* Rustup to *rustc 1.18.0-nightly (91ae22a01 2017-04-05)*
 +* New lint: [`op_ref`]
 +
 +## 0.0.121 — 2017-03-21
 +* Rustup to *rustc 1.17.0-nightly (134c4a0f0 2017-03-20)*
 +
 +## 0.0.120 — 2017-03-17
 +* Rustup to *rustc 1.17.0-nightly (0aeb9c129 2017-03-15)*
 +
 +## 0.0.119 — 2017-03-13
 +* Rustup to *rustc 1.17.0-nightly (824c9ebbd 2017-03-12)*
 +
 +## 0.0.118 — 2017-03-05
 +* Rustup to *rustc 1.17.0-nightly (b1e31766d 2017-03-03)*
 +
 +## 0.0.117 — 2017-03-01
 +* Rustup to *rustc 1.17.0-nightly (be760566c 2017-02-28)*
 +
 +## 0.0.116 — 2017-02-28
 +* Fix `cargo clippy` on 64 bit windows systems
 +
 +## 0.0.115 — 2017-02-27
 +* Rustup to *rustc 1.17.0-nightly (60a0edc6c 2017-02-26)*
 +* New lints: [`zero_ptr`], [`never_loop`], [`mut_from_ref`]
 +
 +## 0.0.114 — 2017-02-08
 +* Rustup to *rustc 1.17.0-nightly (c49d10207 2017-02-07)*
 +* Tests are now ui tests (testing the exact output of rustc)
 +
 +## 0.0.113 — 2017-02-04
 +* Rustup to *rustc 1.16.0-nightly (eedaa94e3 2017-02-02)*
 +* New lint: [`large_enum_variant`]
 +* `explicit_into_iter_loop` provides suggestions
 +
 +## 0.0.112 — 2017-01-27
 +* Rustup to *rustc 1.16.0-nightly (df8debf6d 2017-01-25)*
 +
 +## 0.0.111 — 2017-01-21
 +* Rustup to *rustc 1.16.0-nightly (a52da95ce 2017-01-20)*
 +
 +## 0.0.110 — 2017-01-20
 +* Add badges and categories to `Cargo.toml`
 +
 +## 0.0.109 — 2017-01-19
 +* Update to *rustc 1.16.0-nightly (c07a6ae77 2017-01-17)*
 +
 +## 0.0.108 — 2017-01-12
 +* Update to *rustc 1.16.0-nightly (2782e8f8f 2017-01-12)*
 +
 +## 0.0.107 — 2017-01-11
 +* Update regex dependency
 +* Fix FP when matching `&&mut` by `&ref`
 +* Reintroduce `for (_, x) in &mut hash_map` -> `for x in hash_map.values_mut()`
 +* New lints: [`unused_io_amount`], [`forget_ref`], [`short_circuit_statement`]
 +
 +## 0.0.106 — 2017-01-04
 +* Fix FP introduced by rustup in [`wrong_self_convention`]
 +
 +## 0.0.105 — 2017-01-04
 +* Update to *rustc 1.16.0-nightly (468227129 2017-01-03)*
 +* New lints: [`deref_addrof`], [`double_parens`], [`pub_enum_variant_names`]
 +* Fix suggestion in [`new_without_default`]
 +* FP fix in [`absurd_extreme_comparisons`]
 +
 +## 0.0.104 — 2016-12-15
 +* Update to *rustc 1.15.0-nightly (8f02c429a 2016-12-15)*
 +
 +## 0.0.103 — 2016-11-25
 +* Update to *rustc 1.15.0-nightly (d5814b03e 2016-11-23)*
 +
 +## 0.0.102 — 2016-11-24
 +* Update to *rustc 1.15.0-nightly (3bf2be9ce 2016-11-22)*
 +
 +## 0.0.101 — 2016-11-23
 +* Update to *rustc 1.15.0-nightly (7b3eeea22 2016-11-21)*
 +* New lint: [`string_extend_chars`]
 +
 +## 0.0.100 — 2016-11-20
 +* Update to *rustc 1.15.0-nightly (ac635aa95 2016-11-18)*
 +
 +## 0.0.99 — 2016-11-18
 +* Update to rustc 1.15.0-nightly (0ed951993 2016-11-14)
 +* New lint: [`get_unwrap`]
 +
 +## 0.0.98 — 2016-11-08
 +* Fixes an issue due to a change in how cargo handles `--sysroot`, which broke `cargo clippy`
 +
 +## 0.0.97 — 2016-11-03
 +* For convenience, `cargo clippy` defines a `cargo-clippy` feature. This was
 +  previously added for a short time under the name `clippy` but removed for
 +  compatibility.
 +* `cargo clippy --help` is more helping (and less helpful :smile:)
 +* Rustup to *rustc 1.14.0-nightly (5665bdf3e 2016-11-02)*
 +* New lints: [`if_let_redundant_pattern_matching`], [`partialeq_ne_impl`]
 +
 +## 0.0.96 — 2016-10-22
 +* Rustup to *rustc 1.14.0-nightly (f09420685 2016-10-20)*
 +* New lint: [`iter_skip_next`]
 +
 +## 0.0.95 — 2016-10-06
 +* Rustup to *rustc 1.14.0-nightly (3210fd5c2 2016-10-05)*
 +
 +## 0.0.94 — 2016-10-04
 +* Fixes bustage on Windows due to forbidden directory name
 +
 +## 0.0.93 — 2016-10-03
 +* Rustup to *rustc 1.14.0-nightly (144af3e97 2016-10-02)*
 +* `option_map_unwrap_or` and `option_map_unwrap_or_else` are now
 +  allowed by default.
 +* New lint: [`explicit_into_iter_loop`]
 +
 +## 0.0.92 — 2016-09-30
 +* Rustup to *rustc 1.14.0-nightly (289f3a4ca 2016-09-29)*
 +
 +## 0.0.91 — 2016-09-28
 +* Rustup to *rustc 1.13.0-nightly (d0623cf7b 2016-09-26)*
 +
 +## 0.0.90 — 2016-09-09
 +* Rustup to *rustc 1.13.0-nightly (f1f40f850 2016-09-09)*
 +
 +## 0.0.89 — 2016-09-06
 +* Rustup to *rustc 1.13.0-nightly (cbe4de78e 2016-09-05)*
 +
 +## 0.0.88 — 2016-09-04
 +* Rustup to *rustc 1.13.0-nightly (70598e04f 2016-09-03)*
 +* The following lints are not new but were only usable through the `clippy`
 +  lint groups: [`filter_next`], `for_loop_over_option`,
 +  `for_loop_over_result` and [`match_overlapping_arm`]. You should now be
 +  able to `#[allow/deny]` them individually and they are available directly
 +  through `cargo clippy`.
 +
 +## 0.0.87 — 2016-08-31
 +* Rustup to *rustc 1.13.0-nightly (eac41469d 2016-08-30)*
 +* New lints: [`builtin_type_shadow`]
 +* Fix FP in [`zero_prefixed_literal`] and `0b`/`0o`
 +
 +## 0.0.86 — 2016-08-28
 +* Rustup to *rustc 1.13.0-nightly (a23064af5 2016-08-27)*
 +* New lints: [`missing_docs_in_private_items`], [`zero_prefixed_literal`]
 +
 +## 0.0.85 — 2016-08-19
 +* Fix ICE with [`useless_attribute`]
 +* [`useless_attribute`] ignores `unused_imports` on `use` statements
 +
 +## 0.0.84 — 2016-08-18
 +* Rustup to *rustc 1.13.0-nightly (aef6971ca 2016-08-17)*
 +
 +## 0.0.83 — 2016-08-17
 +* Rustup to *rustc 1.12.0-nightly (1bf5fa326 2016-08-16)*
 +* New lints: [`print_with_newline`], [`useless_attribute`]
 +
 +## 0.0.82 — 2016-08-17
 +* Rustup to *rustc 1.12.0-nightly (197be89f3 2016-08-15)*
 +* New lint: [`module_inception`]
 +
 +## 0.0.81 — 2016-08-14
 +* Rustup to *rustc 1.12.0-nightly (1deb02ea6 2016-08-12)*
 +* New lints: [`eval_order_dependence`], [`mixed_case_hex_literals`], [`unseparated_literal_suffix`]
 +* False positive fix in [`too_many_arguments`]
 +* Addition of functionality to [`needless_borrow`]
 +* Suggestions for [`clone_on_copy`]
 +* Bug fix in [`wrong_self_convention`]
 +* Doc improvements
 +
 +## 0.0.80 — 2016-07-31
 +* Rustup to *rustc 1.12.0-nightly (1225e122f 2016-07-30)*
 +* New lints: [`misrefactored_assign_op`], [`serde_api_misuse`]
 +
 +## 0.0.79 — 2016-07-10
 +* Rustup to *rustc 1.12.0-nightly (f93aaf84c 2016-07-09)*
 +* Major suggestions refactoring
 +
 +## 0.0.78 — 2016-07-02
 +* Rustup to *rustc 1.11.0-nightly (01411937f 2016-07-01)*
 +* New lints: [`wrong_transmute`], [`double_neg`], [`filter_map`]
 +* For compatibility, `cargo clippy` does not defines the `clippy` feature
 +  introduced in 0.0.76 anymore
 +* [`collapsible_if`] now considers `if let`
 +
 +## 0.0.77 — 2016-06-21
 +* Rustup to *rustc 1.11.0-nightly (5522e678b 2016-06-20)*
 +* New lints: `stutter` and [`iter_nth`]
 +
 +## 0.0.76 — 2016-06-10
 +* Rustup to *rustc 1.11.0-nightly (7d2f75a95 2016-06-09)*
 +* `cargo clippy` now automatically defines the `clippy` feature
 +* New lint: [`not_unsafe_ptr_arg_deref`]
 +
 +## 0.0.75 — 2016-06-08
 +* Rustup to *rustc 1.11.0-nightly (763f9234b 2016-06-06)*
 +
 +## 0.0.74 — 2016-06-07
 +* Fix bug with `cargo-clippy` JSON parsing
 +* Add the `CLIPPY_DISABLE_DOCS_LINKS` environment variable to deactivate the
 +  “for further information visit *lint-link*” message.
 +
 +## 0.0.73 — 2016-06-05
 +* Fix false positives in [`useless_let_if_seq`]
 +
 +## 0.0.72 — 2016-06-04
 +* Fix false positives in [`useless_let_if_seq`]
 +
 +## 0.0.71 — 2016-05-31
 +* Rustup to *rustc 1.11.0-nightly (a967611d8 2016-05-30)*
 +* New lint: [`useless_let_if_seq`]
 +
 +## 0.0.70 — 2016-05-28
 +* Rustup to *rustc 1.10.0-nightly (7bddce693 2016-05-27)*
 +* [`invalid_regex`] and [`trivial_regex`] can now warn on `RegexSet::new`,
 +  `RegexBuilder::new` and byte regexes
 +
 +## 0.0.69 — 2016-05-20
 +* Rustup to *rustc 1.10.0-nightly (476fe6eef 2016-05-21)*
 +* [`used_underscore_binding`] has been made `Allow` temporarily
 +
 +## 0.0.68 — 2016-05-17
 +* Rustup to *rustc 1.10.0-nightly (cd6a40017 2016-05-16)*
 +* New lint: [`unnecessary_operation`]
 +
 +## 0.0.67 — 2016-05-12
 +* Rustup to *rustc 1.10.0-nightly (22ac88f1a 2016-05-11)*
 +
 +## 0.0.66 — 2016-05-11
 +* New `cargo clippy` subcommand
 +* New lints: [`assign_op_pattern`], [`assign_ops`], [`needless_borrow`]
 +
 +## 0.0.65 — 2016-05-08
 +* Rustup to *rustc 1.10.0-nightly (62e2b2fb7 2016-05-06)*
 +* New lints: [`float_arithmetic`], [`integer_arithmetic`]
 +
 +## 0.0.64 — 2016-04-26
 +* Rustup to *rustc 1.10.0-nightly (645dd013a 2016-04-24)*
 +* New lints: `temporary_cstring_as_ptr`, [`unsafe_removed_from_name`], and [`mem_forget`]
 +
 +## 0.0.63 — 2016-04-08
 +* Rustup to *rustc 1.9.0-nightly (7979dd608 2016-04-07)*
 +
 +## 0.0.62 — 2016-04-07
 +* Rustup to *rustc 1.9.0-nightly (bf5da36f1 2016-04-06)*
 +
 +## 0.0.61 — 2016-04-03
 +* Rustup to *rustc 1.9.0-nightly (5ab11d72c 2016-04-02)*
 +* New lint: [`invalid_upcast_comparisons`]
 +
 +## 0.0.60 — 2016-04-01
 +* Rustup to *rustc 1.9.0-nightly (e1195c24b 2016-03-31)*
 +
 +## 0.0.59 — 2016-03-31
 +* Rustup to *rustc 1.9.0-nightly (30a3849f2 2016-03-30)*
 +* New lints: [`logic_bug`], [`nonminimal_bool`]
 +* Fixed: [`match_same_arms`] now ignores arms with guards
 +* Improved: [`useless_vec`] now warns on `for … in vec![…]`
 +
 +## 0.0.58 — 2016-03-27
 +* Rustup to *rustc 1.9.0-nightly (d5a91e695 2016-03-26)*
 +* New lint: [`doc_markdown`]
 +
 +## 0.0.57 — 2016-03-27
 +* Update to *rustc 1.9.0-nightly (a1e29daf1 2016-03-25)*
 +* Deprecated lints: [`str_to_string`], [`string_to_string`], [`unstable_as_slice`], [`unstable_as_mut_slice`]
 +* New lint: [`crosspointer_transmute`]
 +
 +## 0.0.56 — 2016-03-23
 +* Update to *rustc 1.9.0-nightly (0dcc413e4 2016-03-22)*
 +* New lints: [`many_single_char_names`] and [`similar_names`]
 +
 +## 0.0.55 — 2016-03-21
 +* Update to *rustc 1.9.0-nightly (02310fd31 2016-03-19)*
 +
 +## 0.0.54 — 2016-03-16
 +* Update to *rustc 1.9.0-nightly (c66d2380a 2016-03-15)*
 +
 +## 0.0.53 — 2016-03-15
 +* Add a [configuration file]
 +
 +## ~~0.0.52~~
 +
 +## 0.0.51 — 2016-03-13
 +* Add `str` to types considered by [`len_zero`]
 +* New lints: [`indexing_slicing`]
 +
 +## 0.0.50 — 2016-03-11
 +* Update to *rustc 1.9.0-nightly (c9629d61c 2016-03-10)*
 +
 +## 0.0.49 — 2016-03-09
 +* Update to *rustc 1.9.0-nightly (eabfc160f 2016-03-08)*
 +* New lints: [`overflow_check_conditional`], `unused_label`, [`new_without_default`]
 +
 +## 0.0.48 — 2016-03-07
 +* Fixed: ICE in [`needless_range_loop`] with globals
 +
 +## 0.0.47 — 2016-03-07
 +* Update to *rustc 1.9.0-nightly (998a6720b 2016-03-07)*
 +* New lint: [`redundant_closure_call`]
 +
 +[`AsMut`]: https://doc.rust-lang.org/std/convert/trait.AsMut.html
 +[`AsRef`]: https://doc.rust-lang.org/std/convert/trait.AsRef.html
 +[configuration file]: ./rust-clippy#configuration
 +[pull3665]: https://github.com/rust-lang/rust-clippy/pull/3665
 +[adding_lints]: https://github.com/rust-lang/rust-clippy/blob/master/doc/adding_lints.md
 +[`README.md`]: https://github.com/rust-lang/rust-clippy/blob/master/README.md
 +
 +<!-- lint disable no-unused-definitions -->
 +<!-- begin autogenerated links to lint list -->
 +[`absurd_extreme_comparisons`]: https://rust-lang.github.io/rust-clippy/master/index.html#absurd_extreme_comparisons
 +[`almost_swapped`]: https://rust-lang.github.io/rust-clippy/master/index.html#almost_swapped
 +[`approx_constant`]: https://rust-lang.github.io/rust-clippy/master/index.html#approx_constant
 +[`as_conversions`]: https://rust-lang.github.io/rust-clippy/master/index.html#as_conversions
 +[`assertions_on_constants`]: https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_constants
 +[`assign_op_pattern`]: https://rust-lang.github.io/rust-clippy/master/index.html#assign_op_pattern
 +[`assign_ops`]: https://rust-lang.github.io/rust-clippy/master/index.html#assign_ops
 +[`async_yields_async`]: https://rust-lang.github.io/rust-clippy/master/index.html#async_yields_async
 +[`await_holding_lock`]: https://rust-lang.github.io/rust-clippy/master/index.html#await_holding_lock
 +[`await_holding_refcell_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#await_holding_refcell_ref
 +[`bad_bit_mask`]: https://rust-lang.github.io/rust-clippy/master/index.html#bad_bit_mask
 +[`bind_instead_of_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#bind_instead_of_map
 +[`blacklisted_name`]: https://rust-lang.github.io/rust-clippy/master/index.html#blacklisted_name
 +[`blanket_clippy_restriction_lints`]: https://rust-lang.github.io/rust-clippy/master/index.html#blanket_clippy_restriction_lints
 +[`blocks_in_if_conditions`]: https://rust-lang.github.io/rust-clippy/master/index.html#blocks_in_if_conditions
 +[`bool_assert_comparison`]: https://rust-lang.github.io/rust-clippy/master/index.html#bool_assert_comparison
 +[`bool_comparison`]: https://rust-lang.github.io/rust-clippy/master/index.html#bool_comparison
 +[`borrow_as_ptr`]: https://rust-lang.github.io/rust-clippy/master/index.html#borrow_as_ptr
 +[`borrow_interior_mutable_const`]: https://rust-lang.github.io/rust-clippy/master/index.html#borrow_interior_mutable_const
 +[`borrowed_box`]: https://rust-lang.github.io/rust-clippy/master/index.html#borrowed_box
 +[`box_collection`]: https://rust-lang.github.io/rust-clippy/master/index.html#box_collection
 +[`boxed_local`]: https://rust-lang.github.io/rust-clippy/master/index.html#boxed_local
 +[`branches_sharing_code`]: https://rust-lang.github.io/rust-clippy/master/index.html#branches_sharing_code
 +[`builtin_type_shadow`]: https://rust-lang.github.io/rust-clippy/master/index.html#builtin_type_shadow
 +[`bytes_nth`]: https://rust-lang.github.io/rust-clippy/master/index.html#bytes_nth
 +[`cargo_common_metadata`]: https://rust-lang.github.io/rust-clippy/master/index.html#cargo_common_metadata
 +[`case_sensitive_file_extension_comparisons`]: https://rust-lang.github.io/rust-clippy/master/index.html#case_sensitive_file_extension_comparisons
 +[`cast_lossless`]: https://rust-lang.github.io/rust-clippy/master/index.html#cast_lossless
 +[`cast_possible_truncation`]: https://rust-lang.github.io/rust-clippy/master/index.html#cast_possible_truncation
 +[`cast_possible_wrap`]: https://rust-lang.github.io/rust-clippy/master/index.html#cast_possible_wrap
 +[`cast_precision_loss`]: https://rust-lang.github.io/rust-clippy/master/index.html#cast_precision_loss
 +[`cast_ptr_alignment`]: https://rust-lang.github.io/rust-clippy/master/index.html#cast_ptr_alignment
 +[`cast_ref_to_mut`]: https://rust-lang.github.io/rust-clippy/master/index.html#cast_ref_to_mut
 +[`cast_sign_loss`]: https://rust-lang.github.io/rust-clippy/master/index.html#cast_sign_loss
 +[`char_lit_as_u8`]: https://rust-lang.github.io/rust-clippy/master/index.html#char_lit_as_u8
 +[`chars_last_cmp`]: https://rust-lang.github.io/rust-clippy/master/index.html#chars_last_cmp
 +[`chars_next_cmp`]: https://rust-lang.github.io/rust-clippy/master/index.html#chars_next_cmp
 +[`checked_conversions`]: https://rust-lang.github.io/rust-clippy/master/index.html#checked_conversions
 +[`clone_double_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#clone_double_ref
 +[`clone_on_copy`]: https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy
 +[`clone_on_ref_ptr`]: https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_ref_ptr
 +[`cloned_instead_of_copied`]: https://rust-lang.github.io/rust-clippy/master/index.html#cloned_instead_of_copied
 +[`cmp_nan`]: https://rust-lang.github.io/rust-clippy/master/index.html#cmp_nan
 +[`cmp_null`]: https://rust-lang.github.io/rust-clippy/master/index.html#cmp_null
 +[`cmp_owned`]: https://rust-lang.github.io/rust-clippy/master/index.html#cmp_owned
 +[`cognitive_complexity`]: https://rust-lang.github.io/rust-clippy/master/index.html#cognitive_complexity
 +[`collapsible_else_if`]: https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_else_if
 +[`collapsible_if`]: https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
 +[`collapsible_match`]: https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_match
 +[`comparison_chain`]: https://rust-lang.github.io/rust-clippy/master/index.html#comparison_chain
 +[`comparison_to_empty`]: https://rust-lang.github.io/rust-clippy/master/index.html#comparison_to_empty
 +[`copy_iterator`]: https://rust-lang.github.io/rust-clippy/master/index.html#copy_iterator
 +[`create_dir`]: https://rust-lang.github.io/rust-clippy/master/index.html#create_dir
 +[`crosspointer_transmute`]: https://rust-lang.github.io/rust-clippy/master/index.html#crosspointer_transmute
 +[`dbg_macro`]: https://rust-lang.github.io/rust-clippy/master/index.html#dbg_macro
 +[`debug_assert_with_mut_call`]: https://rust-lang.github.io/rust-clippy/master/index.html#debug_assert_with_mut_call
 +[`decimal_literal_representation`]: https://rust-lang.github.io/rust-clippy/master/index.html#decimal_literal_representation
 +[`declare_interior_mutable_const`]: https://rust-lang.github.io/rust-clippy/master/index.html#declare_interior_mutable_const
 +[`default_numeric_fallback`]: https://rust-lang.github.io/rust-clippy/master/index.html#default_numeric_fallback
 +[`default_trait_access`]: https://rust-lang.github.io/rust-clippy/master/index.html#default_trait_access
 +[`deprecated_cfg_attr`]: https://rust-lang.github.io/rust-clippy/master/index.html#deprecated_cfg_attr
 +[`deprecated_semver`]: https://rust-lang.github.io/rust-clippy/master/index.html#deprecated_semver
 +[`deref_addrof`]: https://rust-lang.github.io/rust-clippy/master/index.html#deref_addrof
 +[`derivable_impls`]: https://rust-lang.github.io/rust-clippy/master/index.html#derivable_impls
 +[`derive_hash_xor_eq`]: https://rust-lang.github.io/rust-clippy/master/index.html#derive_hash_xor_eq
 +[`derive_ord_xor_partial_ord`]: https://rust-lang.github.io/rust-clippy/master/index.html#derive_ord_xor_partial_ord
 +[`disallowed_methods`]: https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_methods
 +[`disallowed_script_idents`]: https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_script_idents
 +[`disallowed_types`]: https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_types
 +[`diverging_sub_expression`]: https://rust-lang.github.io/rust-clippy/master/index.html#diverging_sub_expression
 +[`doc_markdown`]: https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown
 +[`double_comparisons`]: https://rust-lang.github.io/rust-clippy/master/index.html#double_comparisons
 +[`double_must_use`]: https://rust-lang.github.io/rust-clippy/master/index.html#double_must_use
 +[`double_neg`]: https://rust-lang.github.io/rust-clippy/master/index.html#double_neg
 +[`double_parens`]: https://rust-lang.github.io/rust-clippy/master/index.html#double_parens
 +[`drop_copy`]: https://rust-lang.github.io/rust-clippy/master/index.html#drop_copy
 +[`drop_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#drop_ref
 +[`duplicate_underscore_argument`]: https://rust-lang.github.io/rust-clippy/master/index.html#duplicate_underscore_argument
 +[`duration_subsec`]: https://rust-lang.github.io/rust-clippy/master/index.html#duration_subsec
 +[`else_if_without_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#else_if_without_else
 +[`empty_enum`]: https://rust-lang.github.io/rust-clippy/master/index.html#empty_enum
 +[`empty_line_after_outer_attr`]: https://rust-lang.github.io/rust-clippy/master/index.html#empty_line_after_outer_attr
 +[`empty_loop`]: https://rust-lang.github.io/rust-clippy/master/index.html#empty_loop
 +[`enum_clike_unportable_variant`]: https://rust-lang.github.io/rust-clippy/master/index.html#enum_clike_unportable_variant
 +[`enum_glob_use`]: https://rust-lang.github.io/rust-clippy/master/index.html#enum_glob_use
 +[`enum_variant_names`]: https://rust-lang.github.io/rust-clippy/master/index.html#enum_variant_names
 +[`eq_op`]: https://rust-lang.github.io/rust-clippy/master/index.html#eq_op
 +[`equatable_if_let`]: https://rust-lang.github.io/rust-clippy/master/index.html#equatable_if_let
 +[`erasing_op`]: https://rust-lang.github.io/rust-clippy/master/index.html#erasing_op
 +[`eval_order_dependence`]: https://rust-lang.github.io/rust-clippy/master/index.html#eval_order_dependence
 +[`excessive_precision`]: https://rust-lang.github.io/rust-clippy/master/index.html#excessive_precision
 +[`exhaustive_enums`]: https://rust-lang.github.io/rust-clippy/master/index.html#exhaustive_enums
 +[`exhaustive_structs`]: https://rust-lang.github.io/rust-clippy/master/index.html#exhaustive_structs
 +[`exit`]: https://rust-lang.github.io/rust-clippy/master/index.html#exit
 +[`expect_fun_call`]: https://rust-lang.github.io/rust-clippy/master/index.html#expect_fun_call
 +[`expect_used`]: https://rust-lang.github.io/rust-clippy/master/index.html#expect_used
 +[`expl_impl_clone_on_copy`]: https://rust-lang.github.io/rust-clippy/master/index.html#expl_impl_clone_on_copy
 +[`explicit_counter_loop`]: https://rust-lang.github.io/rust-clippy/master/index.html#explicit_counter_loop
 +[`explicit_deref_methods`]: https://rust-lang.github.io/rust-clippy/master/index.html#explicit_deref_methods
 +[`explicit_into_iter_loop`]: https://rust-lang.github.io/rust-clippy/master/index.html#explicit_into_iter_loop
 +[`explicit_iter_loop`]: https://rust-lang.github.io/rust-clippy/master/index.html#explicit_iter_loop
 +[`explicit_write`]: https://rust-lang.github.io/rust-clippy/master/index.html#explicit_write
 +[`extend_from_slice`]: https://rust-lang.github.io/rust-clippy/master/index.html#extend_from_slice
 +[`extend_with_drain`]: https://rust-lang.github.io/rust-clippy/master/index.html#extend_with_drain
 +[`extra_unused_lifetimes`]: https://rust-lang.github.io/rust-clippy/master/index.html#extra_unused_lifetimes
 +[`fallible_impl_from`]: https://rust-lang.github.io/rust-clippy/master/index.html#fallible_impl_from
 +[`field_reassign_with_default`]: https://rust-lang.github.io/rust-clippy/master/index.html#field_reassign_with_default
 +[`filetype_is_file`]: https://rust-lang.github.io/rust-clippy/master/index.html#filetype_is_file
 +[`filter_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#filter_map
 +[`filter_map_identity`]: https://rust-lang.github.io/rust-clippy/master/index.html#filter_map_identity
 +[`filter_map_next`]: https://rust-lang.github.io/rust-clippy/master/index.html#filter_map_next
 +[`filter_next`]: https://rust-lang.github.io/rust-clippy/master/index.html#filter_next
 +[`find_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#find_map
 +[`flat_map_identity`]: https://rust-lang.github.io/rust-clippy/master/index.html#flat_map_identity
 +[`flat_map_option`]: https://rust-lang.github.io/rust-clippy/master/index.html#flat_map_option
 +[`float_arithmetic`]: https://rust-lang.github.io/rust-clippy/master/index.html#float_arithmetic
 +[`float_cmp`]: https://rust-lang.github.io/rust-clippy/master/index.html#float_cmp
 +[`float_cmp_const`]: https://rust-lang.github.io/rust-clippy/master/index.html#float_cmp_const
 +[`float_equality_without_abs`]: https://rust-lang.github.io/rust-clippy/master/index.html#float_equality_without_abs
 +[`fn_address_comparisons`]: https://rust-lang.github.io/rust-clippy/master/index.html#fn_address_comparisons
 +[`fn_params_excessive_bools`]: https://rust-lang.github.io/rust-clippy/master/index.html#fn_params_excessive_bools
 +[`fn_to_numeric_cast`]: https://rust-lang.github.io/rust-clippy/master/index.html#fn_to_numeric_cast
 +[`fn_to_numeric_cast_any`]: https://rust-lang.github.io/rust-clippy/master/index.html#fn_to_numeric_cast_any
 +[`fn_to_numeric_cast_with_truncation`]: https://rust-lang.github.io/rust-clippy/master/index.html#fn_to_numeric_cast_with_truncation
 +[`for_kv_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#for_kv_map
 +[`for_loops_over_fallibles`]: https://rust-lang.github.io/rust-clippy/master/index.html#for_loops_over_fallibles
 +[`forget_copy`]: https://rust-lang.github.io/rust-clippy/master/index.html#forget_copy
 +[`forget_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#forget_ref
 +[`format_in_format_args`]: https://rust-lang.github.io/rust-clippy/master/index.html#format_in_format_args
 +[`from_iter_instead_of_collect`]: https://rust-lang.github.io/rust-clippy/master/index.html#from_iter_instead_of_collect
 +[`from_over_into`]: https://rust-lang.github.io/rust-clippy/master/index.html#from_over_into
 +[`from_str_radix_10`]: https://rust-lang.github.io/rust-clippy/master/index.html#from_str_radix_10
 +[`future_not_send`]: https://rust-lang.github.io/rust-clippy/master/index.html#future_not_send
 +[`get_last_with_len`]: https://rust-lang.github.io/rust-clippy/master/index.html#get_last_with_len
 +[`get_unwrap`]: https://rust-lang.github.io/rust-clippy/master/index.html#get_unwrap
 +[`identity_op`]: https://rust-lang.github.io/rust-clippy/master/index.html#identity_op
 +[`if_let_mutex`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_let_mutex
 +[`if_let_redundant_pattern_matching`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_let_redundant_pattern_matching
 +[`if_not_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_not_else
 +[`if_same_then_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_same_then_else
 +[`if_then_some_else_none`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_then_some_else_none
 +[`ifs_same_cond`]: https://rust-lang.github.io/rust-clippy/master/index.html#ifs_same_cond
 +[`implicit_clone`]: https://rust-lang.github.io/rust-clippy/master/index.html#implicit_clone
 +[`implicit_hasher`]: https://rust-lang.github.io/rust-clippy/master/index.html#implicit_hasher
 +[`implicit_return`]: https://rust-lang.github.io/rust-clippy/master/index.html#implicit_return
 +[`implicit_saturating_sub`]: https://rust-lang.github.io/rust-clippy/master/index.html#implicit_saturating_sub
 +[`imprecise_flops`]: https://rust-lang.github.io/rust-clippy/master/index.html#imprecise_flops
 +[`inconsistent_digit_grouping`]: https://rust-lang.github.io/rust-clippy/master/index.html#inconsistent_digit_grouping
 +[`inconsistent_struct_constructor`]: https://rust-lang.github.io/rust-clippy/master/index.html#inconsistent_struct_constructor
 +[`index_refutable_slice`]: https://rust-lang.github.io/rust-clippy/master/index.html#index_refutable_slice
 +[`indexing_slicing`]: https://rust-lang.github.io/rust-clippy/master/index.html#indexing_slicing
 +[`ineffective_bit_mask`]: https://rust-lang.github.io/rust-clippy/master/index.html#ineffective_bit_mask
 +[`inefficient_to_string`]: https://rust-lang.github.io/rust-clippy/master/index.html#inefficient_to_string
 +[`infallible_destructuring_match`]: https://rust-lang.github.io/rust-clippy/master/index.html#infallible_destructuring_match
 +[`infinite_iter`]: https://rust-lang.github.io/rust-clippy/master/index.html#infinite_iter
 +[`inherent_to_string`]: https://rust-lang.github.io/rust-clippy/master/index.html#inherent_to_string
 +[`inherent_to_string_shadow_display`]: https://rust-lang.github.io/rust-clippy/master/index.html#inherent_to_string_shadow_display
 +[`init_numbered_fields`]: https://rust-lang.github.io/rust-clippy/master/index.html#init_numbered_fields
 +[`inline_always`]: https://rust-lang.github.io/rust-clippy/master/index.html#inline_always
 +[`inline_asm_x86_att_syntax`]: https://rust-lang.github.io/rust-clippy/master/index.html#inline_asm_x86_att_syntax
 +[`inline_asm_x86_intel_syntax`]: https://rust-lang.github.io/rust-clippy/master/index.html#inline_asm_x86_intel_syntax
 +[`inline_fn_without_body`]: https://rust-lang.github.io/rust-clippy/master/index.html#inline_fn_without_body
 +[`inspect_for_each`]: https://rust-lang.github.io/rust-clippy/master/index.html#inspect_for_each
 +[`int_plus_one`]: https://rust-lang.github.io/rust-clippy/master/index.html#int_plus_one
 +[`integer_arithmetic`]: https://rust-lang.github.io/rust-clippy/master/index.html#integer_arithmetic
 +[`integer_division`]: https://rust-lang.github.io/rust-clippy/master/index.html#integer_division
 +[`into_iter_on_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#into_iter_on_ref
 +[`invalid_null_ptr_usage`]: https://rust-lang.github.io/rust-clippy/master/index.html#invalid_null_ptr_usage
 +[`invalid_regex`]: https://rust-lang.github.io/rust-clippy/master/index.html#invalid_regex
 +[`invalid_upcast_comparisons`]: https://rust-lang.github.io/rust-clippy/master/index.html#invalid_upcast_comparisons
 +[`invisible_characters`]: https://rust-lang.github.io/rust-clippy/master/index.html#invisible_characters
 +[`items_after_statements`]: https://rust-lang.github.io/rust-clippy/master/index.html#items_after_statements
 +[`iter_cloned_collect`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_cloned_collect
 +[`iter_count`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_count
 +[`iter_next_loop`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_next_loop
 +[`iter_next_slice`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_next_slice
 +[`iter_not_returning_iterator`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_not_returning_iterator
 +[`iter_nth`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_nth
 +[`iter_nth_zero`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_nth_zero
 +[`iter_overeager_cloned`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_overeager_cloned
 +[`iter_skip_next`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_skip_next
 +[`iterator_step_by_zero`]: https://rust-lang.github.io/rust-clippy/master/index.html#iterator_step_by_zero
 +[`just_underscores_and_digits`]: https://rust-lang.github.io/rust-clippy/master/index.html#just_underscores_and_digits
 +[`large_const_arrays`]: https://rust-lang.github.io/rust-clippy/master/index.html#large_const_arrays
 +[`large_digit_groups`]: https://rust-lang.github.io/rust-clippy/master/index.html#large_digit_groups
 +[`large_enum_variant`]: https://rust-lang.github.io/rust-clippy/master/index.html#large_enum_variant
 +[`large_stack_arrays`]: https://rust-lang.github.io/rust-clippy/master/index.html#large_stack_arrays
 +[`large_types_passed_by_value`]: https://rust-lang.github.io/rust-clippy/master/index.html#large_types_passed_by_value
 +[`len_without_is_empty`]: https://rust-lang.github.io/rust-clippy/master/index.html#len_without_is_empty
 +[`len_zero`]: https://rust-lang.github.io/rust-clippy/master/index.html#len_zero
 +[`let_and_return`]: https://rust-lang.github.io/rust-clippy/master/index.html#let_and_return
 +[`let_underscore_drop`]: https://rust-lang.github.io/rust-clippy/master/index.html#let_underscore_drop
 +[`let_underscore_lock`]: https://rust-lang.github.io/rust-clippy/master/index.html#let_underscore_lock
 +[`let_underscore_must_use`]: https://rust-lang.github.io/rust-clippy/master/index.html#let_underscore_must_use
 +[`let_unit_value`]: https://rust-lang.github.io/rust-clippy/master/index.html#let_unit_value
 +[`linkedlist`]: https://rust-lang.github.io/rust-clippy/master/index.html#linkedlist
 +[`logic_bug`]: https://rust-lang.github.io/rust-clippy/master/index.html#logic_bug
 +[`lossy_float_literal`]: https://rust-lang.github.io/rust-clippy/master/index.html#lossy_float_literal
 +[`macro_use_imports`]: https://rust-lang.github.io/rust-clippy/master/index.html#macro_use_imports
 +[`main_recursion`]: https://rust-lang.github.io/rust-clippy/master/index.html#main_recursion
 +[`manual_assert`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_assert
 +[`manual_async_fn`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_async_fn
 +[`manual_bits`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_bits
 +[`manual_filter_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_filter_map
 +[`manual_find_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_find_map
 +[`manual_flatten`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_flatten
 +[`manual_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_map
 +[`manual_memcpy`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_memcpy
 +[`manual_non_exhaustive`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_non_exhaustive
 +[`manual_ok_or`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_ok_or
 +[`manual_range_contains`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_range_contains
 +[`manual_saturating_arithmetic`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_saturating_arithmetic
 +[`manual_split_once`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_split_once
 +[`manual_str_repeat`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_str_repeat
 +[`manual_strip`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_strip
 +[`manual_swap`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_swap
 +[`manual_unwrap_or`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_unwrap_or
 +[`many_single_char_names`]: https://rust-lang.github.io/rust-clippy/master/index.html#many_single_char_names
 +[`map_clone`]: https://rust-lang.github.io/rust-clippy/master/index.html#map_clone
 +[`map_collect_result_unit`]: https://rust-lang.github.io/rust-clippy/master/index.html#map_collect_result_unit
 +[`map_entry`]: https://rust-lang.github.io/rust-clippy/master/index.html#map_entry
 +[`map_err_ignore`]: https://rust-lang.github.io/rust-clippy/master/index.html#map_err_ignore
 +[`map_flatten`]: https://rust-lang.github.io/rust-clippy/master/index.html#map_flatten
 +[`map_identity`]: https://rust-lang.github.io/rust-clippy/master/index.html#map_identity
 +[`map_unwrap_or`]: https://rust-lang.github.io/rust-clippy/master/index.html#map_unwrap_or
 +[`match_as_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#match_as_ref
 +[`match_bool`]: https://rust-lang.github.io/rust-clippy/master/index.html#match_bool
 +[`match_like_matches_macro`]: https://rust-lang.github.io/rust-clippy/master/index.html#match_like_matches_macro
 +[`match_on_vec_items`]: https://rust-lang.github.io/rust-clippy/master/index.html#match_on_vec_items
 +[`match_overlapping_arm`]: https://rust-lang.github.io/rust-clippy/master/index.html#match_overlapping_arm
 +[`match_ref_pats`]: https://rust-lang.github.io/rust-clippy/master/index.html#match_ref_pats
 +[`match_result_ok`]: https://rust-lang.github.io/rust-clippy/master/index.html#match_result_ok
 +[`match_same_arms`]: https://rust-lang.github.io/rust-clippy/master/index.html#match_same_arms
 +[`match_single_binding`]: https://rust-lang.github.io/rust-clippy/master/index.html#match_single_binding
 +[`match_str_case_mismatch`]: https://rust-lang.github.io/rust-clippy/master/index.html#match_str_case_mismatch
 +[`match_wild_err_arm`]: https://rust-lang.github.io/rust-clippy/master/index.html#match_wild_err_arm
 +[`match_wildcard_for_single_variants`]: https://rust-lang.github.io/rust-clippy/master/index.html#match_wildcard_for_single_variants
 +[`maybe_infinite_iter`]: https://rust-lang.github.io/rust-clippy/master/index.html#maybe_infinite_iter
 +[`mem_forget`]: https://rust-lang.github.io/rust-clippy/master/index.html#mem_forget
 +[`mem_replace_option_with_none`]: https://rust-lang.github.io/rust-clippy/master/index.html#mem_replace_option_with_none
 +[`mem_replace_with_default`]: https://rust-lang.github.io/rust-clippy/master/index.html#mem_replace_with_default
 +[`mem_replace_with_uninit`]: https://rust-lang.github.io/rust-clippy/master/index.html#mem_replace_with_uninit
 +[`min_max`]: https://rust-lang.github.io/rust-clippy/master/index.html#min_max
 +[`misaligned_transmute`]: https://rust-lang.github.io/rust-clippy/master/index.html#misaligned_transmute
 +[`mismatched_target_os`]: https://rust-lang.github.io/rust-clippy/master/index.html#mismatched_target_os
 +[`misrefactored_assign_op`]: https://rust-lang.github.io/rust-clippy/master/index.html#misrefactored_assign_op
 +[`missing_const_for_fn`]: https://rust-lang.github.io/rust-clippy/master/index.html#missing_const_for_fn
 +[`missing_docs_in_private_items`]: https://rust-lang.github.io/rust-clippy/master/index.html#missing_docs_in_private_items
 +[`missing_enforced_import_renames`]: https://rust-lang.github.io/rust-clippy/master/index.html#missing_enforced_import_renames
 +[`missing_errors_doc`]: https://rust-lang.github.io/rust-clippy/master/index.html#missing_errors_doc
 +[`missing_inline_in_public_items`]: https://rust-lang.github.io/rust-clippy/master/index.html#missing_inline_in_public_items
 +[`missing_panics_doc`]: https://rust-lang.github.io/rust-clippy/master/index.html#missing_panics_doc
 +[`missing_safety_doc`]: https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc
 +[`mistyped_literal_suffixes`]: https://rust-lang.github.io/rust-clippy/master/index.html#mistyped_literal_suffixes
 +[`mixed_case_hex_literals`]: https://rust-lang.github.io/rust-clippy/master/index.html#mixed_case_hex_literals
 +[`mod_module_files`]: https://rust-lang.github.io/rust-clippy/master/index.html#mod_module_files
 +[`module_inception`]: https://rust-lang.github.io/rust-clippy/master/index.html#module_inception
 +[`module_name_repetitions`]: https://rust-lang.github.io/rust-clippy/master/index.html#module_name_repetitions
 +[`modulo_arithmetic`]: https://rust-lang.github.io/rust-clippy/master/index.html#modulo_arithmetic
 +[`modulo_one`]: https://rust-lang.github.io/rust-clippy/master/index.html#modulo_one
 +[`multiple_crate_versions`]: https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions
 +[`multiple_inherent_impl`]: https://rust-lang.github.io/rust-clippy/master/index.html#multiple_inherent_impl
 +[`must_use_candidate`]: https://rust-lang.github.io/rust-clippy/master/index.html#must_use_candidate
 +[`must_use_unit`]: https://rust-lang.github.io/rust-clippy/master/index.html#must_use_unit
 +[`mut_from_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#mut_from_ref
 +[`mut_mut`]: https://rust-lang.github.io/rust-clippy/master/index.html#mut_mut
 +[`mut_mutex_lock`]: https://rust-lang.github.io/rust-clippy/master/index.html#mut_mutex_lock
 +[`mut_range_bound`]: https://rust-lang.github.io/rust-clippy/master/index.html#mut_range_bound
 +[`mutable_key_type`]: https://rust-lang.github.io/rust-clippy/master/index.html#mutable_key_type
 +[`mutex_atomic`]: https://rust-lang.github.io/rust-clippy/master/index.html#mutex_atomic
 +[`mutex_integer`]: https://rust-lang.github.io/rust-clippy/master/index.html#mutex_integer
 +[`naive_bytecount`]: https://rust-lang.github.io/rust-clippy/master/index.html#naive_bytecount
 +[`needless_arbitrary_self_type`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_arbitrary_self_type
 +[`needless_bitwise_bool`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_bitwise_bool
 +[`needless_bool`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_bool
 +[`needless_borrow`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
 +[`needless_borrowed_reference`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrowed_reference
 +[`needless_collect`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_collect
 +[`needless_continue`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_continue
 +[`needless_doctest_main`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_doctest_main
 +[`needless_for_each`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_for_each
 +[`needless_late_init`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_late_init
 +[`needless_lifetimes`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes
 +[`needless_option_as_deref`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_option_as_deref
 +[`needless_pass_by_value`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_value
 +[`needless_question_mark`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_question_mark
 +[`needless_range_loop`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_range_loop
 +[`needless_return`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
 +[`needless_splitn`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_splitn
 +[`needless_update`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_update
 +[`neg_cmp_op_on_partial_ord`]: https://rust-lang.github.io/rust-clippy/master/index.html#neg_cmp_op_on_partial_ord
 +[`neg_multiply`]: https://rust-lang.github.io/rust-clippy/master/index.html#neg_multiply
 +[`negative_feature_names`]: https://rust-lang.github.io/rust-clippy/master/index.html#negative_feature_names
 +[`never_loop`]: https://rust-lang.github.io/rust-clippy/master/index.html#never_loop
 +[`new_ret_no_self`]: https://rust-lang.github.io/rust-clippy/master/index.html#new_ret_no_self
 +[`new_without_default`]: https://rust-lang.github.io/rust-clippy/master/index.html#new_without_default
 +[`no_effect`]: https://rust-lang.github.io/rust-clippy/master/index.html#no_effect
 +[`no_effect_underscore_binding`]: https://rust-lang.github.io/rust-clippy/master/index.html#no_effect_underscore_binding
 +[`non_ascii_literal`]: https://rust-lang.github.io/rust-clippy/master/index.html#non_ascii_literal
 +[`non_octal_unix_permissions`]: https://rust-lang.github.io/rust-clippy/master/index.html#non_octal_unix_permissions
 +[`non_send_fields_in_send_ty`]: https://rust-lang.github.io/rust-clippy/master/index.html#non_send_fields_in_send_ty
 +[`nonminimal_bool`]: https://rust-lang.github.io/rust-clippy/master/index.html#nonminimal_bool
 +[`nonsensical_open_options`]: https://rust-lang.github.io/rust-clippy/master/index.html#nonsensical_open_options
 +[`nonstandard_macro_braces`]: https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
 +[`not_unsafe_ptr_arg_deref`]: https://rust-lang.github.io/rust-clippy/master/index.html#not_unsafe_ptr_arg_deref
 +[`octal_escapes`]: https://rust-lang.github.io/rust-clippy/master/index.html#octal_escapes
 +[`ok_expect`]: https://rust-lang.github.io/rust-clippy/master/index.html#ok_expect
 +[`op_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#op_ref
 +[`option_as_ref_deref`]: https://rust-lang.github.io/rust-clippy/master/index.html#option_as_ref_deref
 +[`option_env_unwrap`]: https://rust-lang.github.io/rust-clippy/master/index.html#option_env_unwrap
 +[`option_filter_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#option_filter_map
 +[`option_if_let_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#option_if_let_else
 +[`option_map_or_none`]: https://rust-lang.github.io/rust-clippy/master/index.html#option_map_or_none
 +[`option_map_unit_fn`]: https://rust-lang.github.io/rust-clippy/master/index.html#option_map_unit_fn
 +[`option_option`]: https://rust-lang.github.io/rust-clippy/master/index.html#option_option
 +[`or_fun_call`]: https://rust-lang.github.io/rust-clippy/master/index.html#or_fun_call
 +[`out_of_bounds_indexing`]: https://rust-lang.github.io/rust-clippy/master/index.html#out_of_bounds_indexing
 +[`overflow_check_conditional`]: https://rust-lang.github.io/rust-clippy/master/index.html#overflow_check_conditional
 +[`panic`]: https://rust-lang.github.io/rust-clippy/master/index.html#panic
 +[`panic_in_result_fn`]: https://rust-lang.github.io/rust-clippy/master/index.html#panic_in_result_fn
 +[`panicking_unwrap`]: https://rust-lang.github.io/rust-clippy/master/index.html#panicking_unwrap
 +[`partialeq_ne_impl`]: https://rust-lang.github.io/rust-clippy/master/index.html#partialeq_ne_impl
 +[`path_buf_push_overwrite`]: https://rust-lang.github.io/rust-clippy/master/index.html#path_buf_push_overwrite
 +[`pattern_type_mismatch`]: https://rust-lang.github.io/rust-clippy/master/index.html#pattern_type_mismatch
 +[`possible_missing_comma`]: https://rust-lang.github.io/rust-clippy/master/index.html#possible_missing_comma
 +[`precedence`]: https://rust-lang.github.io/rust-clippy/master/index.html#precedence
 +[`print_literal`]: https://rust-lang.github.io/rust-clippy/master/index.html#print_literal
 +[`print_stderr`]: https://rust-lang.github.io/rust-clippy/master/index.html#print_stderr
 +[`print_stdout`]: https://rust-lang.github.io/rust-clippy/master/index.html#print_stdout
 +[`print_with_newline`]: https://rust-lang.github.io/rust-clippy/master/index.html#print_with_newline
 +[`println_empty_string`]: https://rust-lang.github.io/rust-clippy/master/index.html#println_empty_string
 +[`ptr_arg`]: https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg
 +[`ptr_as_ptr`]: https://rust-lang.github.io/rust-clippy/master/index.html#ptr_as_ptr
 +[`ptr_eq`]: https://rust-lang.github.io/rust-clippy/master/index.html#ptr_eq
 +[`ptr_offset_with_cast`]: https://rust-lang.github.io/rust-clippy/master/index.html#ptr_offset_with_cast
 +[`pub_enum_variant_names`]: https://rust-lang.github.io/rust-clippy/master/index.html#pub_enum_variant_names
 +[`question_mark`]: https://rust-lang.github.io/rust-clippy/master/index.html#question_mark
 +[`range_minus_one`]: https://rust-lang.github.io/rust-clippy/master/index.html#range_minus_one
 +[`range_plus_one`]: https://rust-lang.github.io/rust-clippy/master/index.html#range_plus_one
 +[`range_step_by_zero`]: https://rust-lang.github.io/rust-clippy/master/index.html#range_step_by_zero
 +[`range_zip_with_len`]: https://rust-lang.github.io/rust-clippy/master/index.html#range_zip_with_len
 +[`rc_buffer`]: https://rust-lang.github.io/rust-clippy/master/index.html#rc_buffer
 +[`rc_mutex`]: https://rust-lang.github.io/rust-clippy/master/index.html#rc_mutex
 +[`redundant_allocation`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_allocation
 +[`redundant_clone`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone
 +[`redundant_closure`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure
 +[`redundant_closure_call`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure_call
 +[`redundant_closure_for_method_calls`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure_for_method_calls
 +[`redundant_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_else
 +[`redundant_feature_names`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_feature_names
 +[`redundant_field_names`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names
 +[`redundant_pattern`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_pattern
 +[`redundant_pattern_matching`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_pattern_matching
 +[`redundant_pub_crate`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_pub_crate
 +[`redundant_slicing`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_slicing
 +[`redundant_static_lifetimes`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_static_lifetimes
 +[`ref_binding_to_reference`]: https://rust-lang.github.io/rust-clippy/master/index.html#ref_binding_to_reference
 +[`ref_option_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#ref_option_ref
 +[`regex_macro`]: https://rust-lang.github.io/rust-clippy/master/index.html#regex_macro
 +[`repeat_once`]: https://rust-lang.github.io/rust-clippy/master/index.html#repeat_once
 +[`replace_consts`]: https://rust-lang.github.io/rust-clippy/master/index.html#replace_consts
 +[`rest_pat_in_fully_bound_structs`]: https://rust-lang.github.io/rust-clippy/master/index.html#rest_pat_in_fully_bound_structs
 +[`result_map_or_into_option`]: https://rust-lang.github.io/rust-clippy/master/index.html#result_map_or_into_option
 +[`result_map_unit_fn`]: https://rust-lang.github.io/rust-clippy/master/index.html#result_map_unit_fn
 +[`result_unit_err`]: https://rust-lang.github.io/rust-clippy/master/index.html#result_unit_err
 +[`return_self_not_must_use`]: https://rust-lang.github.io/rust-clippy/master/index.html#return_self_not_must_use
 +[`reversed_empty_ranges`]: https://rust-lang.github.io/rust-clippy/master/index.html#reversed_empty_ranges
 +[`same_functions_in_if_condition`]: https://rust-lang.github.io/rust-clippy/master/index.html#same_functions_in_if_condition
 +[`same_item_push`]: https://rust-lang.github.io/rust-clippy/master/index.html#same_item_push
 +[`same_name_method`]: https://rust-lang.github.io/rust-clippy/master/index.html#same_name_method
 +[`search_is_some`]: https://rust-lang.github.io/rust-clippy/master/index.html#search_is_some
 +[`self_assignment`]: https://rust-lang.github.io/rust-clippy/master/index.html#self_assignment
 +[`self_named_constructors`]: https://rust-lang.github.io/rust-clippy/master/index.html#self_named_constructors
 +[`self_named_module_files`]: https://rust-lang.github.io/rust-clippy/master/index.html#self_named_module_files
 +[`semicolon_if_nothing_returned`]: https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned
 +[`separated_literal_suffix`]: https://rust-lang.github.io/rust-clippy/master/index.html#separated_literal_suffix
 +[`serde_api_misuse`]: https://rust-lang.github.io/rust-clippy/master/index.html#serde_api_misuse
 +[`shadow_reuse`]: https://rust-lang.github.io/rust-clippy/master/index.html#shadow_reuse
 +[`shadow_same`]: https://rust-lang.github.io/rust-clippy/master/index.html#shadow_same
 +[`shadow_unrelated`]: https://rust-lang.github.io/rust-clippy/master/index.html#shadow_unrelated
 +[`short_circuit_statement`]: https://rust-lang.github.io/rust-clippy/master/index.html#short_circuit_statement
 +[`should_assert_eq`]: https://rust-lang.github.io/rust-clippy/master/index.html#should_assert_eq
 +[`should_implement_trait`]: https://rust-lang.github.io/rust-clippy/master/index.html#should_implement_trait
 +[`similar_names`]: https://rust-lang.github.io/rust-clippy/master/index.html#similar_names
 +[`single_char_add_str`]: https://rust-lang.github.io/rust-clippy/master/index.html#single_char_add_str
 +[`single_char_lifetime_names`]: https://rust-lang.github.io/rust-clippy/master/index.html#single_char_lifetime_names
 +[`single_char_pattern`]: https://rust-lang.github.io/rust-clippy/master/index.html#single_char_pattern
 +[`single_component_path_imports`]: https://rust-lang.github.io/rust-clippy/master/index.html#single_component_path_imports
 +[`single_element_loop`]: https://rust-lang.github.io/rust-clippy/master/index.html#single_element_loop
 +[`single_match`]: https://rust-lang.github.io/rust-clippy/master/index.html#single_match
 +[`single_match_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#single_match_else
 +[`size_of_in_element_count`]: https://rust-lang.github.io/rust-clippy/master/index.html#size_of_in_element_count
 +[`skip_while_next`]: https://rust-lang.github.io/rust-clippy/master/index.html#skip_while_next
 +[`slow_vector_initialization`]: https://rust-lang.github.io/rust-clippy/master/index.html#slow_vector_initialization
 +[`stable_sort_primitive`]: https://rust-lang.github.io/rust-clippy/master/index.html#stable_sort_primitive
 +[`str_to_string`]: https://rust-lang.github.io/rust-clippy/master/index.html#str_to_string
 +[`string_add`]: https://rust-lang.github.io/rust-clippy/master/index.html#string_add
 +[`string_add_assign`]: https://rust-lang.github.io/rust-clippy/master/index.html#string_add_assign
 +[`string_extend_chars`]: https://rust-lang.github.io/rust-clippy/master/index.html#string_extend_chars
 +[`string_from_utf8_as_bytes`]: https://rust-lang.github.io/rust-clippy/master/index.html#string_from_utf8_as_bytes
 +[`string_lit_as_bytes`]: https://rust-lang.github.io/rust-clippy/master/index.html#string_lit_as_bytes
 +[`string_slice`]: https://rust-lang.github.io/rust-clippy/master/index.html#string_slice
 +[`string_to_string`]: https://rust-lang.github.io/rust-clippy/master/index.html#string_to_string
 +[`strlen_on_c_strings`]: https://rust-lang.github.io/rust-clippy/master/index.html#strlen_on_c_strings
 +[`struct_excessive_bools`]: https://rust-lang.github.io/rust-clippy/master/index.html#struct_excessive_bools
 +[`suboptimal_flops`]: https://rust-lang.github.io/rust-clippy/master/index.html#suboptimal_flops
 +[`suspicious_arithmetic_impl`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_arithmetic_impl
 +[`suspicious_assignment_formatting`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_assignment_formatting
 +[`suspicious_else_formatting`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_else_formatting
 +[`suspicious_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_map
 +[`suspicious_op_assign_impl`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_op_assign_impl
 +[`suspicious_operation_groupings`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_operation_groupings
 +[`suspicious_splitn`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_splitn
 +[`suspicious_unary_op_formatting`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_unary_op_formatting
 +[`tabs_in_doc_comments`]: https://rust-lang.github.io/rust-clippy/master/index.html#tabs_in_doc_comments
 +[`temporary_assignment`]: https://rust-lang.github.io/rust-clippy/master/index.html#temporary_assignment
 +[`to_digit_is_some`]: https://rust-lang.github.io/rust-clippy/master/index.html#to_digit_is_some
 +[`to_string_in_display`]: https://rust-lang.github.io/rust-clippy/master/index.html#to_string_in_display
 +[`to_string_in_format_args`]: https://rust-lang.github.io/rust-clippy/master/index.html#to_string_in_format_args
 +[`todo`]: https://rust-lang.github.io/rust-clippy/master/index.html#todo
 +[`too_many_arguments`]: https://rust-lang.github.io/rust-clippy/master/index.html#too_many_arguments
 +[`too_many_lines`]: https://rust-lang.github.io/rust-clippy/master/index.html#too_many_lines
 +[`toplevel_ref_arg`]: https://rust-lang.github.io/rust-clippy/master/index.html#toplevel_ref_arg
 +[`trailing_empty_array`]: https://rust-lang.github.io/rust-clippy/master/index.html#trailing_empty_array
 +[`trait_duplication_in_bounds`]: https://rust-lang.github.io/rust-clippy/master/index.html#trait_duplication_in_bounds
 +[`transmute_bytes_to_str`]: https://rust-lang.github.io/rust-clippy/master/index.html#transmute_bytes_to_str
 +[`transmute_float_to_int`]: https://rust-lang.github.io/rust-clippy/master/index.html#transmute_float_to_int
 +[`transmute_int_to_bool`]: https://rust-lang.github.io/rust-clippy/master/index.html#transmute_int_to_bool
 +[`transmute_int_to_char`]: https://rust-lang.github.io/rust-clippy/master/index.html#transmute_int_to_char
 +[`transmute_int_to_float`]: https://rust-lang.github.io/rust-clippy/master/index.html#transmute_int_to_float
 +[`transmute_num_to_bytes`]: https://rust-lang.github.io/rust-clippy/master/index.html#transmute_num_to_bytes
 +[`transmute_ptr_to_ptr`]: https://rust-lang.github.io/rust-clippy/master/index.html#transmute_ptr_to_ptr
 +[`transmute_ptr_to_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#transmute_ptr_to_ref
 +[`transmutes_expressible_as_ptr_casts`]: https://rust-lang.github.io/rust-clippy/master/index.html#transmutes_expressible_as_ptr_casts
 +[`transmuting_null`]: https://rust-lang.github.io/rust-clippy/master/index.html#transmuting_null
 +[`trivial_regex`]: https://rust-lang.github.io/rust-clippy/master/index.html#trivial_regex
 +[`trivially_copy_pass_by_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#trivially_copy_pass_by_ref
 +[`try_err`]: https://rust-lang.github.io/rust-clippy/master/index.html#try_err
 +[`type_complexity`]: https://rust-lang.github.io/rust-clippy/master/index.html#type_complexity
 +[`type_repetition_in_bounds`]: https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds
 +[`undocumented_unsafe_blocks`]: https://rust-lang.github.io/rust-clippy/master/index.html#undocumented_unsafe_blocks
 +[`undropped_manually_drops`]: https://rust-lang.github.io/rust-clippy/master/index.html#undropped_manually_drops
 +[`unicode_not_nfc`]: https://rust-lang.github.io/rust-clippy/master/index.html#unicode_not_nfc
 +[`unimplemented`]: https://rust-lang.github.io/rust-clippy/master/index.html#unimplemented
 +[`uninit_assumed_init`]: https://rust-lang.github.io/rust-clippy/master/index.html#uninit_assumed_init
 +[`uninit_vec`]: https://rust-lang.github.io/rust-clippy/master/index.html#uninit_vec
 +[`unit_arg`]: https://rust-lang.github.io/rust-clippy/master/index.html#unit_arg
 +[`unit_cmp`]: https://rust-lang.github.io/rust-clippy/master/index.html#unit_cmp
 +[`unit_hash`]: https://rust-lang.github.io/rust-clippy/master/index.html#unit_hash
 +[`unit_return_expecting_ord`]: https://rust-lang.github.io/rust-clippy/master/index.html#unit_return_expecting_ord
 +[`unnecessary_cast`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
 +[`unnecessary_filter_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_filter_map
 +[`unnecessary_fold`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_fold
 +[`unnecessary_lazy_evaluations`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_lazy_evaluations
 +[`unnecessary_mut_passed`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_mut_passed
 +[`unnecessary_operation`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_operation
 +[`unnecessary_self_imports`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_self_imports
 +[`unnecessary_sort_by`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_sort_by
 +[`unnecessary_to_owned`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_to_owned
 +[`unnecessary_unwrap`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_unwrap
 +[`unnecessary_wraps`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_wraps
 +[`unneeded_field_pattern`]: https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_field_pattern
 +[`unneeded_wildcard_pattern`]: https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_wildcard_pattern
 +[`unnested_or_patterns`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnested_or_patterns
 +[`unreachable`]: https://rust-lang.github.io/rust-clippy/master/index.html#unreachable
 +[`unreadable_literal`]: https://rust-lang.github.io/rust-clippy/master/index.html#unreadable_literal
 +[`unsafe_derive_deserialize`]: https://rust-lang.github.io/rust-clippy/master/index.html#unsafe_derive_deserialize
 +[`unsafe_removed_from_name`]: https://rust-lang.github.io/rust-clippy/master/index.html#unsafe_removed_from_name
 +[`unsafe_vector_initialization`]: https://rust-lang.github.io/rust-clippy/master/index.html#unsafe_vector_initialization
 +[`unseparated_literal_suffix`]: https://rust-lang.github.io/rust-clippy/master/index.html#unseparated_literal_suffix
 +[`unsound_collection_transmute`]: https://rust-lang.github.io/rust-clippy/master/index.html#unsound_collection_transmute
 +[`unstable_as_mut_slice`]: https://rust-lang.github.io/rust-clippy/master/index.html#unstable_as_mut_slice
 +[`unstable_as_slice`]: https://rust-lang.github.io/rust-clippy/master/index.html#unstable_as_slice
 +[`unused_async`]: https://rust-lang.github.io/rust-clippy/master/index.html#unused_async
 +[`unused_collect`]: https://rust-lang.github.io/rust-clippy/master/index.html#unused_collect
 +[`unused_io_amount`]: https://rust-lang.github.io/rust-clippy/master/index.html#unused_io_amount
 +[`unused_self`]: https://rust-lang.github.io/rust-clippy/master/index.html#unused_self
 +[`unused_unit`]: https://rust-lang.github.io/rust-clippy/master/index.html#unused_unit
 +[`unusual_byte_groupings`]: https://rust-lang.github.io/rust-clippy/master/index.html#unusual_byte_groupings
 +[`unwrap_in_result`]: https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_in_result
 +[`unwrap_or_else_default`]: https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_or_else_default
 +[`unwrap_used`]: https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_used
 +[`upper_case_acronyms`]: https://rust-lang.github.io/rust-clippy/master/index.html#upper_case_acronyms
 +[`use_debug`]: https://rust-lang.github.io/rust-clippy/master/index.html#use_debug
 +[`use_self`]: https://rust-lang.github.io/rust-clippy/master/index.html#use_self
 +[`used_underscore_binding`]: https://rust-lang.github.io/rust-clippy/master/index.html#used_underscore_binding
 +[`useless_asref`]: https://rust-lang.github.io/rust-clippy/master/index.html#useless_asref
 +[`useless_attribute`]: https://rust-lang.github.io/rust-clippy/master/index.html#useless_attribute
 +[`useless_conversion`]: https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion
 +[`useless_format`]: https://rust-lang.github.io/rust-clippy/master/index.html#useless_format
 +[`useless_let_if_seq`]: https://rust-lang.github.io/rust-clippy/master/index.html#useless_let_if_seq
 +[`useless_transmute`]: https://rust-lang.github.io/rust-clippy/master/index.html#useless_transmute
 +[`useless_vec`]: https://rust-lang.github.io/rust-clippy/master/index.html#useless_vec
 +[`vec_box`]: https://rust-lang.github.io/rust-clippy/master/index.html#vec_box
 +[`vec_init_then_push`]: https://rust-lang.github.io/rust-clippy/master/index.html#vec_init_then_push
 +[`vec_resize_to_zero`]: https://rust-lang.github.io/rust-clippy/master/index.html#vec_resize_to_zero
 +[`verbose_bit_mask`]: https://rust-lang.github.io/rust-clippy/master/index.html#verbose_bit_mask
 +[`verbose_file_reads`]: https://rust-lang.github.io/rust-clippy/master/index.html#verbose_file_reads
 +[`vtable_address_comparisons`]: https://rust-lang.github.io/rust-clippy/master/index.html#vtable_address_comparisons
 +[`while_immutable_condition`]: https://rust-lang.github.io/rust-clippy/master/index.html#while_immutable_condition
 +[`while_let_loop`]: https://rust-lang.github.io/rust-clippy/master/index.html#while_let_loop
 +[`while_let_on_iterator`]: https://rust-lang.github.io/rust-clippy/master/index.html#while_let_on_iterator
 +[`wildcard_dependencies`]: https://rust-lang.github.io/rust-clippy/master/index.html#wildcard_dependencies
 +[`wildcard_enum_match_arm`]: https://rust-lang.github.io/rust-clippy/master/index.html#wildcard_enum_match_arm
 +[`wildcard_imports`]: https://rust-lang.github.io/rust-clippy/master/index.html#wildcard_imports
 +[`wildcard_in_or_patterns`]: https://rust-lang.github.io/rust-clippy/master/index.html#wildcard_in_or_patterns
 +[`write_literal`]: https://rust-lang.github.io/rust-clippy/master/index.html#write_literal
 +[`write_with_newline`]: https://rust-lang.github.io/rust-clippy/master/index.html#write_with_newline
 +[`writeln_empty_string`]: https://rust-lang.github.io/rust-clippy/master/index.html#writeln_empty_string
 +[`wrong_pub_self_convention`]: https://rust-lang.github.io/rust-clippy/master/index.html#wrong_pub_self_convention
 +[`wrong_self_convention`]: https://rust-lang.github.io/rust-clippy/master/index.html#wrong_self_convention
 +[`wrong_transmute`]: https://rust-lang.github.io/rust-clippy/master/index.html#wrong_transmute
 +[`zero_divided_by_zero`]: https://rust-lang.github.io/rust-clippy/master/index.html#zero_divided_by_zero
 +[`zero_prefixed_literal`]: https://rust-lang.github.io/rust-clippy/master/index.html#zero_prefixed_literal
 +[`zero_ptr`]: https://rust-lang.github.io/rust-clippy/master/index.html#zero_ptr
 +[`zero_sized_map_values`]: https://rust-lang.github.io/rust-clippy/master/index.html#zero_sized_map_values
 +[`zst_offset`]: https://rust-lang.github.io/rust-clippy/master/index.html#zst_offset
 +<!-- end autogenerated links to lint list -->
index daf0fcc993bad320ff894014596fa13328ba0307,0000000000000000000000000000000000000000..dcc2502e4c59a0f2cf4b01ac0f08669fe828c108
mode 100644,000000..100644
--- /dev/null
@@@ -1,91 -1,0 +1,96 @@@
-     path.set_file_name("cargo-clippy");
 +//! `bless` updates the reference files in the repo with changed output files
 +//! from the last test run.
 +
 +use std::ffi::OsStr;
 +use std::fs;
 +use std::lazy::SyncLazy;
 +use std::path::{Path, PathBuf};
 +use walkdir::WalkDir;
 +
 +use crate::clippy_project_root;
 +
++#[cfg(not(windows))]
++static CARGO_CLIPPY_EXE: &str = "cargo-clippy";
++#[cfg(windows)]
++static CARGO_CLIPPY_EXE: &str = "cargo-clippy.exe";
++
 +static CLIPPY_BUILD_TIME: SyncLazy<Option<std::time::SystemTime>> = SyncLazy::new(|| {
 +    let mut path = std::env::current_exe().unwrap();
++    path.set_file_name(CARGO_CLIPPY_EXE);
 +    fs::metadata(path).ok()?.modified().ok()
 +});
 +
 +/// # Panics
 +///
 +/// Panics if the path to a test file is broken
 +pub fn bless(ignore_timestamp: bool) {
 +    let test_suite_dirs = [
 +        clippy_project_root().join("tests").join("ui"),
 +        clippy_project_root().join("tests").join("ui-internal"),
 +        clippy_project_root().join("tests").join("ui-toml"),
 +        clippy_project_root().join("tests").join("ui-cargo"),
 +    ];
 +    for test_suite_dir in &test_suite_dirs {
 +        WalkDir::new(test_suite_dir)
 +            .into_iter()
 +            .filter_map(Result::ok)
 +            .filter(|f| f.path().extension() == Some(OsStr::new("rs")))
 +            .for_each(|f| {
 +                let test_name = f.path().strip_prefix(test_suite_dir).unwrap();
 +                for &ext in &["stdout", "stderr", "fixed"] {
 +                    let test_name_ext = format!("stage-id.{}", ext);
 +                    update_reference_file(
 +                        f.path().with_extension(ext),
 +                        test_name.with_extension(test_name_ext),
 +                        ignore_timestamp,
 +                    );
 +                }
 +            });
 +    }
 +}
 +
 +fn update_reference_file(reference_file_path: PathBuf, test_name: PathBuf, ignore_timestamp: bool) {
 +    let test_output_path = build_dir().join(test_name);
 +    let relative_reference_file_path = reference_file_path.strip_prefix(clippy_project_root()).unwrap();
 +
 +    // If compiletest did not write any changes during the test run,
 +    // we don't have to update anything
 +    if !test_output_path.exists() {
 +        return;
 +    }
 +
 +    // If the test output was not updated since the last clippy build, it may be outdated
 +    if !ignore_timestamp && !updated_since_clippy_build(&test_output_path).unwrap_or(true) {
 +        return;
 +    }
 +
 +    let test_output_file = fs::read(&test_output_path).expect("Unable to read test output file");
 +    let reference_file = fs::read(&reference_file_path).unwrap_or_default();
 +
 +    if test_output_file != reference_file {
 +        // If a test run caused an output file to change, update the reference file
 +        println!("updating {}", &relative_reference_file_path.display());
 +        fs::copy(test_output_path, &reference_file_path).expect("Could not update reference file");
 +
 +        // We need to re-read the file now because it was potentially updated from copying
 +        let reference_file = fs::read(&reference_file_path).unwrap_or_default();
 +
 +        if reference_file.is_empty() {
 +            // If we copied over an empty output file, we remove the now empty reference file
 +            println!("removing {}", &relative_reference_file_path.display());
 +            fs::remove_file(reference_file_path).expect("Could not remove reference file");
 +        }
 +    }
 +}
 +
 +fn updated_since_clippy_build(path: &Path) -> Option<bool> {
 +    let clippy_build_time = (*CLIPPY_BUILD_TIME)?;
 +    let modified = fs::metadata(path).ok()?.modified().ok()?;
 +    Some(modified >= clippy_build_time)
 +}
 +
 +fn build_dir() -> PathBuf {
 +    let mut path = std::env::current_exe().unwrap();
 +    path.set_file_name("test");
 +    path
 +}
index dfd16f7105438c3b8df74cf26b875e8491509675,0000000000000000000000000000000000000000..b8287980a4bacea5df7cadbe2a50621eac7e6131
mode 100644,000000..100644
--- /dev/null
@@@ -1,20 -1,0 +1,19 @@@
-         .env("__CLIPPY_INTERNAL_TESTS", "true")
 +use std::process::{self, Command};
 +
 +pub fn run(filename: &str) {
 +    let code = Command::new("cargo")
 +        .args(["run", "--bin", "clippy-driver", "--"])
 +        .args(["-L", "./target/debug"])
 +        .args(["-Z", "no-codegen"])
 +        .args(["--edition", "2021"])
 +        .arg(filename)
 +        .status()
 +        .expect("failed to run cargo")
 +        .code();
 +
 +    if code.is_none() {
 +        eprintln!("Killed by signal");
 +    }
 +
 +    process::exit(code.unwrap_or(1));
 +}
index b8f5217af2b7d68dcda02e14ea6bd66783b0b7c5,0000000000000000000000000000000000000000..9f8eb488c29ba049cf25619ac4e6902d137415fb
mode 100644,000000..100644
--- /dev/null
@@@ -1,97 -1,0 +1,99 @@@
 +use clippy_utils::diagnostics::span_lint_and_sugg;
 +use clippy_utils::is_no_std_crate;
 +use clippy_utils::source::snippet_opt;
 +use clippy_utils::{meets_msrv, msrvs};
 +use if_chain::if_chain;
 +use rustc_errors::Applicability;
 +use rustc_hir::{BorrowKind, Expr, ExprKind, Mutability, TyKind};
 +use rustc_lint::{LateContext, LateLintPass};
 +use rustc_semver::RustcVersion;
 +use rustc_session::{declare_tool_lint, impl_lint_pass};
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for the usage of `&expr as *const T` or
 +    /// `&mut expr as *mut T`, and suggest using `ptr::addr_of` or
 +    /// `ptr::addr_of_mut` instead.
 +    ///
 +    /// ### Why is this bad?
 +    /// This would improve readability and avoid creating a reference
 +    /// that points to an uninitialized value or unaligned place.
 +    /// Read the `ptr::addr_of` docs for more information.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// let val = 1;
 +    /// let p = &val as *const i32;
 +    ///
 +    /// let mut val_mut = 1;
 +    /// let p_mut = &mut val_mut as *mut i32;
 +    /// ```
 +    /// Use instead:
 +    /// ```rust
 +    /// let val = 1;
 +    /// let p = std::ptr::addr_of!(val);
 +    ///
 +    /// let mut val_mut = 1;
 +    /// let p_mut = std::ptr::addr_of_mut!(val_mut);
 +    /// ```
 +    #[clippy::version = "1.60.0"]
 +    pub BORROW_AS_PTR,
 +    pedantic,
 +    "borrowing just to cast to a raw pointer"
 +}
 +
 +impl_lint_pass!(BorrowAsPtr => [BORROW_AS_PTR]);
 +
 +pub struct BorrowAsPtr {
 +    msrv: Option<RustcVersion>,
 +}
 +
 +impl BorrowAsPtr {
 +    #[must_use]
 +    pub fn new(msrv: Option<RustcVersion>) -> Self {
 +        Self { msrv }
 +    }
 +}
 +
 +impl<'tcx> LateLintPass<'tcx> for BorrowAsPtr {
 +    fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
 +        if !meets_msrv(self.msrv.as_ref(), &msrvs::BORROW_AS_PTR) {
 +            return;
 +        }
 +
 +        if expr.span.from_expansion() {
 +            return;
 +        }
 +
 +        if_chain! {
 +            if let ExprKind::Cast(left_expr, ty) = &expr.kind;
 +            if let TyKind::Ptr(_) = ty.kind;
 +            if let ExprKind::AddrOf(BorrowKind::Ref, mutability, e) = &left_expr.kind;
 +
 +            then {
 +                let core_or_std = if is_no_std_crate(cx) { "core" } else { "std" };
 +                let macro_name = match mutability {
 +                    Mutability::Not => "addr_of",
 +                    Mutability::Mut => "addr_of_mut",
 +                };
 +
 +                span_lint_and_sugg(
 +                    cx,
 +                    BORROW_AS_PTR,
 +                    expr.span,
 +                    "borrow as raw pointer",
 +                    "try",
 +                    format!(
 +                        "{}::ptr::{}!({})",
 +                        core_or_std,
 +                        macro_name,
 +                        snippet_opt(cx, e.span).unwrap()
 +                    ),
 +                    Applicability::MachineApplicable,
 +                );
 +            }
 +        }
 +    }
++
++    extract_msrv_attr!(LateContext);
 +}
index 1915d990c126c1e4b990104b1fce603afac4fa53,0000000000000000000000000000000000000000..470c8c7ea26a60dd2b48b142ffac3cb6ec10a63b
mode 100644,000000..100644
--- /dev/null
@@@ -1,119 -1,0 +1,114 @@@
-             if let Some(src) = snippet_opt(cx, lit.span);
 +use clippy_utils::diagnostics::span_lint_and_sugg;
 +use clippy_utils::numeric_literal::NumericLiteral;
 +use clippy_utils::source::snippet_opt;
 +use if_chain::if_chain;
 +use rustc_ast::{LitFloatType, LitIntType, LitKind};
 +use rustc_errors::Applicability;
 +use rustc_hir::{Expr, ExprKind, Lit, UnOp};
 +use rustc_lint::{LateContext, LintContext};
 +use rustc_middle::lint::in_external_macro;
 +use rustc_middle::ty::{self, FloatTy, InferTy, Ty};
 +
 +use super::UNNECESSARY_CAST;
 +
 +pub(super) fn check(
 +    cx: &LateContext<'_>,
 +    expr: &Expr<'_>,
 +    cast_expr: &Expr<'_>,
 +    cast_from: Ty<'_>,
 +    cast_to: Ty<'_>,
 +) -> bool {
 +    if let Some(lit) = get_numeric_literal(cast_expr) {
 +        let literal_str = snippet_opt(cx, cast_expr.span).unwrap_or_default();
 +
 +        if_chain! {
 +            if let LitKind::Int(n, _) = lit.node;
-                 let literal_str = if is_unary_neg(cast_expr) { format!("-{}", num_lit.integer) } else { num_lit.integer.into() };
-                 lint_unnecessary_cast(cx, expr, &literal_str, cast_from, cast_to);
++            if let Some(src) = snippet_opt(cx, cast_expr.span);
 +            if cast_to.is_floating_point();
 +            if let Some(num_lit) = NumericLiteral::from_lit_kind(&src, &lit.node);
 +            let from_nbits = 128 - n.leading_zeros();
 +            let to_nbits = fp_ty_mantissa_nbits(cast_to);
 +            if from_nbits != 0 && to_nbits != 0 && from_nbits <= to_nbits && num_lit.is_decimal();
 +            then {
-                 if let Some(src) = snippet_opt(cx, lit.span) {
++                lint_unnecessary_cast(cx, expr, num_lit.integer, cast_from, cast_to);
 +                return true
 +            }
 +        }
 +
 +        match lit.node {
 +            LitKind::Int(_, LitIntType::Unsuffixed) if cast_to.is_integral() => {
 +                lint_unnecessary_cast(cx, expr, &literal_str, cast_from, cast_to);
 +            },
 +            LitKind::Float(_, LitFloatType::Unsuffixed) if cast_to.is_floating_point() => {
 +                lint_unnecessary_cast(cx, expr, &literal_str, cast_from, cast_to);
 +            },
 +            LitKind::Int(_, LitIntType::Unsuffixed) | LitKind::Float(_, LitFloatType::Unsuffixed) => {},
 +            LitKind::Int(_, LitIntType::Signed(_) | LitIntType::Unsigned(_))
 +            | LitKind::Float(_, LitFloatType::Suffixed(_))
 +                if cast_from.kind() == cast_to.kind() =>
 +            {
- fn is_unary_neg(expr: &Expr<'_>) -> bool {
-     matches!(expr.kind, ExprKind::Unary(UnOp::Neg, _))
- }
++                if let Some(src) = snippet_opt(cx, cast_expr.span) {
 +                    if let Some(num_lit) = NumericLiteral::from_lit_kind(&src, &lit.node) {
 +                        lint_unnecessary_cast(cx, expr, num_lit.integer, cast_from, cast_to);
 +                    }
 +                }
 +            },
 +            _ => {
 +                if cast_from.kind() == cast_to.kind() && !in_external_macro(cx.sess(), expr.span) {
 +                    span_lint_and_sugg(
 +                        cx,
 +                        UNNECESSARY_CAST,
 +                        expr.span,
 +                        &format!(
 +                            "casting to the same type is unnecessary (`{}` -> `{}`)",
 +                            cast_from, cast_to
 +                        ),
 +                        "try",
 +                        literal_str,
 +                        Applicability::MachineApplicable,
 +                    );
 +                    return true;
 +                }
 +            },
 +        }
 +    }
 +
 +    false
 +}
 +
 +fn lint_unnecessary_cast(cx: &LateContext<'_>, expr: &Expr<'_>, literal_str: &str, cast_from: Ty<'_>, cast_to: Ty<'_>) {
 +    let literal_kind_name = if cast_from.is_integral() { "integer" } else { "float" };
 +    span_lint_and_sugg(
 +        cx,
 +        UNNECESSARY_CAST,
 +        expr.span,
 +        &format!("casting {} literal to `{}` is unnecessary", literal_kind_name, cast_to),
 +        "try",
 +        format!("{}_{}", literal_str.trim_end_matches('.'), cast_to),
 +        Applicability::MachineApplicable,
 +    );
 +}
 +
 +fn get_numeric_literal<'e>(expr: &'e Expr<'e>) -> Option<&'e Lit> {
 +    match expr.kind {
 +        ExprKind::Lit(ref lit) => Some(lit),
 +        ExprKind::Unary(UnOp::Neg, e) => {
 +            if let ExprKind::Lit(ref lit) = e.kind {
 +                Some(lit)
 +            } else {
 +                None
 +            }
 +        },
 +        _ => None,
 +    }
 +}
 +
 +/// Returns the mantissa bits wide of a fp type.
 +/// Will return 0 if the type is not a fp
 +fn fp_ty_mantissa_nbits(typ: Ty<'_>) -> u32 {
 +    match typ.kind() {
 +        ty::Float(FloatTy::F32) => 23,
 +        ty::Float(FloatTy::F64) | ty::Infer(InferTy::FloatVar(_)) => 52,
 +        _ => 0,
 +    }
 +}
index feb5f100de5d5871904bfb47cb469d7b93b2fb82,0000000000000000000000000000000000000000..c0adab790f0d51a2971311113ed506fa244190da
mode 100644,000000..100644
--- /dev/null
@@@ -1,629 -1,0 +1,718 @@@
- use rustc_middle::ty::adjustment::{Adjust, Adjustment, AutoBorrow};
 +use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then};
 +use clippy_utils::source::{snippet_with_applicability, snippet_with_context};
++use clippy_utils::sugg::has_enclosing_paren;
 +use clippy_utils::ty::peel_mid_ty_refs;
 +use clippy_utils::{get_parent_expr, get_parent_node, is_lint_allowed, path_to_local};
 +use rustc_ast::util::parser::{PREC_POSTFIX, PREC_PREFIX};
 +use rustc_data_structures::fx::FxIndexMap;
 +use rustc_errors::Applicability;
 +use rustc_hir::{
 +    BindingAnnotation, Body, BodyId, BorrowKind, Destination, Expr, ExprKind, HirId, MatchSource, Mutability, Node,
 +    Pat, PatKind, UnOp,
 +};
 +use rustc_lint::{LateContext, LateLintPass};
- use std::iter;
++use rustc_middle::ty::adjustment::{Adjust, Adjustment, AutoBorrow, AutoBorrowMutability};
 +use rustc_middle::ty::{self, Ty, TyCtxt, TyS, TypeckResults};
 +use rustc_session::{declare_tool_lint, impl_lint_pass};
 +use rustc_span::{symbol::sym, Span};
-     /// The required mutability
-     target_mut: Mutability,
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for explicit `deref()` or `deref_mut()` method calls.
 +    ///
 +    /// ### Why is this bad?
 +    /// Dereferencing by `&*x` or `&mut *x` is clearer and more concise,
 +    /// when not part of a method chain.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// use std::ops::Deref;
 +    /// let a: &mut String = &mut String::from("foo");
 +    /// let b: &str = a.deref();
 +    /// ```
 +    /// Could be written as:
 +    /// ```rust
 +    /// let a: &mut String = &mut String::from("foo");
 +    /// let b = &*a;
 +    /// ```
 +    ///
 +    /// This lint excludes
 +    /// ```rust,ignore
 +    /// let _ = d.unwrap().deref();
 +    /// ```
 +    #[clippy::version = "1.44.0"]
 +    pub EXPLICIT_DEREF_METHODS,
 +    pedantic,
 +    "Explicit use of deref or deref_mut method while not in a method chain."
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for address of operations (`&`) that are going to
 +    /// be dereferenced immediately by the compiler.
 +    ///
 +    /// ### Why is this bad?
 +    /// Suggests that the receiver of the expression borrows
 +    /// the expression.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// fn fun(_a: &i32) {}
 +    ///
 +    /// // Bad
 +    /// let x: &i32 = &&&&&&5;
 +    /// fun(&x);
 +    ///
 +    /// // Good
 +    /// let x: &i32 = &5;
 +    /// fun(x);
 +    /// ```
 +    #[clippy::version = "pre 1.29.0"]
 +    pub NEEDLESS_BORROW,
 +    style,
 +    "taking a reference that is going to be automatically dereferenced"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for `ref` bindings which create a reference to a reference.
 +    ///
 +    /// ### Why is this bad?
 +    /// The address-of operator at the use site is clearer about the need for a reference.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// // Bad
 +    /// let x = Some("");
 +    /// if let Some(ref x) = x {
 +    ///     // use `x` here
 +    /// }
 +    ///
 +    /// // Good
 +    /// let x = Some("");
 +    /// if let Some(x) = x {
 +    ///     // use `&x` here
 +    /// }
 +    /// ```
 +    #[clippy::version = "1.54.0"]
 +    pub REF_BINDING_TO_REFERENCE,
 +    pedantic,
 +    "`ref` binding to a reference"
 +}
 +
 +impl_lint_pass!(Dereferencing => [
 +    EXPLICIT_DEREF_METHODS,
 +    NEEDLESS_BORROW,
 +    REF_BINDING_TO_REFERENCE,
 +]);
 +
 +#[derive(Default)]
 +pub struct Dereferencing {
 +    state: Option<(State, StateData)>,
 +
 +    // While parsing a `deref` method call in ufcs form, the path to the function is itself an
 +    // expression. This is to store the id of that expression so it can be skipped when
 +    // `check_expr` is called for it.
 +    skip_expr: Option<HirId>,
 +
 +    /// The body the first local was found in. Used to emit lints when the traversal of the body has
 +    /// been finished. Note we can't lint at the end of every body as they can be nested within each
 +    /// other.
 +    current_body: Option<BodyId>,
 +    /// The list of locals currently being checked by the lint.
 +    /// If the value is `None`, then the binding has been seen as a ref pattern, but is not linted.
 +    /// This is needed for or patterns where one of the branches can be linted, but another can not
 +    /// be.
 +    ///
 +    /// e.g. `m!(x) | Foo::Bar(ref x)`
 +    ref_locals: FxIndexMap<HirId, Option<RefPat>>,
 +}
 +
 +struct StateData {
 +    /// Span of the top level expression
 +    span: Span,
-         count: u32,
 +}
 +
 +enum State {
 +    // Any number of deref method calls.
 +    DerefMethod {
 +        // The number of calls in a sequence which changed the referenced type
 +        ty_changed_count: usize,
 +        is_final_ufcs: bool,
++        /// The required mutability
++        target_mut: Mutability,
 +    },
 +    DerefedBorrow {
-                             },
-                             StateData {
-                                 span: expr.span,
++        count: usize,
++        required_precedence: i8,
++        msg: &'static str,
 +    },
 +}
 +
 +// A reference operation considered by this lint pass
 +enum RefOp {
 +    Method(Mutability),
 +    Deref,
 +    AddrOf,
 +}
 +
 +struct RefPat {
 +    /// Whether every usage of the binding is dereferenced.
 +    always_deref: bool,
 +    /// The spans of all the ref bindings for this local.
 +    spans: Vec<Span>,
 +    /// The applicability of this suggestion.
 +    app: Applicability,
 +    /// All the replacements which need to be made.
 +    replacements: Vec<(Span, String)>,
 +}
 +
 +impl<'tcx> LateLintPass<'tcx> for Dereferencing {
 +    #[allow(clippy::too_many_lines)]
 +    fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
 +        // Skip path expressions from deref calls. e.g. `Deref::deref(e)`
 +        if Some(expr.hir_id) == self.skip_expr.take() {
 +            return;
 +        }
 +
 +        if let Some(local) = path_to_local(expr) {
 +            self.check_local_usage(cx, expr, local);
 +        }
 +
 +        // Stop processing sub expressions when a macro call is seen
 +        if expr.span.from_expansion() {
 +            if let Some((state, data)) = self.state.take() {
 +                report(cx, expr, state, data);
 +            }
 +            return;
 +        }
 +
 +        let typeck = cx.typeck_results();
 +        let (kind, sub_expr) = if let Some(x) = try_parse_ref_op(cx.tcx, typeck, expr) {
 +            x
 +        } else {
 +            // The whole chain of reference operations has been seen
 +            if let Some((state, data)) = self.state.take() {
 +                report(cx, expr, state, data);
 +            }
 +            return;
 +        };
 +
 +        match (self.state.take(), kind) {
 +            (None, kind) => {
 +                let parent = get_parent_node(cx.tcx, expr.hir_id);
 +                let expr_ty = typeck.expr_ty(expr);
 +
 +                match kind {
 +                    RefOp::Method(target_mut)
 +                        if !is_lint_allowed(cx, EXPLICIT_DEREF_METHODS, expr.hir_id)
 +                            && is_linted_explicit_deref_position(parent, expr.hir_id, expr.span) =>
 +                    {
 +                        self.state = Some((
 +                            State::DerefMethod {
 +                                ty_changed_count: if deref_method_same_type(expr_ty, typeck.expr_ty(sub_expr)) {
 +                                    0
 +                                } else {
 +                                    1
 +                                },
 +                                is_final_ufcs: matches!(expr.kind, ExprKind::Call(..)),
-                         if let Some((i, adjust)) = iter.by_ref().enumerate().find_map(|(i, adjust)| {
-                             if !matches!(adjust.kind, Adjust::Deref(_)) {
-                                 Some((i, adjust))
-                             } else if !adjust.target.is_ref() {
-                                 // Add one to the number of references found.
-                                 Some((i + 1, adjust))
 +                                target_mut,
 +                            },
++                            StateData { span: expr.span },
 +                        ));
 +                    },
 +                    RefOp::AddrOf => {
 +                        // Find the number of times the borrow is auto-derefed.
 +                        let mut iter = find_adjustments(cx.tcx, typeck, expr).iter();
-                                 None
-                             }
-                         }) {
-                             // Found two consecutive derefs. At least one can be removed.
-                             if i > 1 {
-                                 let target_mut = iter::once(adjust)
-                                     .chain(iter)
-                                     .find_map(|adjust| match adjust.kind {
-                                         Adjust::Borrow(AutoBorrow::Ref(_, m)) => Some(m.into()),
-                                         _ => None,
-                                     })
-                                     // This default should never happen. Auto-deref always reborrows.
-                                     .unwrap_or(Mutability::Not);
-                                 self.state = Some((
-                                     // Subtract one for the current borrow expression, and one to cover the last
-                                     // reference which can't be removed (it's either reborrowed, or needed for
-                                     // auto-deref to happen).
-                                     State::DerefedBorrow {
-                                         count:
-                                             // Truncation here would require more than a `u32::MAX` level reference. The compiler
-                                             // does not support this.
-                                             #[allow(clippy::cast_possible_truncation)]
-                                             { i as u32 - 2 }
-                                     },
-                                     StateData {
-                                         span: expr.span,
-                                         target_mut,
-                                     },
-                                 ));
++                        let mut deref_count = 0usize;
++                        let next_adjust = loop {
++                            match iter.next() {
++                                Some(adjust) => {
++                                    if !matches!(adjust.kind, Adjust::Deref(_)) {
++                                        break Some(adjust);
++                                    } else if !adjust.target.is_ref() {
++                                        deref_count += 1;
++                                        break iter.next();
++                                    }
++                                    deref_count += 1;
++                                },
++                                None => break None,
++                            };
++                        };
++
++                        // Determine the required number of references before any can be removed. In all cases the
++                        // reference made by the current expression will be removed. After that there are four cases to
++                        // handle.
++                        //
++                        // 1. Auto-borrow will trigger in the current position, so no further references are required.
++                        // 2. Auto-deref ends at a reference, or the underlying type, so one extra needs to be left to
++                        //    handle the automatically inserted re-borrow.
++                        // 3. Auto-deref hits a user-defined `Deref` impl, so at least one reference needs to exist to
++                        //    start auto-deref.
++                        // 4. If the chain of non-user-defined derefs ends with a mutable re-borrow, and re-borrow
++                        //    adjustments will not be inserted automatically, then leave one further reference to avoid
++                        //    moving a mutable borrow.
++                        //    e.g.
++                        //        fn foo<T>(x: &mut Option<&mut T>, y: &mut T) {
++                        //            let x = match x {
++                        //                // Removing the borrow will cause `x` to be moved
++                        //                Some(x) => &mut *x,
++                        //                None => y
++                        //            };
++                        //        }
++                        let deref_msg =
++                            "this expression creates a reference which is immediately dereferenced by the compiler";
++                        let borrow_msg = "this expression borrows a value the compiler would automatically borrow";
++
++                        let (required_refs, required_precedence, msg) = if is_auto_borrow_position(parent, expr.hir_id)
++                        {
++                            (1, PREC_POSTFIX, if deref_count == 1 { borrow_msg } else { deref_msg })
++                        } else if let Some(&Adjust::Borrow(AutoBorrow::Ref(_, mutability))) =
++                            next_adjust.map(|a| &a.kind)
++                        {
++                            if matches!(mutability, AutoBorrowMutability::Mut { .. })
++                                && !is_auto_reborrow_position(parent)
++                            {
++                                (3, 0, deref_msg)
 +                            } else {
-             (Some((State::DerefMethod { ty_changed_count, .. }, data)), RefOp::Method(_)) => {
++                                (2, 0, deref_msg)
 +                            }
++                        } else {
++                            (2, 0, deref_msg)
++                        };
++
++                        if deref_count >= required_refs {
++                            self.state = Some((
++                                State::DerefedBorrow {
++                                    // One of the required refs is for the current borrow expression, the remaining ones
++                                    // can't be removed without breaking the code. See earlier comment.
++                                    count: deref_count - required_refs,
++                                    required_precedence,
++                                    msg,
++                                },
++                                StateData { span: expr.span },
++                            ));
 +                        }
 +                    },
 +                    _ => (),
 +                }
 +            },
-             (Some((State::DerefedBorrow { count }, data)), RefOp::AddrOf) if count != 0 => {
-                 self.state = Some((State::DerefedBorrow { count: count - 1 }, data));
++            (
++                Some((
++                    State::DerefMethod {
++                        target_mut,
++                        ty_changed_count,
++                        ..
++                    },
++                    data,
++                )),
++                RefOp::Method(_),
++            ) => {
 +                self.state = Some((
 +                    State::DerefMethod {
 +                        ty_changed_count: if deref_method_same_type(typeck.expr_ty(expr), typeck.expr_ty(sub_expr)) {
 +                            ty_changed_count
 +                        } else {
 +                            ty_changed_count + 1
 +                        },
 +                        is_final_ufcs: matches!(expr.kind, ExprKind::Call(..)),
++                        target_mut,
 +                    },
 +                    data,
 +                ));
 +            },
-                 if data.target_mut == Mutability::Not && matches!(ty.kind(), ty::Ref(_, _, Mutability::Mut)) {
++            (
++                Some((
++                    State::DerefedBorrow {
++                        count,
++                        required_precedence,
++                        msg,
++                    },
++                    data,
++                )),
++                RefOp::AddrOf,
++            ) if count != 0 => {
++                self.state = Some((
++                    State::DerefedBorrow {
++                        count: count - 1,
++                        required_precedence,
++                        msg,
++                    },
++                    data,
++                ));
 +            },
 +
 +            (Some((state, data)), _) => report(cx, expr, state, data),
 +        }
 +    }
 +
 +    fn check_pat(&mut self, cx: &LateContext<'tcx>, pat: &'tcx Pat<'_>) {
 +        if let PatKind::Binding(BindingAnnotation::Ref, id, name, _) = pat.kind {
 +            if let Some(opt_prev_pat) = self.ref_locals.get_mut(&id) {
 +                // This binding id has been seen before. Add this pattern to the list of changes.
 +                if let Some(prev_pat) = opt_prev_pat {
 +                    if pat.span.from_expansion() {
 +                        // Doesn't match the context of the previous pattern. Can't lint here.
 +                        *opt_prev_pat = None;
 +                    } else {
 +                        prev_pat.spans.push(pat.span);
 +                        prev_pat.replacements.push((
 +                            pat.span,
 +                            snippet_with_context(cx, name.span, pat.span.ctxt(), "..", &mut prev_pat.app)
 +                                .0
 +                                .into(),
 +                        ));
 +                    }
 +                }
 +                return;
 +            }
 +
 +            if_chain! {
 +                if !pat.span.from_expansion();
 +                if let ty::Ref(_, tam, _) = *cx.typeck_results().pat_ty(pat).kind();
 +                // only lint immutable refs, because borrowed `&mut T` cannot be moved out
 +                if let ty::Ref(_, _, Mutability::Not) = *tam.kind();
 +                then {
 +                    let mut app = Applicability::MachineApplicable;
 +                    let snip = snippet_with_context(cx, name.span, pat.span.ctxt(), "..", &mut app).0;
 +                    self.current_body = self.current_body.or(cx.enclosing_body);
 +                    self.ref_locals.insert(
 +                        id,
 +                        Some(RefPat {
 +                            always_deref: true,
 +                            spans: vec![pat.span],
 +                            app,
 +                            replacements: vec![(pat.span, snip.into())],
 +                        }),
 +                    );
 +                }
 +            }
 +        }
 +    }
 +
 +    fn check_body_post(&mut self, cx: &LateContext<'tcx>, body: &'tcx Body<'_>) {
 +        if Some(body.id()) == self.current_body {
 +            for pat in self.ref_locals.drain(..).filter_map(|(_, x)| x) {
 +                let replacements = pat.replacements;
 +                let app = pat.app;
 +                span_lint_and_then(
 +                    cx,
 +                    if pat.always_deref {
 +                        NEEDLESS_BORROW
 +                    } else {
 +                        REF_BINDING_TO_REFERENCE
 +                    },
 +                    pat.spans,
 +                    "this pattern creates a reference to a reference",
 +                    |diag| {
 +                        diag.multipart_suggestion("try this", replacements, app);
 +                    },
 +                );
 +            }
 +            self.current_body = None;
 +        }
 +    }
 +}
 +
 +fn try_parse_ref_op<'tcx>(
 +    tcx: TyCtxt<'tcx>,
 +    typeck: &'tcx TypeckResults<'_>,
 +    expr: &'tcx Expr<'_>,
 +) -> Option<(RefOp, &'tcx Expr<'tcx>)> {
 +    let (def_id, arg) = match expr.kind {
 +        ExprKind::MethodCall(_, [arg], _) => (typeck.type_dependent_def_id(expr.hir_id)?, arg),
 +        ExprKind::Call(
 +            Expr {
 +                kind: ExprKind::Path(path),
 +                hir_id,
 +                ..
 +            },
 +            [arg],
 +        ) => (typeck.qpath_res(path, *hir_id).opt_def_id()?, arg),
 +        ExprKind::Unary(UnOp::Deref, sub_expr) if !typeck.expr_ty(sub_expr).is_unsafe_ptr() => {
 +            return Some((RefOp::Deref, sub_expr));
 +        },
 +        ExprKind::AddrOf(BorrowKind::Ref, _, sub_expr) => return Some((RefOp::AddrOf, sub_expr)),
 +        _ => return None,
 +    };
 +    if tcx.is_diagnostic_item(sym::deref_method, def_id) {
 +        Some((RefOp::Method(Mutability::Not), arg))
 +    } else if tcx.trait_of_item(def_id)? == tcx.lang_items().deref_mut_trait()? {
 +        Some((RefOp::Method(Mutability::Mut), arg))
 +    } else {
 +        None
 +    }
 +}
 +
 +// Checks whether the type for a deref call actually changed the type, not just the mutability of
 +// the reference.
 +fn deref_method_same_type(result_ty: Ty<'_>, arg_ty: Ty<'_>) -> bool {
 +    match (result_ty.kind(), arg_ty.kind()) {
 +        (ty::Ref(_, result_ty, _), ty::Ref(_, arg_ty, _)) => TyS::same_type(result_ty, arg_ty),
 +
 +        // The result type for a deref method is always a reference
 +        // Not matching the previous pattern means the argument type is not a reference
 +        // This means that the type did change
 +        _ => false,
 +    }
 +}
 +
 +// Checks whether the parent node is a suitable context for switching from a deref method to the
 +// deref operator.
 +fn is_linted_explicit_deref_position(parent: Option<Node<'_>>, child_id: HirId, child_span: Span) -> bool {
 +    let parent = match parent {
 +        Some(Node::Expr(e)) if e.span.ctxt() == child_span.ctxt() => e,
 +        _ => return true,
 +    };
 +    match parent.kind {
 +        // Leave deref calls in the middle of a method chain.
 +        // e.g. x.deref().foo()
 +        ExprKind::MethodCall(_, [self_arg, ..], _) if self_arg.hir_id == child_id => false,
 +
 +        // Leave deref calls resulting in a called function
 +        // e.g. (x.deref())()
 +        ExprKind::Call(func_expr, _) if func_expr.hir_id == child_id => false,
 +
 +        // Makes an ugly suggestion
 +        // e.g. *x.deref() => *&*x
 +        ExprKind::Unary(UnOp::Deref, _)
 +        // Postfix expressions would require parens
 +        | ExprKind::Match(_, _, MatchSource::TryDesugar | MatchSource::AwaitDesugar)
 +        | ExprKind::Field(..)
 +        | ExprKind::Index(..)
 +        | ExprKind::Err => false,
 +
 +        ExprKind::Box(..)
 +        | ExprKind::ConstBlock(..)
 +        | ExprKind::Array(_)
 +        | ExprKind::Call(..)
 +        | ExprKind::MethodCall(..)
 +        | ExprKind::Tup(..)
 +        | ExprKind::Binary(..)
 +        | ExprKind::Unary(..)
 +        | ExprKind::Lit(..)
 +        | ExprKind::Cast(..)
 +        | ExprKind::Type(..)
 +        | ExprKind::DropTemps(..)
 +        | ExprKind::If(..)
 +        | ExprKind::Loop(..)
 +        | ExprKind::Match(..)
 +        | ExprKind::Let(..)
 +        | ExprKind::Closure(..)
 +        | ExprKind::Block(..)
 +        | ExprKind::Assign(..)
 +        | ExprKind::AssignOp(..)
 +        | ExprKind::Path(..)
 +        | ExprKind::AddrOf(..)
 +        | ExprKind::Break(..)
 +        | ExprKind::Continue(..)
 +        | ExprKind::Ret(..)
 +        | ExprKind::InlineAsm(..)
 +        | ExprKind::Struct(..)
 +        | ExprKind::Repeat(..)
 +        | ExprKind::Yield(..) => true,
 +    }
 +}
 +
++/// Checks if the given expression is in a position which can be auto-reborrowed.
++/// Note: This is only correct assuming auto-deref is already occurring.
++fn is_auto_reborrow_position(parent: Option<Node<'_>>) -> bool {
++    match parent {
++        Some(Node::Expr(parent)) => matches!(parent.kind, ExprKind::MethodCall(..) | ExprKind::Call(..)),
++        Some(Node::Local(_)) => true,
++        _ => false,
++    }
++}
++
++/// Checks if the given expression is a position which can auto-borrow.
++fn is_auto_borrow_position(parent: Option<Node<'_>>, child_id: HirId) -> bool {
++    if let Some(Node::Expr(parent)) = parent {
++        match parent.kind {
++            ExprKind::MethodCall(_, [self_arg, ..], _) => self_arg.hir_id == child_id,
++            ExprKind::Field(..) => true,
++            ExprKind::Call(f, _) => f.hir_id == child_id,
++            _ => false,
++        }
++    } else {
++        false
++    }
++}
++
 +/// Adjustments are sometimes made in the parent block rather than the expression itself.
 +fn find_adjustments<'tcx>(
 +    tcx: TyCtxt<'tcx>,
 +    typeck: &'tcx TypeckResults<'_>,
 +    expr: &'tcx Expr<'_>,
 +) -> &'tcx [Adjustment<'tcx>] {
 +    let map = tcx.hir();
 +    let mut iter = map.parent_iter(expr.hir_id);
 +    let mut prev = expr;
 +
 +    loop {
 +        match typeck.expr_adjustments(prev) {
 +            [] => (),
 +            a => break a,
 +        };
 +
 +        match iter.next().map(|(_, x)| x) {
 +            Some(Node::Block(_)) => {
 +                if let Some((_, Node::Expr(e))) = iter.next() {
 +                    prev = e;
 +                } else {
 +                    // This shouldn't happen. Blocks are always contained in an expression.
 +                    break &[];
 +                }
 +            },
 +            Some(Node::Expr(&Expr {
 +                kind: ExprKind::Break(Destination { target_id: Ok(id), .. }, _),
 +                ..
 +            })) => {
 +                if let Some(Node::Expr(e)) = map.find(id) {
 +                    prev = e;
 +                    iter = map.parent_iter(id);
 +                } else {
 +                    // This shouldn't happen. The destination should exist.
 +                    break &[];
 +                }
 +            },
 +            _ => break &[],
 +        }
 +    }
 +}
 +
 +#[allow(clippy::needless_pass_by_value)]
 +fn report(cx: &LateContext<'_>, expr: &Expr<'_>, state: State, data: StateData) {
 +    match state {
 +        State::DerefMethod {
 +            ty_changed_count,
 +            is_final_ufcs,
++            target_mut,
 +        } => {
 +            let mut app = Applicability::MachineApplicable;
 +            let (expr_str, expr_is_macro_call) = snippet_with_context(cx, expr.span, data.span.ctxt(), "..", &mut app);
 +            let ty = cx.typeck_results().expr_ty(expr);
 +            let (_, ref_count) = peel_mid_ty_refs(ty);
 +            let deref_str = if ty_changed_count >= ref_count && ref_count != 0 {
 +                // a deref call changing &T -> &U requires two deref operators the first time
 +                // this occurs. One to remove the reference, a second to call the deref impl.
 +                "*".repeat(ty_changed_count + 1)
 +            } else {
 +                "*".repeat(ty_changed_count)
 +            };
 +            let addr_of_str = if ty_changed_count < ref_count {
 +                // Check if a reborrow from &mut T -> &T is required.
-             } else if data.target_mut == Mutability::Mut {
++                if target_mut == Mutability::Not && matches!(ty.kind(), ty::Ref(_, _, Mutability::Mut)) {
 +                    "&*"
 +                } else {
 +                    ""
 +                }
-                 match data.target_mut {
++            } else if target_mut == Mutability::Mut {
 +                "&mut "
 +            } else {
 +                "&"
 +            };
 +
 +            let expr_str = if !expr_is_macro_call && is_final_ufcs && expr.precedence().order() < PREC_PREFIX {
 +                format!("({})", expr_str)
 +            } else {
 +                expr_str.into_owned()
 +            };
 +
 +            span_lint_and_sugg(
 +                cx,
 +                EXPLICIT_DEREF_METHODS,
 +                data.span,
-         State::DerefedBorrow { .. } => {
++                match target_mut {
 +                    Mutability::Not => "explicit `deref` method call",
 +                    Mutability::Mut => "explicit `deref_mut` method call",
 +                },
 +                "try this",
 +                format!("{}{}{}", addr_of_str, deref_str, expr_str),
 +                app,
 +            );
 +        },
-                 &format!(
-                     "this expression borrows a reference (`{}`) that is immediately dereferenced by the compiler",
-                     cx.typeck_results().expr_ty(expr),
-                 ),
++        State::DerefedBorrow {
++            required_precedence,
++            msg,
++            ..
++        } => {
 +            let mut app = Applicability::MachineApplicable;
 +            let snip = snippet_with_context(cx, expr.span, data.span.ctxt(), "..", &mut app).0;
 +            span_lint_and_sugg(
 +                cx,
 +                NEEDLESS_BORROW,
 +                data.span,
-                 snip.into(),
++                msg,
 +                "change this to",
++                if required_precedence > expr.precedence().order() && !has_enclosing_paren(&snip) {
++                    format!("({})", snip)
++                } else {
++                    snip.into()
++                },
 +                app,
 +            );
 +        },
 +    }
 +}
 +
 +impl Dereferencing {
 +    fn check_local_usage(&mut self, cx: &LateContext<'_>, e: &Expr<'_>, local: HirId) {
 +        if let Some(outer_pat) = self.ref_locals.get_mut(&local) {
 +            if let Some(pat) = outer_pat {
 +                // Check for auto-deref
 +                if !matches!(
 +                    cx.typeck_results().expr_adjustments(e),
 +                    [
 +                        Adjustment {
 +                            kind: Adjust::Deref(_),
 +                            ..
 +                        },
 +                        Adjustment {
 +                            kind: Adjust::Deref(_),
 +                            ..
 +                        },
 +                        ..
 +                    ]
 +                ) {
 +                    match get_parent_expr(cx, e) {
 +                        // Field accesses are the same no matter the number of references.
 +                        Some(Expr {
 +                            kind: ExprKind::Field(..),
 +                            ..
 +                        }) => (),
 +                        Some(&Expr {
 +                            span,
 +                            kind: ExprKind::Unary(UnOp::Deref, _),
 +                            ..
 +                        }) if !span.from_expansion() => {
 +                            // Remove explicit deref.
 +                            let snip = snippet_with_context(cx, e.span, span.ctxt(), "..", &mut pat.app).0;
 +                            pat.replacements.push((span, snip.into()));
 +                        },
 +                        Some(parent) if !parent.span.from_expansion() => {
 +                            // Double reference might be needed at this point.
 +                            if parent.precedence().order() == PREC_POSTFIX {
 +                                // Parentheses would be needed here, don't lint.
 +                                *outer_pat = None;
 +                            } else {
 +                                pat.always_deref = false;
 +                                let snip = snippet_with_context(cx, e.span, parent.span.ctxt(), "..", &mut pat.app).0;
 +                                pat.replacements.push((e.span, format!("&{}", snip)));
 +                            }
 +                        },
 +                        _ if !e.span.from_expansion() => {
 +                            // Double reference might be needed at this point.
 +                            pat.always_deref = false;
 +                            let snip = snippet_with_applicability(cx, e.span, "..", &mut pat.app);
 +                            pat.replacements.push((e.span, format!("&{}", snip)));
 +                        },
 +                        // Edge case for macros. The span of the identifier will usually match the context of the
 +                        // binding, but not if the identifier was created in a macro. e.g. `concat_idents` and proc
 +                        // macros
 +                        _ => *outer_pat = None,
 +                    }
 +                }
 +            }
 +        }
 +    }
 +}
index 4f89e5674306817ab83b3f3f791e80716aed6c4c,0000000000000000000000000000000000000000..1f4353fa4f72bd73a6028f80c49e71d1b552230e
mode 100644,000000..100644
--- /dev/null
@@@ -1,297 -1,0 +1,300 @@@
 +//! lint on enum variants that are prefixed or suffixed by the same characters
 +
 +use clippy_utils::diagnostics::{span_lint, span_lint_and_help};
 +use clippy_utils::source::is_present_in_source;
 +use clippy_utils::str_utils::{camel_case_split, count_match_end, count_match_start};
 +use rustc_hir::{EnumDef, Item, ItemKind, Variant};
 +use rustc_lint::{LateContext, LateLintPass};
 +use rustc_session::{declare_tool_lint, impl_lint_pass};
 +use rustc_span::source_map::Span;
 +use rustc_span::symbol::Symbol;
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Detects enumeration variants that are prefixed or suffixed
 +    /// by the same characters.
 +    ///
 +    /// ### Why is this bad?
 +    /// Enumeration variant names should specify their variant,
 +    /// not repeat the enumeration name.
 +    ///
 +    /// ### Limitations
 +    /// Characters with no casing will be considered when comparing prefixes/suffixes
 +    /// This applies to numbers and non-ascii characters without casing
 +    /// e.g. `Foo1` and `Foo2` is considered to have different prefixes
 +    /// (the prefixes are `Foo1` and `Foo2` respectively), as also `Bar螃`, `Bar蟹`
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// enum Cake {
 +    ///     BlackForestCake,
 +    ///     HummingbirdCake,
 +    ///     BattenbergCake,
 +    /// }
 +    /// ```
 +    /// Could be written as:
 +    /// ```rust
 +    /// enum Cake {
 +    ///     BlackForest,
 +    ///     Hummingbird,
 +    ///     Battenberg,
 +    /// }
 +    /// ```
 +    #[clippy::version = "pre 1.29.0"]
 +    pub ENUM_VARIANT_NAMES,
 +    style,
 +    "enums where all variants share a prefix/postfix"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Detects type names that are prefixed or suffixed by the
 +    /// containing module's name.
 +    ///
 +    /// ### Why is this bad?
 +    /// It requires the user to type the module name twice.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// mod cake {
 +    ///     struct BlackForestCake;
 +    /// }
 +    /// ```
 +    /// Could be written as:
 +    /// ```rust
 +    /// mod cake {
 +    ///     struct BlackForest;
 +    /// }
 +    /// ```
 +    #[clippy::version = "1.33.0"]
 +    pub MODULE_NAME_REPETITIONS,
 +    pedantic,
 +    "type names prefixed/postfixed with their containing module's name"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for modules that have the same name as their
 +    /// parent module
 +    ///
 +    /// ### Why is this bad?
 +    /// A typical beginner mistake is to have `mod foo;` and
 +    /// again `mod foo { ..
 +    /// }` in `foo.rs`.
 +    /// The expectation is that items inside the inner `mod foo { .. }` are then
 +    /// available
 +    /// through `foo::x`, but they are only available through
 +    /// `foo::foo::x`.
 +    /// If this is done on purpose, it would be better to choose a more
 +    /// representative module name.
 +    ///
 +    /// ### Example
 +    /// ```ignore
 +    /// // lib.rs
 +    /// mod foo;
 +    /// // foo.rs
 +    /// mod foo {
 +    ///     ...
 +    /// }
 +    /// ```
 +    #[clippy::version = "pre 1.29.0"]
 +    pub MODULE_INCEPTION,
 +    style,
 +    "modules that have the same name as their parent module"
 +}
 +
 +pub struct EnumVariantNames {
 +    modules: Vec<(Symbol, String)>,
 +    threshold: u64,
 +    avoid_breaking_exported_api: bool,
 +}
 +
 +impl EnumVariantNames {
 +    #[must_use]
 +    pub fn new(threshold: u64, avoid_breaking_exported_api: bool) -> Self {
 +        Self {
 +            modules: Vec::new(),
 +            threshold,
 +            avoid_breaking_exported_api,
 +        }
 +    }
 +}
 +
 +impl_lint_pass!(EnumVariantNames => [
 +    ENUM_VARIANT_NAMES,
 +    MODULE_NAME_REPETITIONS,
 +    MODULE_INCEPTION
 +]);
 +
 +fn check_enum_start(cx: &LateContext<'_>, item_name: &str, variant: &Variant<'_>) {
 +    let name = variant.ident.name.as_str();
 +    let item_name_chars = item_name.chars().count();
 +
 +    if count_match_start(item_name, name).char_count == item_name_chars
 +        && name.chars().nth(item_name_chars).map_or(false, |c| !c.is_lowercase())
 +        && name.chars().nth(item_name_chars + 1).map_or(false, |c| !c.is_numeric())
 +    {
 +        span_lint(
 +            cx,
 +            ENUM_VARIANT_NAMES,
 +            variant.span,
 +            "variant name starts with the enum's name",
 +        );
 +    }
 +}
 +
 +fn check_enum_end(cx: &LateContext<'_>, item_name: &str, variant: &Variant<'_>) {
 +    let name = variant.ident.name.as_str();
 +    let item_name_chars = item_name.chars().count();
 +
 +    if count_match_end(item_name, name).char_count == item_name_chars {
 +        span_lint(
 +            cx,
 +            ENUM_VARIANT_NAMES,
 +            variant.span,
 +            "variant name ends with the enum's name",
 +        );
 +    }
 +}
 +
 +fn check_variant(cx: &LateContext<'_>, threshold: u64, def: &EnumDef<'_>, item_name: &str, span: Span) {
 +    if (def.variants.len() as u64) < threshold {
 +        return;
 +    }
 +
 +    let first = &def.variants[0].ident.name.as_str();
 +    let mut pre = camel_case_split(first);
 +    let mut post = pre.clone();
 +    post.reverse();
 +    for var in def.variants {
 +        check_enum_start(cx, item_name, var);
 +        check_enum_end(cx, item_name, var);
 +        let name = var.ident.name.as_str();
 +
 +        let variant_split = camel_case_split(name);
++        if variant_split.len() == 1 {
++            return;
++        }
 +
 +        pre = pre
 +            .iter()
 +            .zip(variant_split.iter())
 +            .take_while(|(a, b)| a == b)
 +            .map(|e| *e.0)
 +            .collect();
 +        post = post
 +            .iter()
 +            .zip(variant_split.iter().rev())
 +            .take_while(|(a, b)| a == b)
 +            .map(|e| *e.0)
 +            .collect();
 +    }
 +    let (what, value) = match (pre.is_empty(), post.is_empty()) {
 +        (true, true) => return,
 +        (false, _) => ("pre", pre.join("")),
 +        (true, false) => {
 +            post.reverse();
 +            ("post", post.join(""))
 +        },
 +    };
 +    span_lint_and_help(
 +        cx,
 +        ENUM_VARIANT_NAMES,
 +        span,
 +        &format!("all variants have the same {}fix: `{}`", what, value),
 +        None,
 +        &format!(
 +            "remove the {}fixes and use full paths to \
 +             the variants instead of glob imports",
 +            what
 +        ),
 +    );
 +}
 +
 +#[must_use]
 +fn to_camel_case(item_name: &str) -> String {
 +    let mut s = String::new();
 +    let mut up = true;
 +    for c in item_name.chars() {
 +        if c.is_uppercase() {
 +            // we only turn snake case text into CamelCase
 +            return item_name.to_string();
 +        }
 +        if c == '_' {
 +            up = true;
 +            continue;
 +        }
 +        if up {
 +            up = false;
 +            s.extend(c.to_uppercase());
 +        } else {
 +            s.push(c);
 +        }
 +    }
 +    s
 +}
 +
 +impl LateLintPass<'_> for EnumVariantNames {
 +    fn check_item_post(&mut self, _cx: &LateContext<'_>, _item: &Item<'_>) {
 +        let last = self.modules.pop();
 +        assert!(last.is_some());
 +    }
 +
 +    #[allow(clippy::similar_names)]
 +    fn check_item(&mut self, cx: &LateContext<'_>, item: &Item<'_>) {
 +        let item_name = item.ident.name.as_str();
 +        let item_camel = to_camel_case(item_name);
 +        if !item.span.from_expansion() && is_present_in_source(cx, item.span) {
 +            if let Some(&(ref mod_name, ref mod_camel)) = self.modules.last() {
 +                // constants don't have surrounding modules
 +                if !mod_camel.is_empty() {
 +                    if mod_name == &item.ident.name {
 +                        if let ItemKind::Mod(..) = item.kind {
 +                            span_lint(
 +                                cx,
 +                                MODULE_INCEPTION,
 +                                item.span,
 +                                "module has the same name as its containing module",
 +                            );
 +                        }
 +                    }
 +                    // The `module_name_repetitions` lint should only trigger if the item has the module in its
 +                    // name. Having the same name is accepted.
 +                    if item.vis.node.is_pub() && item_camel.len() > mod_camel.len() {
 +                        let matching = count_match_start(mod_camel, &item_camel);
 +                        let rmatching = count_match_end(mod_camel, &item_camel);
 +                        let nchars = mod_camel.chars().count();
 +
 +                        let is_word_beginning = |c: char| c == '_' || c.is_uppercase() || c.is_numeric();
 +
 +                        if matching.char_count == nchars {
 +                            match item_camel.chars().nth(nchars) {
 +                                Some(c) if is_word_beginning(c) => span_lint(
 +                                    cx,
 +                                    MODULE_NAME_REPETITIONS,
 +                                    item.span,
 +                                    "item name starts with its containing module's name",
 +                                ),
 +                                _ => (),
 +                            }
 +                        }
 +                        if rmatching.char_count == nchars {
 +                            span_lint(
 +                                cx,
 +                                MODULE_NAME_REPETITIONS,
 +                                item.span,
 +                                "item name ends with its containing module's name",
 +                            );
 +                        }
 +                    }
 +                }
 +            }
 +        }
 +        if let ItemKind::Enum(ref def, _) = item.kind {
 +            if !(self.avoid_breaking_exported_api && cx.access_levels.is_exported(item.def_id)) {
 +                check_variant(cx, self.threshold, def, item_name, item.span);
 +            }
 +        }
 +        self.modules.push((item.ident.name, item_camel));
 +    }
 +}
index df75b815436b896bd20160303ebe983d8a79b5d0,0000000000000000000000000000000000000000..24d7613e6f8ca6d2061d3d3c3c1e2c6958a9a983
mode 100644,000000..100644
--- /dev/null
@@@ -1,253 -1,0 +1,320 @@@
- use rustc_hir::{BinOpKind, BorrowKind, Expr, ExprKind};
 +use clippy_utils::diagnostics::{multispan_sugg, span_lint, span_lint_and_then};
++use clippy_utils::get_enclosing_block;
 +use clippy_utils::macros::{find_assert_eq_args, first_node_macro_backtrace};
 +use clippy_utils::source::snippet;
 +use clippy_utils::ty::{implements_trait, is_copy};
 +use clippy_utils::{ast_utils::is_useless_with_eq_exprs, eq_expr_value, is_in_test_function};
 +use if_chain::if_chain;
 +use rustc_errors::Applicability;
++use rustc_hir::{
++    def::Res, def_id::DefId, BinOpKind, BorrowKind, Expr, ExprKind, GenericArg, ItemKind, QPath, Ty, TyKind,
++};
 +use rustc_lint::{LateContext, LateLintPass};
++use rustc_middle::ty::{self, TyS};
 +use rustc_session::{declare_lint_pass, declare_tool_lint};
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for equal operands to comparison, logical and
 +    /// bitwise, difference and division binary operators (`==`, `>`, etc., `&&`,
 +    /// `||`, `&`, `|`, `^`, `-` and `/`).
 +    ///
 +    /// ### Why is this bad?
 +    /// This is usually just a typo or a copy and paste error.
 +    ///
 +    /// ### Known problems
 +    /// False negatives: We had some false positives regarding
 +    /// calls (notably [racer](https://github.com/phildawes/racer) had one instance
 +    /// of `x.pop() && x.pop()`), so we removed matching any function or method
 +    /// calls. We may introduce a list of known pure functions in the future.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// # let x = 1;
 +    /// if x + 1 == x + 1 {}
 +    /// ```
 +    /// or
 +    /// ```rust
 +    /// # let a = 3;
 +    /// # let b = 4;
 +    /// assert_eq!(a, a);
 +    /// ```
 +    #[clippy::version = "pre 1.29.0"]
 +    pub EQ_OP,
 +    correctness,
 +    "equal operands on both sides of a comparison or bitwise combination (e.g., `x == x`)"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for arguments to `==` which have their address
 +    /// taken to satisfy a bound
 +    /// and suggests to dereference the other argument instead
 +    ///
 +    /// ### Why is this bad?
 +    /// It is more idiomatic to dereference the other argument.
 +    ///
 +    /// ### Known problems
 +    /// None
 +    ///
 +    /// ### Example
 +    /// ```ignore
 +    /// // Bad
 +    /// &x == y
 +    ///
 +    /// // Good
 +    /// x == *y
 +    /// ```
 +    #[clippy::version = "pre 1.29.0"]
 +    pub OP_REF,
 +    style,
 +    "taking a reference to satisfy the type constraints on `==`"
 +}
 +
 +declare_lint_pass!(EqOp => [EQ_OP, OP_REF]);
 +
 +impl<'tcx> LateLintPass<'tcx> for EqOp {
 +    #[allow(clippy::similar_names, clippy::too_many_lines)]
 +    fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) {
 +        if_chain! {
 +            if let Some((macro_call, macro_name)) = first_node_macro_backtrace(cx, e).find_map(|macro_call| {
 +                let name = cx.tcx.item_name(macro_call.def_id);
 +                matches!(name.as_str(), "assert_eq" | "assert_ne" | "debug_assert_eq" | "debug_assert_ne")
 +                    .then(|| (macro_call, name))
 +            });
 +            if let Some((lhs, rhs, _)) = find_assert_eq_args(cx, e, macro_call.expn);
 +            if eq_expr_value(cx, lhs, rhs);
 +            if macro_call.is_local();
 +            if !is_in_test_function(cx.tcx, e.hir_id);
 +            then {
 +                span_lint(
 +                    cx,
 +                    EQ_OP,
 +                    lhs.span.to(rhs.span),
 +                    &format!("identical args used in this `{}!` macro call", macro_name),
 +                );
 +            }
 +        }
 +        if let ExprKind::Binary(op, left, right) = e.kind {
 +            if e.span.from_expansion() {
 +                return;
 +            }
 +            let macro_with_not_op = |expr_kind: &ExprKind<'_>| {
 +                if let ExprKind::Unary(_, expr) = *expr_kind {
 +                    expr.span.from_expansion()
 +                } else {
 +                    false
 +                }
 +            };
 +            if macro_with_not_op(&left.kind) || macro_with_not_op(&right.kind) {
 +                return;
 +            }
 +            if is_useless_with_eq_exprs(op.node.into())
 +                && eq_expr_value(cx, left, right)
 +                && !is_in_test_function(cx.tcx, e.hir_id)
 +            {
 +                span_lint(
 +                    cx,
 +                    EQ_OP,
 +                    e.span,
 +                    &format!("equal expressions as operands to `{}`", op.node.as_str()),
 +                );
 +                return;
 +            }
 +            let (trait_id, requires_ref) = match op.node {
 +                BinOpKind::Add => (cx.tcx.lang_items().add_trait(), false),
 +                BinOpKind::Sub => (cx.tcx.lang_items().sub_trait(), false),
 +                BinOpKind::Mul => (cx.tcx.lang_items().mul_trait(), false),
 +                BinOpKind::Div => (cx.tcx.lang_items().div_trait(), false),
 +                BinOpKind::Rem => (cx.tcx.lang_items().rem_trait(), false),
 +                // don't lint short circuiting ops
 +                BinOpKind::And | BinOpKind::Or => return,
 +                BinOpKind::BitXor => (cx.tcx.lang_items().bitxor_trait(), false),
 +                BinOpKind::BitAnd => (cx.tcx.lang_items().bitand_trait(), false),
 +                BinOpKind::BitOr => (cx.tcx.lang_items().bitor_trait(), false),
 +                BinOpKind::Shl => (cx.tcx.lang_items().shl_trait(), false),
 +                BinOpKind::Shr => (cx.tcx.lang_items().shr_trait(), false),
 +                BinOpKind::Ne | BinOpKind::Eq => (cx.tcx.lang_items().eq_trait(), true),
 +                BinOpKind::Lt | BinOpKind::Le | BinOpKind::Ge | BinOpKind::Gt => {
 +                    (cx.tcx.lang_items().partial_ord_trait(), true)
 +                },
 +            };
 +            if let Some(trait_id) = trait_id {
 +                #[allow(clippy::match_same_arms)]
 +                match (&left.kind, &right.kind) {
 +                    // do not suggest to dereference literals
 +                    (&ExprKind::Lit(..), _) | (_, &ExprKind::Lit(..)) => {},
 +                    // &foo == &bar
 +                    (&ExprKind::AddrOf(BorrowKind::Ref, _, l), &ExprKind::AddrOf(BorrowKind::Ref, _, r)) => {
 +                        let lty = cx.typeck_results().expr_ty(l);
 +                        let rty = cx.typeck_results().expr_ty(r);
 +                        let lcpy = is_copy(cx, lty);
 +                        let rcpy = is_copy(cx, rty);
++                        if let Some((self_ty, other_ty)) = in_impl(cx, e, trait_id) {
++                            if (are_equal(cx, rty, self_ty) && are_equal(cx, lty, other_ty))
++                                || (are_equal(cx, rty, other_ty) && are_equal(cx, lty, self_ty))
++                            {
++                                return; // Don't lint
++                            }
++                        }
 +                        // either operator autorefs or both args are copyable
 +                        if (requires_ref || (lcpy && rcpy)) && implements_trait(cx, lty, trait_id, &[rty.into()]) {
 +                            span_lint_and_then(
 +                                cx,
 +                                OP_REF,
 +                                e.span,
 +                                "needlessly taken reference of both operands",
 +                                |diag| {
 +                                    let lsnip = snippet(cx, l.span, "...").to_string();
 +                                    let rsnip = snippet(cx, r.span, "...").to_string();
 +                                    multispan_sugg(
 +                                        diag,
 +                                        "use the values directly",
 +                                        vec![(left.span, lsnip), (right.span, rsnip)],
 +                                    );
 +                                },
 +                            );
 +                        } else if lcpy
 +                            && !rcpy
 +                            && implements_trait(cx, lty, trait_id, &[cx.typeck_results().expr_ty(right).into()])
 +                        {
 +                            span_lint_and_then(
 +                                cx,
 +                                OP_REF,
 +                                e.span,
 +                                "needlessly taken reference of left operand",
 +                                |diag| {
 +                                    let lsnip = snippet(cx, l.span, "...").to_string();
 +                                    diag.span_suggestion(
 +                                        left.span,
 +                                        "use the left value directly",
 +                                        lsnip,
 +                                        Applicability::MaybeIncorrect, // FIXME #2597
 +                                    );
 +                                },
 +                            );
 +                        } else if !lcpy
 +                            && rcpy
 +                            && implements_trait(cx, cx.typeck_results().expr_ty(left), trait_id, &[rty.into()])
 +                        {
 +                            span_lint_and_then(
 +                                cx,
 +                                OP_REF,
 +                                e.span,
 +                                "needlessly taken reference of right operand",
 +                                |diag| {
 +                                    let rsnip = snippet(cx, r.span, "...").to_string();
 +                                    diag.span_suggestion(
 +                                        right.span,
 +                                        "use the right value directly",
 +                                        rsnip,
 +                                        Applicability::MaybeIncorrect, // FIXME #2597
 +                                    );
 +                                },
 +                            );
 +                        }
 +                    },
 +                    // &foo == bar
 +                    (&ExprKind::AddrOf(BorrowKind::Ref, _, l), _) => {
 +                        let lty = cx.typeck_results().expr_ty(l);
++                        if let Some((self_ty, other_ty)) = in_impl(cx, e, trait_id) {
++                            let rty = cx.typeck_results().expr_ty(right);
++                            if (are_equal(cx, rty, self_ty) && are_equal(cx, lty, other_ty))
++                                || (are_equal(cx, rty, other_ty) && are_equal(cx, lty, self_ty))
++                            {
++                                return; // Don't lint
++                            }
++                        }
 +                        let lcpy = is_copy(cx, lty);
 +                        if (requires_ref || lcpy)
 +                            && implements_trait(cx, lty, trait_id, &[cx.typeck_results().expr_ty(right).into()])
 +                        {
 +                            span_lint_and_then(
 +                                cx,
 +                                OP_REF,
 +                                e.span,
 +                                "needlessly taken reference of left operand",
 +                                |diag| {
 +                                    let lsnip = snippet(cx, l.span, "...").to_string();
 +                                    diag.span_suggestion(
 +                                        left.span,
 +                                        "use the left value directly",
 +                                        lsnip,
 +                                        Applicability::MaybeIncorrect, // FIXME #2597
 +                                    );
 +                                },
 +                            );
 +                        }
 +                    },
 +                    // foo == &bar
 +                    (_, &ExprKind::AddrOf(BorrowKind::Ref, _, r)) => {
 +                        let rty = cx.typeck_results().expr_ty(r);
++                        if let Some((self_ty, other_ty)) = in_impl(cx, e, trait_id) {
++                            let lty = cx.typeck_results().expr_ty(left);
++                            if (are_equal(cx, rty, self_ty) && are_equal(cx, lty, other_ty))
++                                || (are_equal(cx, rty, other_ty) && are_equal(cx, lty, self_ty))
++                            {
++                                return; // Don't lint
++                            }
++                        }
 +                        let rcpy = is_copy(cx, rty);
 +                        if (requires_ref || rcpy)
 +                            && implements_trait(cx, cx.typeck_results().expr_ty(left), trait_id, &[rty.into()])
 +                        {
 +                            span_lint_and_then(cx, OP_REF, e.span, "taken reference of right operand", |diag| {
 +                                let rsnip = snippet(cx, r.span, "...").to_string();
 +                                diag.span_suggestion(
 +                                    right.span,
 +                                    "use the right value directly",
 +                                    rsnip,
 +                                    Applicability::MaybeIncorrect, // FIXME #2597
 +                                );
 +                            });
 +                        }
 +                    },
 +                    _ => {},
 +                }
 +            }
 +        }
 +    }
 +}
++
++fn in_impl<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>, bin_op: DefId) -> Option<(&'tcx Ty<'tcx>, &'tcx Ty<'tcx>)> {
++    if_chain! {
++        if let Some(block) = get_enclosing_block(cx, e.hir_id);
++        if let Some(impl_def_id) = cx.tcx.impl_of_method(block.hir_id.owner.to_def_id());
++        let item = cx.tcx.hir().expect_item(impl_def_id.expect_local());
++        if let ItemKind::Impl(item) = &item.kind;
++        if let Some(of_trait) = &item.of_trait;
++        if let Some(seg) = of_trait.path.segments.last();
++        if let Some(Res::Def(_, trait_id)) = seg.res;
++        if trait_id == bin_op;
++        if let Some(generic_args) = seg.args;
++        if let Some(GenericArg::Type(other_ty)) = generic_args.args.last();
++
++        then {
++            Some((item.self_ty, other_ty))
++        }
++        else {
++            None
++        }
++    }
++}
++
++fn are_equal<'tcx>(cx: &LateContext<'tcx>, middle_ty: &TyS<'_>, hir_ty: &Ty<'_>) -> bool {
++    if_chain! {
++        if let ty::Adt(adt_def, _) = middle_ty.kind();
++        if let Some(local_did) = adt_def.did.as_local();
++        let item = cx.tcx.hir().expect_item(local_did);
++        let middle_ty_id = item.def_id.to_def_id();
++        if let TyKind::Path(QPath::Resolved(_, path)) = hir_ty.kind;
++        if let Res::Def(_, hir_ty_id) = path.res;
++
++        then {
++            hir_ty_id == middle_ty_id
++        }
++        else {
++            false
++        }
++    }
++}
index 104de0ff62f8a2e0d0101a601d34fc458c72de1c,0000000000000000000000000000000000000000..eed25e9bc0ea8c7458a18480a2d956af5f9b1aaa
mode 100644,000000..100644
--- /dev/null
@@@ -1,389 -1,0 +1,389 @@@
-                                 Some(item.span.lo() + BytePos((i + (&snip[i..]).find('(')?) as u32))
 +use std::borrow::Cow;
 +use std::collections::BTreeMap;
 +
 +use rustc_errors::DiagnosticBuilder;
 +use rustc_hir as hir;
 +use rustc_hir::intravisit::{walk_body, walk_expr, walk_inf, walk_ty, Visitor};
 +use rustc_hir::{Body, Expr, ExprKind, GenericArg, Item, ItemKind, QPath, TyKind};
 +use rustc_lint::{LateContext, LateLintPass, LintContext};
 +use rustc_middle::hir::nested_filter;
 +use rustc_middle::lint::in_external_macro;
 +use rustc_middle::ty::{Ty, TyS, TypeckResults};
 +use rustc_session::{declare_lint_pass, declare_tool_lint};
 +use rustc_span::source_map::Span;
 +use rustc_span::symbol::sym;
 +use rustc_typeck::hir_ty_to_ty;
 +
 +use if_chain::if_chain;
 +
 +use clippy_utils::diagnostics::{multispan_sugg, span_lint_and_then};
 +use clippy_utils::differing_macro_contexts;
 +use clippy_utils::source::{snippet, snippet_opt};
 +use clippy_utils::ty::is_type_diagnostic_item;
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for public `impl` or `fn` missing generalization
 +    /// over different hashers and implicitly defaulting to the default hashing
 +    /// algorithm (`SipHash`).
 +    ///
 +    /// ### Why is this bad?
 +    /// `HashMap` or `HashSet` with custom hashers cannot be
 +    /// used with them.
 +    ///
 +    /// ### Known problems
 +    /// Suggestions for replacing constructors can contain
 +    /// false-positives. Also applying suggestions can require modification of other
 +    /// pieces of code, possibly including external crates.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// # use std::collections::HashMap;
 +    /// # use std::hash::{Hash, BuildHasher};
 +    /// # trait Serialize {};
 +    /// impl<K: Hash + Eq, V> Serialize for HashMap<K, V> { }
 +    ///
 +    /// pub fn foo(map: &mut HashMap<i32, i32>) { }
 +    /// ```
 +    /// could be rewritten as
 +    /// ```rust
 +    /// # use std::collections::HashMap;
 +    /// # use std::hash::{Hash, BuildHasher};
 +    /// # trait Serialize {};
 +    /// impl<K: Hash + Eq, V, S: BuildHasher> Serialize for HashMap<K, V, S> { }
 +    ///
 +    /// pub fn foo<S: BuildHasher>(map: &mut HashMap<i32, i32, S>) { }
 +    /// ```
 +    #[clippy::version = "pre 1.29.0"]
 +    pub IMPLICIT_HASHER,
 +    pedantic,
 +    "missing generalization over different hashers"
 +}
 +
 +declare_lint_pass!(ImplicitHasher => [IMPLICIT_HASHER]);
 +
 +impl<'tcx> LateLintPass<'tcx> for ImplicitHasher {
 +    #[allow(clippy::cast_possible_truncation, clippy::too_many_lines)]
 +    fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
 +        use rustc_span::BytePos;
 +
 +        fn suggestion<'tcx>(
 +            cx: &LateContext<'tcx>,
 +            diag: &mut DiagnosticBuilder<'_>,
 +            generics_span: Span,
 +            generics_suggestion_span: Span,
 +            target: &ImplicitHasherType<'_>,
 +            vis: ImplicitHasherConstructorVisitor<'_, '_, '_>,
 +        ) {
 +            let generics_snip = snippet(cx, generics_span, "");
 +            // trim `<` `>`
 +            let generics_snip = if generics_snip.is_empty() {
 +                ""
 +            } else {
 +                &generics_snip[1..generics_snip.len() - 1]
 +            };
 +
 +            multispan_sugg(
 +                diag,
 +                "consider adding a type parameter",
 +                vec![
 +                    (
 +                        generics_suggestion_span,
 +                        format!(
 +                            "<{}{}S: ::std::hash::BuildHasher{}>",
 +                            generics_snip,
 +                            if generics_snip.is_empty() { "" } else { ", " },
 +                            if vis.suggestions.is_empty() {
 +                                ""
 +                            } else {
 +                                // request users to add `Default` bound so that generic constructors can be used
 +                                " + Default"
 +                            },
 +                        ),
 +                    ),
 +                    (
 +                        target.span(),
 +                        format!("{}<{}, S>", target.type_name(), target.type_arguments(),),
 +                    ),
 +                ],
 +            );
 +
 +            if !vis.suggestions.is_empty() {
 +                multispan_sugg(diag, "...and use generic constructor", vis.suggestions);
 +            }
 +        }
 +
 +        if !cx.access_levels.is_exported(item.def_id) {
 +            return;
 +        }
 +
 +        match item.kind {
 +            ItemKind::Impl(ref impl_) => {
 +                let mut vis = ImplicitHasherTypeVisitor::new(cx);
 +                vis.visit_ty(impl_.self_ty);
 +
 +                for target in &vis.found {
 +                    if differing_macro_contexts(item.span, target.span()) {
 +                        return;
 +                    }
 +
 +                    let generics_suggestion_span = impl_.generics.span.substitute_dummy({
 +                        let pos = snippet_opt(cx, item.span.until(target.span()))
 +                            .and_then(|snip| Some(item.span.lo() + BytePos(snip.find("impl")? as u32 + 4)));
 +                        if let Some(pos) = pos {
 +                            Span::new(pos, pos, item.span.ctxt(), item.span.parent())
 +                        } else {
 +                            return;
 +                        }
 +                    });
 +
 +                    let mut ctr_vis = ImplicitHasherConstructorVisitor::new(cx, target);
 +                    for item in impl_.items.iter().map(|item| cx.tcx.hir().impl_item(item.id)) {
 +                        ctr_vis.visit_impl_item(item);
 +                    }
 +
 +                    span_lint_and_then(
 +                        cx,
 +                        IMPLICIT_HASHER,
 +                        target.span(),
 +                        &format!(
 +                            "impl for `{}` should be generalized over different hashers",
 +                            target.type_name()
 +                        ),
 +                        move |diag| {
 +                            suggestion(cx, diag, impl_.generics.span, generics_suggestion_span, target, ctr_vis);
 +                        },
 +                    );
 +                }
 +            },
 +            ItemKind::Fn(ref sig, ref generics, body_id) => {
 +                let body = cx.tcx.hir().body(body_id);
 +
 +                for ty in sig.decl.inputs {
 +                    let mut vis = ImplicitHasherTypeVisitor::new(cx);
 +                    vis.visit_ty(ty);
 +
 +                    for target in &vis.found {
 +                        if in_external_macro(cx.sess(), generics.span) {
 +                            continue;
 +                        }
 +                        let generics_suggestion_span = generics.span.substitute_dummy({
 +                            let pos = snippet_opt(
 +                                cx,
 +                                Span::new(
 +                                    item.span.lo(),
 +                                    body.params[0].pat.span.lo(),
 +                                    item.span.ctxt(),
 +                                    item.span.parent(),
 +                                ),
 +                            )
 +                            .and_then(|snip| {
 +                                let i = snip.find("fn")?;
++                                Some(item.span.lo() + BytePos((i + snip[i..].find('(')?) as u32))
 +                            })
 +                            .expect("failed to create span for type parameters");
 +                            Span::new(pos, pos, item.span.ctxt(), item.span.parent())
 +                        });
 +
 +                        let mut ctr_vis = ImplicitHasherConstructorVisitor::new(cx, target);
 +                        ctr_vis.visit_body(body);
 +
 +                        span_lint_and_then(
 +                            cx,
 +                            IMPLICIT_HASHER,
 +                            target.span(),
 +                            &format!(
 +                                "parameter of type `{}` should be generalized over different hashers",
 +                                target.type_name()
 +                            ),
 +                            move |diag| {
 +                                suggestion(cx, diag, generics.span, generics_suggestion_span, target, ctr_vis);
 +                            },
 +                        );
 +                    }
 +                }
 +            },
 +            _ => {},
 +        }
 +    }
 +}
 +
 +enum ImplicitHasherType<'tcx> {
 +    HashMap(Span, Ty<'tcx>, Cow<'static, str>, Cow<'static, str>),
 +    HashSet(Span, Ty<'tcx>, Cow<'static, str>),
 +}
 +
 +impl<'tcx> ImplicitHasherType<'tcx> {
 +    /// Checks that `ty` is a target type without a `BuildHasher`.
 +    fn new(cx: &LateContext<'tcx>, hir_ty: &hir::Ty<'_>) -> Option<Self> {
 +        if let TyKind::Path(QPath::Resolved(None, path)) = hir_ty.kind {
 +            let params: Vec<_> = path
 +                .segments
 +                .last()
 +                .as_ref()?
 +                .args
 +                .as_ref()?
 +                .args
 +                .iter()
 +                .filter_map(|arg| match arg {
 +                    GenericArg::Type(ty) => Some(ty),
 +                    _ => None,
 +                })
 +                .collect();
 +            let params_len = params.len();
 +
 +            let ty = hir_ty_to_ty(cx.tcx, hir_ty);
 +
 +            if is_type_diagnostic_item(cx, ty, sym::HashMap) && params_len == 2 {
 +                Some(ImplicitHasherType::HashMap(
 +                    hir_ty.span,
 +                    ty,
 +                    snippet(cx, params[0].span, "K"),
 +                    snippet(cx, params[1].span, "V"),
 +                ))
 +            } else if is_type_diagnostic_item(cx, ty, sym::HashSet) && params_len == 1 {
 +                Some(ImplicitHasherType::HashSet(
 +                    hir_ty.span,
 +                    ty,
 +                    snippet(cx, params[0].span, "T"),
 +                ))
 +            } else {
 +                None
 +            }
 +        } else {
 +            None
 +        }
 +    }
 +
 +    fn type_name(&self) -> &'static str {
 +        match *self {
 +            ImplicitHasherType::HashMap(..) => "HashMap",
 +            ImplicitHasherType::HashSet(..) => "HashSet",
 +        }
 +    }
 +
 +    fn type_arguments(&self) -> String {
 +        match *self {
 +            ImplicitHasherType::HashMap(.., ref k, ref v) => format!("{}, {}", k, v),
 +            ImplicitHasherType::HashSet(.., ref t) => format!("{}", t),
 +        }
 +    }
 +
 +    fn ty(&self) -> Ty<'tcx> {
 +        match *self {
 +            ImplicitHasherType::HashMap(_, ty, ..) | ImplicitHasherType::HashSet(_, ty, ..) => ty,
 +        }
 +    }
 +
 +    fn span(&self) -> Span {
 +        match *self {
 +            ImplicitHasherType::HashMap(span, ..) | ImplicitHasherType::HashSet(span, ..) => span,
 +        }
 +    }
 +}
 +
 +struct ImplicitHasherTypeVisitor<'a, 'tcx> {
 +    cx: &'a LateContext<'tcx>,
 +    found: Vec<ImplicitHasherType<'tcx>>,
 +}
 +
 +impl<'a, 'tcx> ImplicitHasherTypeVisitor<'a, 'tcx> {
 +    fn new(cx: &'a LateContext<'tcx>) -> Self {
 +        Self { cx, found: vec![] }
 +    }
 +}
 +
 +impl<'a, 'tcx> Visitor<'tcx> for ImplicitHasherTypeVisitor<'a, 'tcx> {
 +    fn visit_ty(&mut self, t: &'tcx hir::Ty<'_>) {
 +        if let Some(target) = ImplicitHasherType::new(self.cx, t) {
 +            self.found.push(target);
 +        }
 +
 +        walk_ty(self, t);
 +    }
 +
 +    fn visit_infer(&mut self, inf: &'tcx hir::InferArg) {
 +        if let Some(target) = ImplicitHasherType::new(self.cx, &inf.to_ty()) {
 +            self.found.push(target);
 +        }
 +
 +        walk_inf(self, inf);
 +    }
 +}
 +
 +/// Looks for default-hasher-dependent constructors like `HashMap::new`.
 +struct ImplicitHasherConstructorVisitor<'a, 'b, 'tcx> {
 +    cx: &'a LateContext<'tcx>,
 +    maybe_typeck_results: Option<&'tcx TypeckResults<'tcx>>,
 +    target: &'b ImplicitHasherType<'tcx>,
 +    suggestions: BTreeMap<Span, String>,
 +}
 +
 +impl<'a, 'b, 'tcx> ImplicitHasherConstructorVisitor<'a, 'b, 'tcx> {
 +    fn new(cx: &'a LateContext<'tcx>, target: &'b ImplicitHasherType<'tcx>) -> Self {
 +        Self {
 +            cx,
 +            maybe_typeck_results: cx.maybe_typeck_results(),
 +            target,
 +            suggestions: BTreeMap::new(),
 +        }
 +    }
 +}
 +
 +impl<'a, 'b, 'tcx> Visitor<'tcx> for ImplicitHasherConstructorVisitor<'a, 'b, 'tcx> {
 +    type NestedFilter = nested_filter::OnlyBodies;
 +
 +    fn visit_body(&mut self, body: &'tcx Body<'_>) {
 +        let old_maybe_typeck_results = self.maybe_typeck_results.replace(self.cx.tcx.typeck_body(body.id()));
 +        walk_body(self, body);
 +        self.maybe_typeck_results = old_maybe_typeck_results;
 +    }
 +
 +    fn visit_expr(&mut self, e: &'tcx Expr<'_>) {
 +        if_chain! {
 +            if let ExprKind::Call(fun, args) = e.kind;
 +            if let ExprKind::Path(QPath::TypeRelative(ty, method)) = fun.kind;
 +            if let TyKind::Path(QPath::Resolved(None, ty_path)) = ty.kind;
 +            if let Some(ty_did) = ty_path.res.opt_def_id();
 +            then {
 +                if !TyS::same_type(self.target.ty(), self.maybe_typeck_results.unwrap().expr_ty(e)) {
 +                    return;
 +                }
 +
 +                if self.cx.tcx.is_diagnostic_item(sym::HashMap, ty_did) {
 +                    if method.ident.name == sym::new {
 +                        self.suggestions
 +                            .insert(e.span, "HashMap::default()".to_string());
 +                    } else if method.ident.name == sym!(with_capacity) {
 +                        self.suggestions.insert(
 +                            e.span,
 +                            format!(
 +                                "HashMap::with_capacity_and_hasher({}, Default::default())",
 +                                snippet(self.cx, args[0].span, "capacity"),
 +                            ),
 +                        );
 +                    }
 +                } else if self.cx.tcx.is_diagnostic_item(sym::HashSet, ty_did) {
 +                    if method.ident.name == sym::new {
 +                        self.suggestions
 +                            .insert(e.span, "HashSet::default()".to_string());
 +                    } else if method.ident.name == sym!(with_capacity) {
 +                        self.suggestions.insert(
 +                            e.span,
 +                            format!(
 +                                "HashSet::with_capacity_and_hasher({}, Default::default())",
 +                                snippet(self.cx, args[0].span, "capacity"),
 +                            ),
 +                        );
 +                    }
 +                }
 +            }
 +        }
 +
 +        walk_expr(self, e);
 +    }
 +
 +    fn nested_visit_map(&mut self) -> Self::Map {
 +        self.cx.tcx.hir()
 +    }
 +}
index 87fd7f99748a1df8d1b00018e7e7b1c09d55a68d,0000000000000000000000000000000000000000..4721b7f2b472b3ffaab9da2a2e21b8f486cf8457
mode 100644,000000..100644
--- /dev/null
@@@ -1,317 -1,0 +1,316 @@@
-     LintId::of(reference::REF_IN_DEREF),
 +// This file was generated by `cargo dev update_lints`.
 +// Use that command to update this file and do not edit by hand.
 +// Manual edits will be overwritten.
 +
 +store.register_group(true, "clippy::all", Some("clippy_all"), vec![
 +    LintId::of(absurd_extreme_comparisons::ABSURD_EXTREME_COMPARISONS),
 +    LintId::of(approx_const::APPROX_CONSTANT),
 +    LintId::of(assertions_on_constants::ASSERTIONS_ON_CONSTANTS),
 +    LintId::of(assign_ops::ASSIGN_OP_PATTERN),
 +    LintId::of(assign_ops::MISREFACTORED_ASSIGN_OP),
 +    LintId::of(async_yields_async::ASYNC_YIELDS_ASYNC),
 +    LintId::of(attrs::BLANKET_CLIPPY_RESTRICTION_LINTS),
 +    LintId::of(attrs::DEPRECATED_CFG_ATTR),
 +    LintId::of(attrs::DEPRECATED_SEMVER),
 +    LintId::of(attrs::MISMATCHED_TARGET_OS),
 +    LintId::of(attrs::USELESS_ATTRIBUTE),
 +    LintId::of(bit_mask::BAD_BIT_MASK),
 +    LintId::of(bit_mask::INEFFECTIVE_BIT_MASK),
 +    LintId::of(blacklisted_name::BLACKLISTED_NAME),
 +    LintId::of(blocks_in_if_conditions::BLOCKS_IN_IF_CONDITIONS),
 +    LintId::of(bool_assert_comparison::BOOL_ASSERT_COMPARISON),
 +    LintId::of(booleans::LOGIC_BUG),
 +    LintId::of(booleans::NONMINIMAL_BOOL),
 +    LintId::of(casts::CAST_REF_TO_MUT),
 +    LintId::of(casts::CHAR_LIT_AS_U8),
 +    LintId::of(casts::FN_TO_NUMERIC_CAST),
 +    LintId::of(casts::FN_TO_NUMERIC_CAST_WITH_TRUNCATION),
 +    LintId::of(casts::UNNECESSARY_CAST),
 +    LintId::of(collapsible_if::COLLAPSIBLE_ELSE_IF),
 +    LintId::of(collapsible_if::COLLAPSIBLE_IF),
 +    LintId::of(collapsible_match::COLLAPSIBLE_MATCH),
 +    LintId::of(comparison_chain::COMPARISON_CHAIN),
 +    LintId::of(copies::IFS_SAME_COND),
 +    LintId::of(copies::IF_SAME_THEN_ELSE),
 +    LintId::of(default::FIELD_REASSIGN_WITH_DEFAULT),
 +    LintId::of(dereference::NEEDLESS_BORROW),
 +    LintId::of(derivable_impls::DERIVABLE_IMPLS),
 +    LintId::of(derive::DERIVE_HASH_XOR_EQ),
 +    LintId::of(derive::DERIVE_ORD_XOR_PARTIAL_ORD),
 +    LintId::of(disallowed_methods::DISALLOWED_METHODS),
 +    LintId::of(disallowed_types::DISALLOWED_TYPES),
 +    LintId::of(doc::MISSING_SAFETY_DOC),
 +    LintId::of(doc::NEEDLESS_DOCTEST_MAIN),
 +    LintId::of(double_comparison::DOUBLE_COMPARISONS),
 +    LintId::of(double_parens::DOUBLE_PARENS),
 +    LintId::of(drop_forget_ref::DROP_COPY),
 +    LintId::of(drop_forget_ref::DROP_REF),
 +    LintId::of(drop_forget_ref::FORGET_COPY),
 +    LintId::of(drop_forget_ref::FORGET_REF),
 +    LintId::of(duration_subsec::DURATION_SUBSEC),
 +    LintId::of(entry::MAP_ENTRY),
 +    LintId::of(enum_clike::ENUM_CLIKE_UNPORTABLE_VARIANT),
 +    LintId::of(enum_variants::ENUM_VARIANT_NAMES),
 +    LintId::of(enum_variants::MODULE_INCEPTION),
 +    LintId::of(eq_op::EQ_OP),
 +    LintId::of(eq_op::OP_REF),
 +    LintId::of(erasing_op::ERASING_OP),
 +    LintId::of(escape::BOXED_LOCAL),
 +    LintId::of(eta_reduction::REDUNDANT_CLOSURE),
 +    LintId::of(eval_order_dependence::DIVERGING_SUB_EXPRESSION),
 +    LintId::of(eval_order_dependence::EVAL_ORDER_DEPENDENCE),
 +    LintId::of(explicit_write::EXPLICIT_WRITE),
 +    LintId::of(float_equality_without_abs::FLOAT_EQUALITY_WITHOUT_ABS),
 +    LintId::of(float_literal::EXCESSIVE_PRECISION),
 +    LintId::of(format::USELESS_FORMAT),
 +    LintId::of(format_args::FORMAT_IN_FORMAT_ARGS),
 +    LintId::of(format_args::TO_STRING_IN_FORMAT_ARGS),
 +    LintId::of(formatting::POSSIBLE_MISSING_COMMA),
 +    LintId::of(formatting::SUSPICIOUS_ASSIGNMENT_FORMATTING),
 +    LintId::of(formatting::SUSPICIOUS_ELSE_FORMATTING),
 +    LintId::of(formatting::SUSPICIOUS_UNARY_OP_FORMATTING),
 +    LintId::of(from_over_into::FROM_OVER_INTO),
 +    LintId::of(from_str_radix_10::FROM_STR_RADIX_10),
 +    LintId::of(functions::DOUBLE_MUST_USE),
 +    LintId::of(functions::MUST_USE_UNIT),
 +    LintId::of(functions::NOT_UNSAFE_PTR_ARG_DEREF),
 +    LintId::of(functions::RESULT_UNIT_ERR),
 +    LintId::of(functions::TOO_MANY_ARGUMENTS),
 +    LintId::of(get_last_with_len::GET_LAST_WITH_LEN),
 +    LintId::of(identity_op::IDENTITY_OP),
 +    LintId::of(if_let_mutex::IF_LET_MUTEX),
 +    LintId::of(indexing_slicing::OUT_OF_BOUNDS_INDEXING),
 +    LintId::of(infinite_iter::INFINITE_ITER),
 +    LintId::of(inherent_to_string::INHERENT_TO_STRING),
 +    LintId::of(inherent_to_string::INHERENT_TO_STRING_SHADOW_DISPLAY),
 +    LintId::of(init_numbered_fields::INIT_NUMBERED_FIELDS),
 +    LintId::of(inline_fn_without_body::INLINE_FN_WITHOUT_BODY),
 +    LintId::of(int_plus_one::INT_PLUS_ONE),
 +    LintId::of(large_const_arrays::LARGE_CONST_ARRAYS),
 +    LintId::of(large_enum_variant::LARGE_ENUM_VARIANT),
 +    LintId::of(len_zero::COMPARISON_TO_EMPTY),
 +    LintId::of(len_zero::LEN_WITHOUT_IS_EMPTY),
 +    LintId::of(len_zero::LEN_ZERO),
 +    LintId::of(let_underscore::LET_UNDERSCORE_LOCK),
 +    LintId::of(lifetimes::EXTRA_UNUSED_LIFETIMES),
 +    LintId::of(lifetimes::NEEDLESS_LIFETIMES),
 +    LintId::of(literal_representation::INCONSISTENT_DIGIT_GROUPING),
 +    LintId::of(literal_representation::MISTYPED_LITERAL_SUFFIXES),
 +    LintId::of(literal_representation::UNUSUAL_BYTE_GROUPINGS),
 +    LintId::of(loops::EMPTY_LOOP),
 +    LintId::of(loops::EXPLICIT_COUNTER_LOOP),
 +    LintId::of(loops::FOR_KV_MAP),
 +    LintId::of(loops::FOR_LOOPS_OVER_FALLIBLES),
 +    LintId::of(loops::ITER_NEXT_LOOP),
 +    LintId::of(loops::MANUAL_FLATTEN),
 +    LintId::of(loops::MANUAL_MEMCPY),
 +    LintId::of(loops::MUT_RANGE_BOUND),
 +    LintId::of(loops::NEEDLESS_COLLECT),
 +    LintId::of(loops::NEEDLESS_RANGE_LOOP),
 +    LintId::of(loops::NEVER_LOOP),
 +    LintId::of(loops::SAME_ITEM_PUSH),
 +    LintId::of(loops::SINGLE_ELEMENT_LOOP),
 +    LintId::of(loops::WHILE_IMMUTABLE_CONDITION),
 +    LintId::of(loops::WHILE_LET_LOOP),
 +    LintId::of(loops::WHILE_LET_ON_ITERATOR),
 +    LintId::of(main_recursion::MAIN_RECURSION),
 +    LintId::of(manual_async_fn::MANUAL_ASYNC_FN),
 +    LintId::of(manual_bits::MANUAL_BITS),
 +    LintId::of(manual_map::MANUAL_MAP),
 +    LintId::of(manual_non_exhaustive::MANUAL_NON_EXHAUSTIVE),
 +    LintId::of(manual_strip::MANUAL_STRIP),
 +    LintId::of(manual_unwrap_or::MANUAL_UNWRAP_OR),
 +    LintId::of(map_clone::MAP_CLONE),
 +    LintId::of(map_unit_fn::OPTION_MAP_UNIT_FN),
 +    LintId::of(map_unit_fn::RESULT_MAP_UNIT_FN),
 +    LintId::of(match_result_ok::MATCH_RESULT_OK),
 +    LintId::of(match_str_case_mismatch::MATCH_STR_CASE_MISMATCH),
 +    LintId::of(matches::INFALLIBLE_DESTRUCTURING_MATCH),
 +    LintId::of(matches::MATCH_AS_REF),
 +    LintId::of(matches::MATCH_LIKE_MATCHES_MACRO),
 +    LintId::of(matches::MATCH_OVERLAPPING_ARM),
 +    LintId::of(matches::MATCH_REF_PATS),
 +    LintId::of(matches::MATCH_SINGLE_BINDING),
 +    LintId::of(matches::REDUNDANT_PATTERN_MATCHING),
 +    LintId::of(matches::SINGLE_MATCH),
 +    LintId::of(matches::WILDCARD_IN_OR_PATTERNS),
 +    LintId::of(mem_replace::MEM_REPLACE_OPTION_WITH_NONE),
 +    LintId::of(mem_replace::MEM_REPLACE_WITH_DEFAULT),
 +    LintId::of(mem_replace::MEM_REPLACE_WITH_UNINIT),
 +    LintId::of(methods::BIND_INSTEAD_OF_MAP),
 +    LintId::of(methods::BYTES_NTH),
 +    LintId::of(methods::CHARS_LAST_CMP),
 +    LintId::of(methods::CHARS_NEXT_CMP),
 +    LintId::of(methods::CLONE_DOUBLE_REF),
 +    LintId::of(methods::CLONE_ON_COPY),
 +    LintId::of(methods::EXPECT_FUN_CALL),
 +    LintId::of(methods::EXTEND_WITH_DRAIN),
 +    LintId::of(methods::FILTER_MAP_IDENTITY),
 +    LintId::of(methods::FILTER_NEXT),
 +    LintId::of(methods::FLAT_MAP_IDENTITY),
 +    LintId::of(methods::INSPECT_FOR_EACH),
 +    LintId::of(methods::INTO_ITER_ON_REF),
 +    LintId::of(methods::ITERATOR_STEP_BY_ZERO),
 +    LintId::of(methods::ITER_CLONED_COLLECT),
 +    LintId::of(methods::ITER_COUNT),
 +    LintId::of(methods::ITER_NEXT_SLICE),
 +    LintId::of(methods::ITER_NTH),
 +    LintId::of(methods::ITER_NTH_ZERO),
 +    LintId::of(methods::ITER_OVEREAGER_CLONED),
 +    LintId::of(methods::ITER_SKIP_NEXT),
 +    LintId::of(methods::MANUAL_FILTER_MAP),
 +    LintId::of(methods::MANUAL_FIND_MAP),
 +    LintId::of(methods::MANUAL_SATURATING_ARITHMETIC),
 +    LintId::of(methods::MANUAL_SPLIT_ONCE),
 +    LintId::of(methods::MANUAL_STR_REPEAT),
 +    LintId::of(methods::MAP_COLLECT_RESULT_UNIT),
 +    LintId::of(methods::MAP_FLATTEN),
 +    LintId::of(methods::MAP_IDENTITY),
 +    LintId::of(methods::NEEDLESS_SPLITN),
 +    LintId::of(methods::NEW_RET_NO_SELF),
 +    LintId::of(methods::OK_EXPECT),
 +    LintId::of(methods::OPTION_AS_REF_DEREF),
 +    LintId::of(methods::OPTION_FILTER_MAP),
 +    LintId::of(methods::OPTION_MAP_OR_NONE),
 +    LintId::of(methods::OR_FUN_CALL),
 +    LintId::of(methods::RESULT_MAP_OR_INTO_OPTION),
 +    LintId::of(methods::SEARCH_IS_SOME),
 +    LintId::of(methods::SHOULD_IMPLEMENT_TRAIT),
 +    LintId::of(methods::SINGLE_CHAR_ADD_STR),
 +    LintId::of(methods::SINGLE_CHAR_PATTERN),
 +    LintId::of(methods::SKIP_WHILE_NEXT),
 +    LintId::of(methods::STRING_EXTEND_CHARS),
 +    LintId::of(methods::SUSPICIOUS_MAP),
 +    LintId::of(methods::SUSPICIOUS_SPLITN),
 +    LintId::of(methods::UNINIT_ASSUMED_INIT),
 +    LintId::of(methods::UNNECESSARY_FILTER_MAP),
 +    LintId::of(methods::UNNECESSARY_FOLD),
 +    LintId::of(methods::UNNECESSARY_LAZY_EVALUATIONS),
 +    LintId::of(methods::UNNECESSARY_TO_OWNED),
 +    LintId::of(methods::UNWRAP_OR_ELSE_DEFAULT),
 +    LintId::of(methods::USELESS_ASREF),
 +    LintId::of(methods::WRONG_SELF_CONVENTION),
 +    LintId::of(methods::ZST_OFFSET),
 +    LintId::of(minmax::MIN_MAX),
 +    LintId::of(misc::CMP_NAN),
 +    LintId::of(misc::CMP_OWNED),
 +    LintId::of(misc::MODULO_ONE),
 +    LintId::of(misc::SHORT_CIRCUIT_STATEMENT),
 +    LintId::of(misc::TOPLEVEL_REF_ARG),
 +    LintId::of(misc::ZERO_PTR),
 +    LintId::of(misc_early::BUILTIN_TYPE_SHADOW),
 +    LintId::of(misc_early::DOUBLE_NEG),
 +    LintId::of(misc_early::DUPLICATE_UNDERSCORE_ARGUMENT),
 +    LintId::of(misc_early::MIXED_CASE_HEX_LITERALS),
 +    LintId::of(misc_early::REDUNDANT_PATTERN),
 +    LintId::of(misc_early::UNNEEDED_WILDCARD_PATTERN),
 +    LintId::of(misc_early::ZERO_PREFIXED_LITERAL),
 +    LintId::of(mut_key::MUTABLE_KEY_TYPE),
 +    LintId::of(mut_mutex_lock::MUT_MUTEX_LOCK),
 +    LintId::of(mut_reference::UNNECESSARY_MUT_PASSED),
 +    LintId::of(needless_arbitrary_self_type::NEEDLESS_ARBITRARY_SELF_TYPE),
 +    LintId::of(needless_bool::BOOL_COMPARISON),
 +    LintId::of(needless_bool::NEEDLESS_BOOL),
 +    LintId::of(needless_borrowed_ref::NEEDLESS_BORROWED_REFERENCE),
 +    LintId::of(needless_late_init::NEEDLESS_LATE_INIT),
 +    LintId::of(needless_option_as_deref::NEEDLESS_OPTION_AS_DEREF),
 +    LintId::of(needless_question_mark::NEEDLESS_QUESTION_MARK),
 +    LintId::of(needless_update::NEEDLESS_UPDATE),
 +    LintId::of(neg_cmp_op_on_partial_ord::NEG_CMP_OP_ON_PARTIAL_ORD),
 +    LintId::of(neg_multiply::NEG_MULTIPLY),
 +    LintId::of(new_without_default::NEW_WITHOUT_DEFAULT),
 +    LintId::of(no_effect::NO_EFFECT),
 +    LintId::of(no_effect::UNNECESSARY_OPERATION),
 +    LintId::of(non_copy_const::BORROW_INTERIOR_MUTABLE_CONST),
 +    LintId::of(non_copy_const::DECLARE_INTERIOR_MUTABLE_CONST),
 +    LintId::of(non_expressive_names::JUST_UNDERSCORES_AND_DIGITS),
 +    LintId::of(non_octal_unix_permissions::NON_OCTAL_UNIX_PERMISSIONS),
 +    LintId::of(octal_escapes::OCTAL_ESCAPES),
 +    LintId::of(open_options::NONSENSICAL_OPEN_OPTIONS),
 +    LintId::of(option_env_unwrap::OPTION_ENV_UNWRAP),
 +    LintId::of(overflow_check_conditional::OVERFLOW_CHECK_CONDITIONAL),
 +    LintId::of(partialeq_ne_impl::PARTIALEQ_NE_IMPL),
 +    LintId::of(precedence::PRECEDENCE),
 +    LintId::of(ptr::CMP_NULL),
 +    LintId::of(ptr::INVALID_NULL_PTR_USAGE),
 +    LintId::of(ptr::MUT_FROM_REF),
 +    LintId::of(ptr::PTR_ARG),
 +    LintId::of(ptr_eq::PTR_EQ),
 +    LintId::of(ptr_offset_with_cast::PTR_OFFSET_WITH_CAST),
 +    LintId::of(question_mark::QUESTION_MARK),
 +    LintId::of(ranges::MANUAL_RANGE_CONTAINS),
 +    LintId::of(ranges::RANGE_ZIP_WITH_LEN),
 +    LintId::of(ranges::REVERSED_EMPTY_RANGES),
 +    LintId::of(redundant_clone::REDUNDANT_CLONE),
 +    LintId::of(redundant_closure_call::REDUNDANT_CLOSURE_CALL),
 +    LintId::of(redundant_field_names::REDUNDANT_FIELD_NAMES),
 +    LintId::of(redundant_slicing::REDUNDANT_SLICING),
 +    LintId::of(redundant_static_lifetimes::REDUNDANT_STATIC_LIFETIMES),
 +    LintId::of(reference::DEREF_ADDROF),
 +    LintId::of(regex::INVALID_REGEX),
 +    LintId::of(repeat_once::REPEAT_ONCE),
 +    LintId::of(returns::LET_AND_RETURN),
 +    LintId::of(returns::NEEDLESS_RETURN),
 +    LintId::of(self_assignment::SELF_ASSIGNMENT),
 +    LintId::of(self_named_constructors::SELF_NAMED_CONSTRUCTORS),
 +    LintId::of(serde_api::SERDE_API_MISUSE),
 +    LintId::of(single_component_path_imports::SINGLE_COMPONENT_PATH_IMPORTS),
 +    LintId::of(size_of_in_element_count::SIZE_OF_IN_ELEMENT_COUNT),
 +    LintId::of(slow_vector_initialization::SLOW_VECTOR_INITIALIZATION),
 +    LintId::of(stable_sort_primitive::STABLE_SORT_PRIMITIVE),
 +    LintId::of(strings::STRING_FROM_UTF8_AS_BYTES),
 +    LintId::of(strlen_on_c_strings::STRLEN_ON_C_STRINGS),
 +    LintId::of(suspicious_trait_impl::SUSPICIOUS_ARITHMETIC_IMPL),
 +    LintId::of(suspicious_trait_impl::SUSPICIOUS_OP_ASSIGN_IMPL),
 +    LintId::of(swap::ALMOST_SWAPPED),
 +    LintId::of(swap::MANUAL_SWAP),
 +    LintId::of(tabs_in_doc_comments::TABS_IN_DOC_COMMENTS),
 +    LintId::of(temporary_assignment::TEMPORARY_ASSIGNMENT),
 +    LintId::of(to_digit_is_some::TO_DIGIT_IS_SOME),
 +    LintId::of(to_string_in_display::TO_STRING_IN_DISPLAY),
 +    LintId::of(transmute::CROSSPOINTER_TRANSMUTE),
 +    LintId::of(transmute::TRANSMUTES_EXPRESSIBLE_AS_PTR_CASTS),
 +    LintId::of(transmute::TRANSMUTE_BYTES_TO_STR),
 +    LintId::of(transmute::TRANSMUTE_FLOAT_TO_INT),
 +    LintId::of(transmute::TRANSMUTE_INT_TO_BOOL),
 +    LintId::of(transmute::TRANSMUTE_INT_TO_CHAR),
 +    LintId::of(transmute::TRANSMUTE_INT_TO_FLOAT),
 +    LintId::of(transmute::TRANSMUTE_NUM_TO_BYTES),
 +    LintId::of(transmute::TRANSMUTE_PTR_TO_REF),
 +    LintId::of(transmute::UNSOUND_COLLECTION_TRANSMUTE),
 +    LintId::of(transmute::WRONG_TRANSMUTE),
 +    LintId::of(transmuting_null::TRANSMUTING_NULL),
 +    LintId::of(try_err::TRY_ERR),
 +    LintId::of(types::BORROWED_BOX),
 +    LintId::of(types::BOX_COLLECTION),
 +    LintId::of(types::REDUNDANT_ALLOCATION),
 +    LintId::of(types::TYPE_COMPLEXITY),
 +    LintId::of(types::VEC_BOX),
 +    LintId::of(undropped_manually_drops::UNDROPPED_MANUALLY_DROPS),
 +    LintId::of(unicode::INVISIBLE_CHARACTERS),
 +    LintId::of(uninit_vec::UNINIT_VEC),
 +    LintId::of(unit_hash::UNIT_HASH),
 +    LintId::of(unit_return_expecting_ord::UNIT_RETURN_EXPECTING_ORD),
 +    LintId::of(unit_types::UNIT_ARG),
 +    LintId::of(unit_types::UNIT_CMP),
 +    LintId::of(unnamed_address::FN_ADDRESS_COMPARISONS),
 +    LintId::of(unnamed_address::VTABLE_ADDRESS_COMPARISONS),
 +    LintId::of(unnecessary_sort_by::UNNECESSARY_SORT_BY),
 +    LintId::of(unsafe_removed_from_name::UNSAFE_REMOVED_FROM_NAME),
 +    LintId::of(unused_io_amount::UNUSED_IO_AMOUNT),
 +    LintId::of(unused_unit::UNUSED_UNIT),
 +    LintId::of(unwrap::PANICKING_UNWRAP),
 +    LintId::of(unwrap::UNNECESSARY_UNWRAP),
 +    LintId::of(upper_case_acronyms::UPPER_CASE_ACRONYMS),
 +    LintId::of(useless_conversion::USELESS_CONVERSION),
 +    LintId::of(vec::USELESS_VEC),
 +    LintId::of(vec_init_then_push::VEC_INIT_THEN_PUSH),
 +    LintId::of(vec_resize_to_zero::VEC_RESIZE_TO_ZERO),
 +    LintId::of(write::PRINTLN_EMPTY_STRING),
 +    LintId::of(write::PRINT_LITERAL),
 +    LintId::of(write::PRINT_WITH_NEWLINE),
 +    LintId::of(write::WRITELN_EMPTY_STRING),
 +    LintId::of(write::WRITE_LITERAL),
 +    LintId::of(write::WRITE_WITH_NEWLINE),
 +    LintId::of(zero_div_zero::ZERO_DIVIDED_BY_ZERO),
 +])
index a21ddf73a115e6a22a54dbfc2867abdb43cf0228,0000000000000000000000000000000000000000..bd5ff613447cddf521113dfccbfe71d863fc1776
mode 100644,000000..100644
--- /dev/null
@@@ -1,97 -1,0 +1,96 @@@
-     LintId::of(reference::REF_IN_DEREF),
 +// This file was generated by `cargo dev update_lints`.
 +// Use that command to update this file and do not edit by hand.
 +// Manual edits will be overwritten.
 +
 +store.register_group(true, "clippy::complexity", Some("clippy_complexity"), vec![
 +    LintId::of(attrs::DEPRECATED_CFG_ATTR),
 +    LintId::of(booleans::NONMINIMAL_BOOL),
 +    LintId::of(casts::CHAR_LIT_AS_U8),
 +    LintId::of(casts::UNNECESSARY_CAST),
 +    LintId::of(derivable_impls::DERIVABLE_IMPLS),
 +    LintId::of(double_comparison::DOUBLE_COMPARISONS),
 +    LintId::of(double_parens::DOUBLE_PARENS),
 +    LintId::of(duration_subsec::DURATION_SUBSEC),
 +    LintId::of(eval_order_dependence::DIVERGING_SUB_EXPRESSION),
 +    LintId::of(explicit_write::EXPLICIT_WRITE),
 +    LintId::of(format::USELESS_FORMAT),
 +    LintId::of(functions::TOO_MANY_ARGUMENTS),
 +    LintId::of(get_last_with_len::GET_LAST_WITH_LEN),
 +    LintId::of(identity_op::IDENTITY_OP),
 +    LintId::of(int_plus_one::INT_PLUS_ONE),
 +    LintId::of(lifetimes::EXTRA_UNUSED_LIFETIMES),
 +    LintId::of(lifetimes::NEEDLESS_LIFETIMES),
 +    LintId::of(loops::EXPLICIT_COUNTER_LOOP),
 +    LintId::of(loops::MANUAL_FLATTEN),
 +    LintId::of(loops::SINGLE_ELEMENT_LOOP),
 +    LintId::of(loops::WHILE_LET_LOOP),
 +    LintId::of(manual_strip::MANUAL_STRIP),
 +    LintId::of(manual_unwrap_or::MANUAL_UNWRAP_OR),
 +    LintId::of(map_unit_fn::OPTION_MAP_UNIT_FN),
 +    LintId::of(map_unit_fn::RESULT_MAP_UNIT_FN),
 +    LintId::of(matches::MATCH_AS_REF),
 +    LintId::of(matches::MATCH_SINGLE_BINDING),
 +    LintId::of(matches::WILDCARD_IN_OR_PATTERNS),
 +    LintId::of(methods::BIND_INSTEAD_OF_MAP),
 +    LintId::of(methods::CLONE_ON_COPY),
 +    LintId::of(methods::FILTER_MAP_IDENTITY),
 +    LintId::of(methods::FILTER_NEXT),
 +    LintId::of(methods::FLAT_MAP_IDENTITY),
 +    LintId::of(methods::INSPECT_FOR_EACH),
 +    LintId::of(methods::ITER_COUNT),
 +    LintId::of(methods::MANUAL_FILTER_MAP),
 +    LintId::of(methods::MANUAL_FIND_MAP),
 +    LintId::of(methods::MANUAL_SPLIT_ONCE),
 +    LintId::of(methods::MAP_FLATTEN),
 +    LintId::of(methods::MAP_IDENTITY),
 +    LintId::of(methods::NEEDLESS_SPLITN),
 +    LintId::of(methods::OPTION_AS_REF_DEREF),
 +    LintId::of(methods::OPTION_FILTER_MAP),
 +    LintId::of(methods::SEARCH_IS_SOME),
 +    LintId::of(methods::SKIP_WHILE_NEXT),
 +    LintId::of(methods::UNNECESSARY_FILTER_MAP),
 +    LintId::of(methods::USELESS_ASREF),
 +    LintId::of(misc::SHORT_CIRCUIT_STATEMENT),
 +    LintId::of(misc_early::UNNEEDED_WILDCARD_PATTERN),
 +    LintId::of(misc_early::ZERO_PREFIXED_LITERAL),
 +    LintId::of(needless_arbitrary_self_type::NEEDLESS_ARBITRARY_SELF_TYPE),
 +    LintId::of(needless_bool::BOOL_COMPARISON),
 +    LintId::of(needless_bool::NEEDLESS_BOOL),
 +    LintId::of(needless_borrowed_ref::NEEDLESS_BORROWED_REFERENCE),
 +    LintId::of(needless_option_as_deref::NEEDLESS_OPTION_AS_DEREF),
 +    LintId::of(needless_question_mark::NEEDLESS_QUESTION_MARK),
 +    LintId::of(needless_update::NEEDLESS_UPDATE),
 +    LintId::of(neg_cmp_op_on_partial_ord::NEG_CMP_OP_ON_PARTIAL_ORD),
 +    LintId::of(no_effect::NO_EFFECT),
 +    LintId::of(no_effect::UNNECESSARY_OPERATION),
 +    LintId::of(overflow_check_conditional::OVERFLOW_CHECK_CONDITIONAL),
 +    LintId::of(partialeq_ne_impl::PARTIALEQ_NE_IMPL),
 +    LintId::of(precedence::PRECEDENCE),
 +    LintId::of(ptr_offset_with_cast::PTR_OFFSET_WITH_CAST),
 +    LintId::of(ranges::RANGE_ZIP_WITH_LEN),
 +    LintId::of(redundant_closure_call::REDUNDANT_CLOSURE_CALL),
 +    LintId::of(redundant_slicing::REDUNDANT_SLICING),
 +    LintId::of(reference::DEREF_ADDROF),
 +    LintId::of(repeat_once::REPEAT_ONCE),
 +    LintId::of(strings::STRING_FROM_UTF8_AS_BYTES),
 +    LintId::of(strlen_on_c_strings::STRLEN_ON_C_STRINGS),
 +    LintId::of(swap::MANUAL_SWAP),
 +    LintId::of(temporary_assignment::TEMPORARY_ASSIGNMENT),
 +    LintId::of(transmute::CROSSPOINTER_TRANSMUTE),
 +    LintId::of(transmute::TRANSMUTES_EXPRESSIBLE_AS_PTR_CASTS),
 +    LintId::of(transmute::TRANSMUTE_BYTES_TO_STR),
 +    LintId::of(transmute::TRANSMUTE_FLOAT_TO_INT),
 +    LintId::of(transmute::TRANSMUTE_INT_TO_BOOL),
 +    LintId::of(transmute::TRANSMUTE_INT_TO_CHAR),
 +    LintId::of(transmute::TRANSMUTE_INT_TO_FLOAT),
 +    LintId::of(transmute::TRANSMUTE_NUM_TO_BYTES),
 +    LintId::of(transmute::TRANSMUTE_PTR_TO_REF),
 +    LintId::of(types::BORROWED_BOX),
 +    LintId::of(types::TYPE_COMPLEXITY),
 +    LintId::of(types::VEC_BOX),
 +    LintId::of(unit_types::UNIT_ARG),
 +    LintId::of(unnecessary_sort_by::UNNECESSARY_SORT_BY),
 +    LintId::of(unwrap::UNNECESSARY_UNWRAP),
 +    LintId::of(useless_conversion::USELESS_CONVERSION),
 +    LintId::of(zero_div_zero::ZERO_DIVIDED_BY_ZERO),
 +])
index 56146a0fd3a7525d84cfeb51f2dd08cfdf8119c0,0000000000000000000000000000000000000000..2d2693832e9716721feb10b87b1e9fba457e205a
mode 100644,000000..100644
--- /dev/null
@@@ -1,536 -1,0 +1,535 @@@
-     reference::REF_IN_DEREF,
 +// This file was generated by `cargo dev update_lints`.
 +// Use that command to update this file and do not edit by hand.
 +// Manual edits will be overwritten.
 +
 +store.register_lints(&[
 +    #[cfg(feature = "internal")]
 +    utils::internal_lints::CLIPPY_LINTS_INTERNAL,
 +    #[cfg(feature = "internal")]
 +    utils::internal_lints::COLLAPSIBLE_SPAN_LINT_CALLS,
 +    #[cfg(feature = "internal")]
 +    utils::internal_lints::COMPILER_LINT_FUNCTIONS,
 +    #[cfg(feature = "internal")]
 +    utils::internal_lints::DEFAULT_LINT,
 +    #[cfg(feature = "internal")]
 +    utils::internal_lints::IF_CHAIN_STYLE,
 +    #[cfg(feature = "internal")]
 +    utils::internal_lints::INTERNING_DEFINED_SYMBOL,
 +    #[cfg(feature = "internal")]
 +    utils::internal_lints::INVALID_CLIPPY_VERSION_ATTRIBUTE,
 +    #[cfg(feature = "internal")]
 +    utils::internal_lints::INVALID_PATHS,
 +    #[cfg(feature = "internal")]
 +    utils::internal_lints::LINT_WITHOUT_LINT_PASS,
 +    #[cfg(feature = "internal")]
 +    utils::internal_lints::MATCH_TYPE_ON_DIAGNOSTIC_ITEM,
 +    #[cfg(feature = "internal")]
 +    utils::internal_lints::MISSING_CLIPPY_VERSION_ATTRIBUTE,
 +    #[cfg(feature = "internal")]
 +    utils::internal_lints::OUTER_EXPN_EXPN_DATA,
 +    #[cfg(feature = "internal")]
 +    utils::internal_lints::PRODUCE_ICE,
 +    #[cfg(feature = "internal")]
 +    utils::internal_lints::UNNECESSARY_SYMBOL_STR,
 +    absurd_extreme_comparisons::ABSURD_EXTREME_COMPARISONS,
 +    approx_const::APPROX_CONSTANT,
 +    arithmetic::FLOAT_ARITHMETIC,
 +    arithmetic::INTEGER_ARITHMETIC,
 +    as_conversions::AS_CONVERSIONS,
 +    asm_syntax::INLINE_ASM_X86_ATT_SYNTAX,
 +    asm_syntax::INLINE_ASM_X86_INTEL_SYNTAX,
 +    assertions_on_constants::ASSERTIONS_ON_CONSTANTS,
 +    assign_ops::ASSIGN_OP_PATTERN,
 +    assign_ops::MISREFACTORED_ASSIGN_OP,
 +    async_yields_async::ASYNC_YIELDS_ASYNC,
 +    attrs::BLANKET_CLIPPY_RESTRICTION_LINTS,
 +    attrs::DEPRECATED_CFG_ATTR,
 +    attrs::DEPRECATED_SEMVER,
 +    attrs::EMPTY_LINE_AFTER_OUTER_ATTR,
 +    attrs::INLINE_ALWAYS,
 +    attrs::MISMATCHED_TARGET_OS,
 +    attrs::USELESS_ATTRIBUTE,
 +    await_holding_invalid::AWAIT_HOLDING_LOCK,
 +    await_holding_invalid::AWAIT_HOLDING_REFCELL_REF,
 +    bit_mask::BAD_BIT_MASK,
 +    bit_mask::INEFFECTIVE_BIT_MASK,
 +    bit_mask::VERBOSE_BIT_MASK,
 +    blacklisted_name::BLACKLISTED_NAME,
 +    blocks_in_if_conditions::BLOCKS_IN_IF_CONDITIONS,
 +    bool_assert_comparison::BOOL_ASSERT_COMPARISON,
 +    booleans::LOGIC_BUG,
 +    booleans::NONMINIMAL_BOOL,
 +    borrow_as_ptr::BORROW_AS_PTR,
 +    bytecount::NAIVE_BYTECOUNT,
 +    cargo_common_metadata::CARGO_COMMON_METADATA,
 +    case_sensitive_file_extension_comparisons::CASE_SENSITIVE_FILE_EXTENSION_COMPARISONS,
 +    casts::CAST_LOSSLESS,
 +    casts::CAST_POSSIBLE_TRUNCATION,
 +    casts::CAST_POSSIBLE_WRAP,
 +    casts::CAST_PRECISION_LOSS,
 +    casts::CAST_PTR_ALIGNMENT,
 +    casts::CAST_REF_TO_MUT,
 +    casts::CAST_SIGN_LOSS,
 +    casts::CHAR_LIT_AS_U8,
 +    casts::FN_TO_NUMERIC_CAST,
 +    casts::FN_TO_NUMERIC_CAST_ANY,
 +    casts::FN_TO_NUMERIC_CAST_WITH_TRUNCATION,
 +    casts::PTR_AS_PTR,
 +    casts::UNNECESSARY_CAST,
 +    checked_conversions::CHECKED_CONVERSIONS,
 +    cognitive_complexity::COGNITIVE_COMPLEXITY,
 +    collapsible_if::COLLAPSIBLE_ELSE_IF,
 +    collapsible_if::COLLAPSIBLE_IF,
 +    collapsible_match::COLLAPSIBLE_MATCH,
 +    comparison_chain::COMPARISON_CHAIN,
 +    copies::BRANCHES_SHARING_CODE,
 +    copies::IFS_SAME_COND,
 +    copies::IF_SAME_THEN_ELSE,
 +    copies::SAME_FUNCTIONS_IN_IF_CONDITION,
 +    copy_iterator::COPY_ITERATOR,
 +    create_dir::CREATE_DIR,
 +    dbg_macro::DBG_MACRO,
 +    default::DEFAULT_TRAIT_ACCESS,
 +    default::FIELD_REASSIGN_WITH_DEFAULT,
 +    default_numeric_fallback::DEFAULT_NUMERIC_FALLBACK,
 +    dereference::EXPLICIT_DEREF_METHODS,
 +    dereference::NEEDLESS_BORROW,
 +    dereference::REF_BINDING_TO_REFERENCE,
 +    derivable_impls::DERIVABLE_IMPLS,
 +    derive::DERIVE_HASH_XOR_EQ,
 +    derive::DERIVE_ORD_XOR_PARTIAL_ORD,
 +    derive::EXPL_IMPL_CLONE_ON_COPY,
 +    derive::UNSAFE_DERIVE_DESERIALIZE,
 +    disallowed_methods::DISALLOWED_METHODS,
 +    disallowed_script_idents::DISALLOWED_SCRIPT_IDENTS,
 +    disallowed_types::DISALLOWED_TYPES,
 +    doc::DOC_MARKDOWN,
 +    doc::MISSING_ERRORS_DOC,
 +    doc::MISSING_PANICS_DOC,
 +    doc::MISSING_SAFETY_DOC,
 +    doc::NEEDLESS_DOCTEST_MAIN,
 +    double_comparison::DOUBLE_COMPARISONS,
 +    double_parens::DOUBLE_PARENS,
 +    drop_forget_ref::DROP_COPY,
 +    drop_forget_ref::DROP_REF,
 +    drop_forget_ref::FORGET_COPY,
 +    drop_forget_ref::FORGET_REF,
 +    duration_subsec::DURATION_SUBSEC,
 +    else_if_without_else::ELSE_IF_WITHOUT_ELSE,
 +    empty_enum::EMPTY_ENUM,
 +    entry::MAP_ENTRY,
 +    enum_clike::ENUM_CLIKE_UNPORTABLE_VARIANT,
 +    enum_variants::ENUM_VARIANT_NAMES,
 +    enum_variants::MODULE_INCEPTION,
 +    enum_variants::MODULE_NAME_REPETITIONS,
 +    eq_op::EQ_OP,
 +    eq_op::OP_REF,
 +    equatable_if_let::EQUATABLE_IF_LET,
 +    erasing_op::ERASING_OP,
 +    escape::BOXED_LOCAL,
 +    eta_reduction::REDUNDANT_CLOSURE,
 +    eta_reduction::REDUNDANT_CLOSURE_FOR_METHOD_CALLS,
 +    eval_order_dependence::DIVERGING_SUB_EXPRESSION,
 +    eval_order_dependence::EVAL_ORDER_DEPENDENCE,
 +    excessive_bools::FN_PARAMS_EXCESSIVE_BOOLS,
 +    excessive_bools::STRUCT_EXCESSIVE_BOOLS,
 +    exhaustive_items::EXHAUSTIVE_ENUMS,
 +    exhaustive_items::EXHAUSTIVE_STRUCTS,
 +    exit::EXIT,
 +    explicit_write::EXPLICIT_WRITE,
 +    fallible_impl_from::FALLIBLE_IMPL_FROM,
 +    feature_name::NEGATIVE_FEATURE_NAMES,
 +    feature_name::REDUNDANT_FEATURE_NAMES,
 +    float_equality_without_abs::FLOAT_EQUALITY_WITHOUT_ABS,
 +    float_literal::EXCESSIVE_PRECISION,
 +    float_literal::LOSSY_FLOAT_LITERAL,
 +    floating_point_arithmetic::IMPRECISE_FLOPS,
 +    floating_point_arithmetic::SUBOPTIMAL_FLOPS,
 +    format::USELESS_FORMAT,
 +    format_args::FORMAT_IN_FORMAT_ARGS,
 +    format_args::TO_STRING_IN_FORMAT_ARGS,
 +    formatting::POSSIBLE_MISSING_COMMA,
 +    formatting::SUSPICIOUS_ASSIGNMENT_FORMATTING,
 +    formatting::SUSPICIOUS_ELSE_FORMATTING,
 +    formatting::SUSPICIOUS_UNARY_OP_FORMATTING,
 +    from_over_into::FROM_OVER_INTO,
 +    from_str_radix_10::FROM_STR_RADIX_10,
 +    functions::DOUBLE_MUST_USE,
 +    functions::MUST_USE_CANDIDATE,
 +    functions::MUST_USE_UNIT,
 +    functions::NOT_UNSAFE_PTR_ARG_DEREF,
 +    functions::RESULT_UNIT_ERR,
 +    functions::TOO_MANY_ARGUMENTS,
 +    functions::TOO_MANY_LINES,
 +    future_not_send::FUTURE_NOT_SEND,
 +    get_last_with_len::GET_LAST_WITH_LEN,
 +    identity_op::IDENTITY_OP,
 +    if_let_mutex::IF_LET_MUTEX,
 +    if_not_else::IF_NOT_ELSE,
 +    if_then_some_else_none::IF_THEN_SOME_ELSE_NONE,
 +    implicit_hasher::IMPLICIT_HASHER,
 +    implicit_return::IMPLICIT_RETURN,
 +    implicit_saturating_sub::IMPLICIT_SATURATING_SUB,
 +    inconsistent_struct_constructor::INCONSISTENT_STRUCT_CONSTRUCTOR,
 +    index_refutable_slice::INDEX_REFUTABLE_SLICE,
 +    indexing_slicing::INDEXING_SLICING,
 +    indexing_slicing::OUT_OF_BOUNDS_INDEXING,
 +    infinite_iter::INFINITE_ITER,
 +    infinite_iter::MAYBE_INFINITE_ITER,
 +    inherent_impl::MULTIPLE_INHERENT_IMPL,
 +    inherent_to_string::INHERENT_TO_STRING,
 +    inherent_to_string::INHERENT_TO_STRING_SHADOW_DISPLAY,
 +    init_numbered_fields::INIT_NUMBERED_FIELDS,
 +    inline_fn_without_body::INLINE_FN_WITHOUT_BODY,
 +    int_plus_one::INT_PLUS_ONE,
 +    integer_division::INTEGER_DIVISION,
 +    invalid_upcast_comparisons::INVALID_UPCAST_COMPARISONS,
 +    items_after_statements::ITEMS_AFTER_STATEMENTS,
 +    iter_not_returning_iterator::ITER_NOT_RETURNING_ITERATOR,
 +    large_const_arrays::LARGE_CONST_ARRAYS,
 +    large_enum_variant::LARGE_ENUM_VARIANT,
 +    large_stack_arrays::LARGE_STACK_ARRAYS,
 +    len_zero::COMPARISON_TO_EMPTY,
 +    len_zero::LEN_WITHOUT_IS_EMPTY,
 +    len_zero::LEN_ZERO,
 +    let_if_seq::USELESS_LET_IF_SEQ,
 +    let_underscore::LET_UNDERSCORE_DROP,
 +    let_underscore::LET_UNDERSCORE_LOCK,
 +    let_underscore::LET_UNDERSCORE_MUST_USE,
 +    lifetimes::EXTRA_UNUSED_LIFETIMES,
 +    lifetimes::NEEDLESS_LIFETIMES,
 +    literal_representation::DECIMAL_LITERAL_REPRESENTATION,
 +    literal_representation::INCONSISTENT_DIGIT_GROUPING,
 +    literal_representation::LARGE_DIGIT_GROUPS,
 +    literal_representation::MISTYPED_LITERAL_SUFFIXES,
 +    literal_representation::UNREADABLE_LITERAL,
 +    literal_representation::UNUSUAL_BYTE_GROUPINGS,
 +    loops::EMPTY_LOOP,
 +    loops::EXPLICIT_COUNTER_LOOP,
 +    loops::EXPLICIT_INTO_ITER_LOOP,
 +    loops::EXPLICIT_ITER_LOOP,
 +    loops::FOR_KV_MAP,
 +    loops::FOR_LOOPS_OVER_FALLIBLES,
 +    loops::ITER_NEXT_LOOP,
 +    loops::MANUAL_FLATTEN,
 +    loops::MANUAL_MEMCPY,
 +    loops::MUT_RANGE_BOUND,
 +    loops::NEEDLESS_COLLECT,
 +    loops::NEEDLESS_RANGE_LOOP,
 +    loops::NEVER_LOOP,
 +    loops::SAME_ITEM_PUSH,
 +    loops::SINGLE_ELEMENT_LOOP,
 +    loops::WHILE_IMMUTABLE_CONDITION,
 +    loops::WHILE_LET_LOOP,
 +    loops::WHILE_LET_ON_ITERATOR,
 +    macro_use::MACRO_USE_IMPORTS,
 +    main_recursion::MAIN_RECURSION,
 +    manual_assert::MANUAL_ASSERT,
 +    manual_async_fn::MANUAL_ASYNC_FN,
 +    manual_bits::MANUAL_BITS,
 +    manual_map::MANUAL_MAP,
 +    manual_non_exhaustive::MANUAL_NON_EXHAUSTIVE,
 +    manual_ok_or::MANUAL_OK_OR,
 +    manual_strip::MANUAL_STRIP,
 +    manual_unwrap_or::MANUAL_UNWRAP_OR,
 +    map_clone::MAP_CLONE,
 +    map_err_ignore::MAP_ERR_IGNORE,
 +    map_unit_fn::OPTION_MAP_UNIT_FN,
 +    map_unit_fn::RESULT_MAP_UNIT_FN,
 +    match_on_vec_items::MATCH_ON_VEC_ITEMS,
 +    match_result_ok::MATCH_RESULT_OK,
 +    match_str_case_mismatch::MATCH_STR_CASE_MISMATCH,
 +    matches::INFALLIBLE_DESTRUCTURING_MATCH,
 +    matches::MATCH_AS_REF,
 +    matches::MATCH_BOOL,
 +    matches::MATCH_LIKE_MATCHES_MACRO,
 +    matches::MATCH_OVERLAPPING_ARM,
 +    matches::MATCH_REF_PATS,
 +    matches::MATCH_SAME_ARMS,
 +    matches::MATCH_SINGLE_BINDING,
 +    matches::MATCH_WILDCARD_FOR_SINGLE_VARIANTS,
 +    matches::MATCH_WILD_ERR_ARM,
 +    matches::REDUNDANT_PATTERN_MATCHING,
 +    matches::REST_PAT_IN_FULLY_BOUND_STRUCTS,
 +    matches::SINGLE_MATCH,
 +    matches::SINGLE_MATCH_ELSE,
 +    matches::WILDCARD_ENUM_MATCH_ARM,
 +    matches::WILDCARD_IN_OR_PATTERNS,
 +    mem_forget::MEM_FORGET,
 +    mem_replace::MEM_REPLACE_OPTION_WITH_NONE,
 +    mem_replace::MEM_REPLACE_WITH_DEFAULT,
 +    mem_replace::MEM_REPLACE_WITH_UNINIT,
 +    methods::BIND_INSTEAD_OF_MAP,
 +    methods::BYTES_NTH,
 +    methods::CHARS_LAST_CMP,
 +    methods::CHARS_NEXT_CMP,
 +    methods::CLONED_INSTEAD_OF_COPIED,
 +    methods::CLONE_DOUBLE_REF,
 +    methods::CLONE_ON_COPY,
 +    methods::CLONE_ON_REF_PTR,
 +    methods::EXPECT_FUN_CALL,
 +    methods::EXPECT_USED,
 +    methods::EXTEND_WITH_DRAIN,
 +    methods::FILETYPE_IS_FILE,
 +    methods::FILTER_MAP_IDENTITY,
 +    methods::FILTER_MAP_NEXT,
 +    methods::FILTER_NEXT,
 +    methods::FLAT_MAP_IDENTITY,
 +    methods::FLAT_MAP_OPTION,
 +    methods::FROM_ITER_INSTEAD_OF_COLLECT,
 +    methods::GET_UNWRAP,
 +    methods::IMPLICIT_CLONE,
 +    methods::INEFFICIENT_TO_STRING,
 +    methods::INSPECT_FOR_EACH,
 +    methods::INTO_ITER_ON_REF,
 +    methods::ITERATOR_STEP_BY_ZERO,
 +    methods::ITER_CLONED_COLLECT,
 +    methods::ITER_COUNT,
 +    methods::ITER_NEXT_SLICE,
 +    methods::ITER_NTH,
 +    methods::ITER_NTH_ZERO,
 +    methods::ITER_OVEREAGER_CLONED,
 +    methods::ITER_SKIP_NEXT,
 +    methods::MANUAL_FILTER_MAP,
 +    methods::MANUAL_FIND_MAP,
 +    methods::MANUAL_SATURATING_ARITHMETIC,
 +    methods::MANUAL_SPLIT_ONCE,
 +    methods::MANUAL_STR_REPEAT,
 +    methods::MAP_COLLECT_RESULT_UNIT,
 +    methods::MAP_FLATTEN,
 +    methods::MAP_IDENTITY,
 +    methods::MAP_UNWRAP_OR,
 +    methods::NEEDLESS_SPLITN,
 +    methods::NEW_RET_NO_SELF,
 +    methods::OK_EXPECT,
 +    methods::OPTION_AS_REF_DEREF,
 +    methods::OPTION_FILTER_MAP,
 +    methods::OPTION_MAP_OR_NONE,
 +    methods::OR_FUN_CALL,
 +    methods::RESULT_MAP_OR_INTO_OPTION,
 +    methods::SEARCH_IS_SOME,
 +    methods::SHOULD_IMPLEMENT_TRAIT,
 +    methods::SINGLE_CHAR_ADD_STR,
 +    methods::SINGLE_CHAR_PATTERN,
 +    methods::SKIP_WHILE_NEXT,
 +    methods::STRING_EXTEND_CHARS,
 +    methods::SUSPICIOUS_MAP,
 +    methods::SUSPICIOUS_SPLITN,
 +    methods::UNINIT_ASSUMED_INIT,
 +    methods::UNNECESSARY_FILTER_MAP,
 +    methods::UNNECESSARY_FOLD,
 +    methods::UNNECESSARY_LAZY_EVALUATIONS,
 +    methods::UNNECESSARY_TO_OWNED,
 +    methods::UNWRAP_OR_ELSE_DEFAULT,
 +    methods::UNWRAP_USED,
 +    methods::USELESS_ASREF,
 +    methods::WRONG_SELF_CONVENTION,
 +    methods::ZST_OFFSET,
 +    minmax::MIN_MAX,
 +    misc::CMP_NAN,
 +    misc::CMP_OWNED,
 +    misc::FLOAT_CMP,
 +    misc::FLOAT_CMP_CONST,
 +    misc::MODULO_ONE,
 +    misc::SHORT_CIRCUIT_STATEMENT,
 +    misc::TOPLEVEL_REF_ARG,
 +    misc::USED_UNDERSCORE_BINDING,
 +    misc::ZERO_PTR,
 +    misc_early::BUILTIN_TYPE_SHADOW,
 +    misc_early::DOUBLE_NEG,
 +    misc_early::DUPLICATE_UNDERSCORE_ARGUMENT,
 +    misc_early::MIXED_CASE_HEX_LITERALS,
 +    misc_early::REDUNDANT_PATTERN,
 +    misc_early::SEPARATED_LITERAL_SUFFIX,
 +    misc_early::UNNEEDED_FIELD_PATTERN,
 +    misc_early::UNNEEDED_WILDCARD_PATTERN,
 +    misc_early::UNSEPARATED_LITERAL_SUFFIX,
 +    misc_early::ZERO_PREFIXED_LITERAL,
 +    missing_const_for_fn::MISSING_CONST_FOR_FN,
 +    missing_doc::MISSING_DOCS_IN_PRIVATE_ITEMS,
 +    missing_enforced_import_rename::MISSING_ENFORCED_IMPORT_RENAMES,
 +    missing_inline::MISSING_INLINE_IN_PUBLIC_ITEMS,
 +    module_style::MOD_MODULE_FILES,
 +    module_style::SELF_NAMED_MODULE_FILES,
 +    modulo_arithmetic::MODULO_ARITHMETIC,
 +    multiple_crate_versions::MULTIPLE_CRATE_VERSIONS,
 +    mut_key::MUTABLE_KEY_TYPE,
 +    mut_mut::MUT_MUT,
 +    mut_mutex_lock::MUT_MUTEX_LOCK,
 +    mut_reference::UNNECESSARY_MUT_PASSED,
 +    mutable_debug_assertion::DEBUG_ASSERT_WITH_MUT_CALL,
 +    mutex_atomic::MUTEX_ATOMIC,
 +    mutex_atomic::MUTEX_INTEGER,
 +    needless_arbitrary_self_type::NEEDLESS_ARBITRARY_SELF_TYPE,
 +    needless_bitwise_bool::NEEDLESS_BITWISE_BOOL,
 +    needless_bool::BOOL_COMPARISON,
 +    needless_bool::NEEDLESS_BOOL,
 +    needless_borrowed_ref::NEEDLESS_BORROWED_REFERENCE,
 +    needless_continue::NEEDLESS_CONTINUE,
 +    needless_for_each::NEEDLESS_FOR_EACH,
 +    needless_late_init::NEEDLESS_LATE_INIT,
 +    needless_option_as_deref::NEEDLESS_OPTION_AS_DEREF,
 +    needless_pass_by_value::NEEDLESS_PASS_BY_VALUE,
 +    needless_question_mark::NEEDLESS_QUESTION_MARK,
 +    needless_update::NEEDLESS_UPDATE,
 +    neg_cmp_op_on_partial_ord::NEG_CMP_OP_ON_PARTIAL_ORD,
 +    neg_multiply::NEG_MULTIPLY,
 +    new_without_default::NEW_WITHOUT_DEFAULT,
 +    no_effect::NO_EFFECT,
 +    no_effect::NO_EFFECT_UNDERSCORE_BINDING,
 +    no_effect::UNNECESSARY_OPERATION,
 +    non_copy_const::BORROW_INTERIOR_MUTABLE_CONST,
 +    non_copy_const::DECLARE_INTERIOR_MUTABLE_CONST,
 +    non_expressive_names::JUST_UNDERSCORES_AND_DIGITS,
 +    non_expressive_names::MANY_SINGLE_CHAR_NAMES,
 +    non_expressive_names::SIMILAR_NAMES,
 +    non_octal_unix_permissions::NON_OCTAL_UNIX_PERMISSIONS,
 +    non_send_fields_in_send_ty::NON_SEND_FIELDS_IN_SEND_TY,
 +    nonstandard_macro_braces::NONSTANDARD_MACRO_BRACES,
 +    octal_escapes::OCTAL_ESCAPES,
 +    open_options::NONSENSICAL_OPEN_OPTIONS,
 +    option_env_unwrap::OPTION_ENV_UNWRAP,
 +    option_if_let_else::OPTION_IF_LET_ELSE,
 +    overflow_check_conditional::OVERFLOW_CHECK_CONDITIONAL,
 +    panic_in_result_fn::PANIC_IN_RESULT_FN,
 +    panic_unimplemented::PANIC,
 +    panic_unimplemented::TODO,
 +    panic_unimplemented::UNIMPLEMENTED,
 +    panic_unimplemented::UNREACHABLE,
 +    partialeq_ne_impl::PARTIALEQ_NE_IMPL,
 +    pass_by_ref_or_value::LARGE_TYPES_PASSED_BY_VALUE,
 +    pass_by_ref_or_value::TRIVIALLY_COPY_PASS_BY_REF,
 +    path_buf_push_overwrite::PATH_BUF_PUSH_OVERWRITE,
 +    pattern_type_mismatch::PATTERN_TYPE_MISMATCH,
 +    precedence::PRECEDENCE,
 +    ptr::CMP_NULL,
 +    ptr::INVALID_NULL_PTR_USAGE,
 +    ptr::MUT_FROM_REF,
 +    ptr::PTR_ARG,
 +    ptr_eq::PTR_EQ,
 +    ptr_offset_with_cast::PTR_OFFSET_WITH_CAST,
 +    question_mark::QUESTION_MARK,
 +    ranges::MANUAL_RANGE_CONTAINS,
 +    ranges::RANGE_MINUS_ONE,
 +    ranges::RANGE_PLUS_ONE,
 +    ranges::RANGE_ZIP_WITH_LEN,
 +    ranges::REVERSED_EMPTY_RANGES,
 +    redundant_clone::REDUNDANT_CLONE,
 +    redundant_closure_call::REDUNDANT_CLOSURE_CALL,
 +    redundant_else::REDUNDANT_ELSE,
 +    redundant_field_names::REDUNDANT_FIELD_NAMES,
 +    redundant_pub_crate::REDUNDANT_PUB_CRATE,
 +    redundant_slicing::REDUNDANT_SLICING,
 +    redundant_static_lifetimes::REDUNDANT_STATIC_LIFETIMES,
 +    ref_option_ref::REF_OPTION_REF,
 +    reference::DEREF_ADDROF,
 +    regex::INVALID_REGEX,
 +    regex::TRIVIAL_REGEX,
 +    repeat_once::REPEAT_ONCE,
 +    return_self_not_must_use::RETURN_SELF_NOT_MUST_USE,
 +    returns::LET_AND_RETURN,
 +    returns::NEEDLESS_RETURN,
 +    same_name_method::SAME_NAME_METHOD,
 +    self_assignment::SELF_ASSIGNMENT,
 +    self_named_constructors::SELF_NAMED_CONSTRUCTORS,
 +    semicolon_if_nothing_returned::SEMICOLON_IF_NOTHING_RETURNED,
 +    serde_api::SERDE_API_MISUSE,
 +    shadow::SHADOW_REUSE,
 +    shadow::SHADOW_SAME,
 +    shadow::SHADOW_UNRELATED,
 +    single_char_lifetime_names::SINGLE_CHAR_LIFETIME_NAMES,
 +    single_component_path_imports::SINGLE_COMPONENT_PATH_IMPORTS,
 +    size_of_in_element_count::SIZE_OF_IN_ELEMENT_COUNT,
 +    slow_vector_initialization::SLOW_VECTOR_INITIALIZATION,
 +    stable_sort_primitive::STABLE_SORT_PRIMITIVE,
 +    strings::STRING_ADD,
 +    strings::STRING_ADD_ASSIGN,
 +    strings::STRING_FROM_UTF8_AS_BYTES,
 +    strings::STRING_LIT_AS_BYTES,
 +    strings::STRING_SLICE,
 +    strings::STRING_TO_STRING,
 +    strings::STR_TO_STRING,
 +    strlen_on_c_strings::STRLEN_ON_C_STRINGS,
 +    suspicious_operation_groupings::SUSPICIOUS_OPERATION_GROUPINGS,
 +    suspicious_trait_impl::SUSPICIOUS_ARITHMETIC_IMPL,
 +    suspicious_trait_impl::SUSPICIOUS_OP_ASSIGN_IMPL,
 +    swap::ALMOST_SWAPPED,
 +    swap::MANUAL_SWAP,
 +    tabs_in_doc_comments::TABS_IN_DOC_COMMENTS,
 +    temporary_assignment::TEMPORARY_ASSIGNMENT,
 +    to_digit_is_some::TO_DIGIT_IS_SOME,
 +    to_string_in_display::TO_STRING_IN_DISPLAY,
 +    trailing_empty_array::TRAILING_EMPTY_ARRAY,
 +    trait_bounds::TRAIT_DUPLICATION_IN_BOUNDS,
 +    trait_bounds::TYPE_REPETITION_IN_BOUNDS,
 +    transmute::CROSSPOINTER_TRANSMUTE,
 +    transmute::TRANSMUTES_EXPRESSIBLE_AS_PTR_CASTS,
 +    transmute::TRANSMUTE_BYTES_TO_STR,
 +    transmute::TRANSMUTE_FLOAT_TO_INT,
 +    transmute::TRANSMUTE_INT_TO_BOOL,
 +    transmute::TRANSMUTE_INT_TO_CHAR,
 +    transmute::TRANSMUTE_INT_TO_FLOAT,
 +    transmute::TRANSMUTE_NUM_TO_BYTES,
 +    transmute::TRANSMUTE_PTR_TO_PTR,
 +    transmute::TRANSMUTE_PTR_TO_REF,
 +    transmute::UNSOUND_COLLECTION_TRANSMUTE,
 +    transmute::USELESS_TRANSMUTE,
 +    transmute::WRONG_TRANSMUTE,
 +    transmuting_null::TRANSMUTING_NULL,
 +    try_err::TRY_ERR,
 +    types::BORROWED_BOX,
 +    types::BOX_COLLECTION,
 +    types::LINKEDLIST,
 +    types::OPTION_OPTION,
 +    types::RC_BUFFER,
 +    types::RC_MUTEX,
 +    types::REDUNDANT_ALLOCATION,
 +    types::TYPE_COMPLEXITY,
 +    types::VEC_BOX,
 +    undocumented_unsafe_blocks::UNDOCUMENTED_UNSAFE_BLOCKS,
 +    undropped_manually_drops::UNDROPPED_MANUALLY_DROPS,
 +    unicode::INVISIBLE_CHARACTERS,
 +    unicode::NON_ASCII_LITERAL,
 +    unicode::UNICODE_NOT_NFC,
 +    uninit_vec::UNINIT_VEC,
 +    unit_hash::UNIT_HASH,
 +    unit_return_expecting_ord::UNIT_RETURN_EXPECTING_ORD,
 +    unit_types::LET_UNIT_VALUE,
 +    unit_types::UNIT_ARG,
 +    unit_types::UNIT_CMP,
 +    unnamed_address::FN_ADDRESS_COMPARISONS,
 +    unnamed_address::VTABLE_ADDRESS_COMPARISONS,
 +    unnecessary_self_imports::UNNECESSARY_SELF_IMPORTS,
 +    unnecessary_sort_by::UNNECESSARY_SORT_BY,
 +    unnecessary_wraps::UNNECESSARY_WRAPS,
 +    unnested_or_patterns::UNNESTED_OR_PATTERNS,
 +    unsafe_removed_from_name::UNSAFE_REMOVED_FROM_NAME,
 +    unused_async::UNUSED_ASYNC,
 +    unused_io_amount::UNUSED_IO_AMOUNT,
 +    unused_self::UNUSED_SELF,
 +    unused_unit::UNUSED_UNIT,
 +    unwrap::PANICKING_UNWRAP,
 +    unwrap::UNNECESSARY_UNWRAP,
 +    unwrap_in_result::UNWRAP_IN_RESULT,
 +    upper_case_acronyms::UPPER_CASE_ACRONYMS,
 +    use_self::USE_SELF,
 +    useless_conversion::USELESS_CONVERSION,
 +    vec::USELESS_VEC,
 +    vec_init_then_push::VEC_INIT_THEN_PUSH,
 +    vec_resize_to_zero::VEC_RESIZE_TO_ZERO,
 +    verbose_file_reads::VERBOSE_FILE_READS,
 +    wildcard_dependencies::WILDCARD_DEPENDENCIES,
 +    wildcard_imports::ENUM_GLOB_USE,
 +    wildcard_imports::WILDCARD_IMPORTS,
 +    write::PRINTLN_EMPTY_STRING,
 +    write::PRINT_LITERAL,
 +    write::PRINT_STDERR,
 +    write::PRINT_STDOUT,
 +    write::PRINT_WITH_NEWLINE,
 +    write::USE_DEBUG,
 +    write::WRITELN_EMPTY_STRING,
 +    write::WRITE_LITERAL,
 +    write::WRITE_WITH_NEWLINE,
 +    zero_div_zero::ZERO_DIVIDED_BY_ZERO,
 +    zero_sized_map_values::ZERO_SIZED_MAP_VALUES,
 +])
index 79e9882fef4c49c42c2d6fb4bca32878a42f23bf,0000000000000000000000000000000000000000..f2a7e925dd3952e698461b003c7347330fc020f0
mode 100644,000000..100644
--- /dev/null
@@@ -1,956 -1,0 +1,956 @@@
-     store.register_late_pass(|| Box::new(map_clone::MapClone));
 +// error-pattern:cargo-clippy
 +
 +#![feature(binary_heap_into_iter_sorted)]
 +#![feature(box_patterns)]
 +#![feature(control_flow_enum)]
 +#![feature(drain_filter)]
 +#![feature(iter_intersperse)]
 +#![feature(let_else)]
 +#![feature(once_cell)]
 +#![feature(rustc_private)]
 +#![feature(stmt_expr_attributes)]
 +#![recursion_limit = "512"]
 +#![cfg_attr(feature = "deny-warnings", deny(warnings))]
 +#![allow(clippy::missing_docs_in_private_items, clippy::must_use_candidate)]
 +#![warn(trivial_casts, trivial_numeric_casts)]
 +// warn on lints, that are included in `rust-lang/rust`s bootstrap
 +#![warn(rust_2018_idioms, unused_lifetimes)]
 +// warn on rustc internal lints
 +#![warn(rustc::internal)]
 +
 +// FIXME: switch to something more ergonomic here, once available.
 +// (Currently there is no way to opt into sysroot crates without `extern crate`.)
 +extern crate rustc_ast;
 +extern crate rustc_ast_pretty;
 +extern crate rustc_data_structures;
 +extern crate rustc_driver;
 +extern crate rustc_errors;
 +extern crate rustc_hir;
 +extern crate rustc_hir_pretty;
 +extern crate rustc_index;
 +extern crate rustc_infer;
 +extern crate rustc_lexer;
 +extern crate rustc_lint;
 +extern crate rustc_middle;
 +extern crate rustc_mir_dataflow;
 +extern crate rustc_parse;
 +extern crate rustc_parse_format;
 +extern crate rustc_session;
 +extern crate rustc_span;
 +extern crate rustc_target;
 +extern crate rustc_trait_selection;
 +extern crate rustc_typeck;
 +
 +#[macro_use]
 +extern crate clippy_utils;
 +
 +use clippy_utils::parse_msrv;
 +use rustc_data_structures::fx::FxHashSet;
 +use rustc_lint::LintId;
 +use rustc_session::Session;
 +
 +/// Macro used to declare a Clippy lint.
 +///
 +/// Every lint declaration consists of 4 parts:
 +///
 +/// 1. The documentation, which is used for the website
 +/// 2. The `LINT_NAME`. See [lint naming][lint_naming] on lint naming conventions.
 +/// 3. The `lint_level`, which is a mapping from *one* of our lint groups to `Allow`, `Warn` or
 +///    `Deny`. The lint level here has nothing to do with what lint groups the lint is a part of.
 +/// 4. The `description` that contains a short explanation on what's wrong with code where the
 +///    lint is triggered.
 +///
 +/// Currently the categories `style`, `correctness`, `suspicious`, `complexity` and `perf` are
 +/// enabled by default. As said in the README.md of this repository, if the lint level mapping
 +/// changes, please update README.md.
 +///
 +/// # Example
 +///
 +/// ```
 +/// #![feature(rustc_private)]
 +/// extern crate rustc_session;
 +/// use rustc_session::declare_tool_lint;
 +/// use clippy_lints::declare_clippy_lint;
 +///
 +/// declare_clippy_lint! {
 +///     /// ### What it does
 +///     /// Checks for ... (describe what the lint matches).
 +///     ///
 +///     /// ### Why is this bad?
 +///     /// Supply the reason for linting the code.
 +///     ///
 +///     /// ### Example
 +///     /// ```rust
 +///     /// // Bad
 +///     /// Insert a short example of code that triggers the lint
 +///     ///
 +///     /// // Good
 +///     /// Insert a short example of improved code that doesn't trigger the lint
 +///     /// ```
 +///     pub LINT_NAME,
 +///     pedantic,
 +///     "description"
 +/// }
 +/// ```
 +/// [lint_naming]: https://rust-lang.github.io/rfcs/0344-conventions-galore.html#lints
 +#[macro_export]
 +macro_rules! declare_clippy_lint {
 +    { $(#[$attr:meta])* pub $name:tt, style, $description:tt } => {
 +        declare_tool_lint! {
 +            $(#[$attr])* pub clippy::$name, Warn, $description, report_in_external_macro: true
 +        }
 +    };
 +    { $(#[$attr:meta])* pub $name:tt, correctness, $description:tt } => {
 +        declare_tool_lint! {
 +            $(#[$attr])* pub clippy::$name, Deny, $description, report_in_external_macro: true
 +        }
 +    };
 +    { $(#[$attr:meta])* pub $name:tt, suspicious, $description:tt } => {
 +        declare_tool_lint! {
 +            $(#[$attr])* pub clippy::$name, Warn, $description, report_in_external_macro: true
 +        }
 +    };
 +    { $(#[$attr:meta])* pub $name:tt, complexity, $description:tt } => {
 +        declare_tool_lint! {
 +            $(#[$attr])* pub clippy::$name, Warn, $description, report_in_external_macro: true
 +        }
 +    };
 +    { $(#[$attr:meta])* pub $name:tt, perf, $description:tt } => {
 +        declare_tool_lint! {
 +            $(#[$attr])* pub clippy::$name, Warn, $description, report_in_external_macro: true
 +        }
 +    };
 +    { $(#[$attr:meta])* pub $name:tt, pedantic, $description:tt } => {
 +        declare_tool_lint! {
 +            $(#[$attr])* pub clippy::$name, Allow, $description, report_in_external_macro: true
 +        }
 +    };
 +    { $(#[$attr:meta])* pub $name:tt, restriction, $description:tt } => {
 +        declare_tool_lint! {
 +            $(#[$attr])* pub clippy::$name, Allow, $description, report_in_external_macro: true
 +        }
 +    };
 +    { $(#[$attr:meta])* pub $name:tt, cargo, $description:tt } => {
 +        declare_tool_lint! {
 +            $(#[$attr])* pub clippy::$name, Allow, $description, report_in_external_macro: true
 +        }
 +    };
 +    { $(#[$attr:meta])* pub $name:tt, nursery, $description:tt } => {
 +        declare_tool_lint! {
 +            $(#[$attr])* pub clippy::$name, Allow, $description, report_in_external_macro: true
 +        }
 +    };
 +    { $(#[$attr:meta])* pub $name:tt, internal, $description:tt } => {
 +        declare_tool_lint! {
 +            $(#[$attr])* pub clippy::$name, Allow, $description, report_in_external_macro: true
 +        }
 +    };
 +    { $(#[$attr:meta])* pub $name:tt, internal_warn, $description:tt } => {
 +        declare_tool_lint! {
 +            $(#[$attr])* pub clippy::$name, Warn, $description, report_in_external_macro: true
 +        }
 +    };
 +}
 +
 +#[cfg(feature = "internal")]
 +mod deprecated_lints;
 +#[cfg_attr(feature = "internal", allow(clippy::missing_clippy_version_attribute))]
 +mod utils;
 +
 +// begin lints modules, do not remove this comment, it’s used in `update_lints`
 +mod absurd_extreme_comparisons;
 +mod approx_const;
 +mod arithmetic;
 +mod as_conversions;
 +mod asm_syntax;
 +mod assertions_on_constants;
 +mod assign_ops;
 +mod async_yields_async;
 +mod attrs;
 +mod await_holding_invalid;
 +mod bit_mask;
 +mod blacklisted_name;
 +mod blocks_in_if_conditions;
 +mod bool_assert_comparison;
 +mod booleans;
 +mod borrow_as_ptr;
 +mod bytecount;
 +mod cargo_common_metadata;
 +mod case_sensitive_file_extension_comparisons;
 +mod casts;
 +mod checked_conversions;
 +mod cognitive_complexity;
 +mod collapsible_if;
 +mod collapsible_match;
 +mod comparison_chain;
 +mod copies;
 +mod copy_iterator;
 +mod create_dir;
 +mod dbg_macro;
 +mod default;
 +mod default_numeric_fallback;
 +mod dereference;
 +mod derivable_impls;
 +mod derive;
 +mod disallowed_methods;
 +mod disallowed_script_idents;
 +mod disallowed_types;
 +mod doc;
 +mod double_comparison;
 +mod double_parens;
 +mod drop_forget_ref;
 +mod duration_subsec;
 +mod else_if_without_else;
 +mod empty_enum;
 +mod entry;
 +mod enum_clike;
 +mod enum_variants;
 +mod eq_op;
 +mod equatable_if_let;
 +mod erasing_op;
 +mod escape;
 +mod eta_reduction;
 +mod eval_order_dependence;
 +mod excessive_bools;
 +mod exhaustive_items;
 +mod exit;
 +mod explicit_write;
 +mod fallible_impl_from;
 +mod feature_name;
 +mod float_equality_without_abs;
 +mod float_literal;
 +mod floating_point_arithmetic;
 +mod format;
 +mod format_args;
 +mod formatting;
 +mod from_over_into;
 +mod from_str_radix_10;
 +mod functions;
 +mod future_not_send;
 +mod get_last_with_len;
 +mod identity_op;
 +mod if_let_mutex;
 +mod if_not_else;
 +mod if_then_some_else_none;
 +mod implicit_hasher;
 +mod implicit_return;
 +mod implicit_saturating_sub;
 +mod inconsistent_struct_constructor;
 +mod index_refutable_slice;
 +mod indexing_slicing;
 +mod infinite_iter;
 +mod inherent_impl;
 +mod inherent_to_string;
 +mod init_numbered_fields;
 +mod inline_fn_without_body;
 +mod int_plus_one;
 +mod integer_division;
 +mod invalid_upcast_comparisons;
 +mod items_after_statements;
 +mod iter_not_returning_iterator;
 +mod large_const_arrays;
 +mod large_enum_variant;
 +mod large_stack_arrays;
 +mod len_zero;
 +mod let_if_seq;
 +mod let_underscore;
 +mod lifetimes;
 +mod literal_representation;
 +mod loops;
 +mod macro_use;
 +mod main_recursion;
 +mod manual_assert;
 +mod manual_async_fn;
 +mod manual_bits;
 +mod manual_map;
 +mod manual_non_exhaustive;
 +mod manual_ok_or;
 +mod manual_strip;
 +mod manual_unwrap_or;
 +mod map_clone;
 +mod map_err_ignore;
 +mod map_unit_fn;
 +mod match_on_vec_items;
 +mod match_result_ok;
 +mod match_str_case_mismatch;
 +mod matches;
 +mod mem_forget;
 +mod mem_replace;
 +mod methods;
 +mod minmax;
 +mod misc;
 +mod misc_early;
 +mod missing_const_for_fn;
 +mod missing_doc;
 +mod missing_enforced_import_rename;
 +mod missing_inline;
 +mod module_style;
 +mod modulo_arithmetic;
 +mod multiple_crate_versions;
 +mod mut_key;
 +mod mut_mut;
 +mod mut_mutex_lock;
 +mod mut_reference;
 +mod mutable_debug_assertion;
 +mod mutex_atomic;
 +mod needless_arbitrary_self_type;
 +mod needless_bitwise_bool;
 +mod needless_bool;
 +mod needless_borrowed_ref;
 +mod needless_continue;
 +mod needless_for_each;
 +mod needless_late_init;
 +mod needless_option_as_deref;
 +mod needless_pass_by_value;
 +mod needless_question_mark;
 +mod needless_update;
 +mod neg_cmp_op_on_partial_ord;
 +mod neg_multiply;
 +mod new_without_default;
 +mod no_effect;
 +mod non_copy_const;
 +mod non_expressive_names;
 +mod non_octal_unix_permissions;
 +mod non_send_fields_in_send_ty;
 +mod nonstandard_macro_braces;
 +mod octal_escapes;
 +mod open_options;
 +mod option_env_unwrap;
 +mod option_if_let_else;
 +mod overflow_check_conditional;
 +mod panic_in_result_fn;
 +mod panic_unimplemented;
 +mod partialeq_ne_impl;
 +mod pass_by_ref_or_value;
 +mod path_buf_push_overwrite;
 +mod pattern_type_mismatch;
 +mod precedence;
 +mod ptr;
 +mod ptr_eq;
 +mod ptr_offset_with_cast;
 +mod question_mark;
 +mod ranges;
 +mod redundant_clone;
 +mod redundant_closure_call;
 +mod redundant_else;
 +mod redundant_field_names;
 +mod redundant_pub_crate;
 +mod redundant_slicing;
 +mod redundant_static_lifetimes;
 +mod ref_option_ref;
 +mod reference;
 +mod regex;
 +mod repeat_once;
 +mod return_self_not_must_use;
 +mod returns;
 +mod same_name_method;
 +mod self_assignment;
 +mod self_named_constructors;
 +mod semicolon_if_nothing_returned;
 +mod serde_api;
 +mod shadow;
 +mod single_char_lifetime_names;
 +mod single_component_path_imports;
 +mod size_of_in_element_count;
 +mod slow_vector_initialization;
 +mod stable_sort_primitive;
 +mod strings;
 +mod strlen_on_c_strings;
 +mod suspicious_operation_groupings;
 +mod suspicious_trait_impl;
 +mod swap;
 +mod tabs_in_doc_comments;
 +mod temporary_assignment;
 +mod to_digit_is_some;
 +mod to_string_in_display;
 +mod trailing_empty_array;
 +mod trait_bounds;
 +mod transmute;
 +mod transmuting_null;
 +mod try_err;
 +mod types;
 +mod undocumented_unsafe_blocks;
 +mod undropped_manually_drops;
 +mod unicode;
 +mod uninit_vec;
 +mod unit_hash;
 +mod unit_return_expecting_ord;
 +mod unit_types;
 +mod unnamed_address;
 +mod unnecessary_self_imports;
 +mod unnecessary_sort_by;
 +mod unnecessary_wraps;
 +mod unnested_or_patterns;
 +mod unsafe_removed_from_name;
 +mod unused_async;
 +mod unused_io_amount;
 +mod unused_self;
 +mod unused_unit;
 +mod unwrap;
 +mod unwrap_in_result;
 +mod upper_case_acronyms;
 +mod use_self;
 +mod useless_conversion;
 +mod vec;
 +mod vec_init_then_push;
 +mod vec_resize_to_zero;
 +mod verbose_file_reads;
 +mod wildcard_dependencies;
 +mod wildcard_imports;
 +mod write;
 +mod zero_div_zero;
 +mod zero_sized_map_values;
 +// end lints modules, do not remove this comment, it’s used in `update_lints`
 +
 +pub use crate::utils::conf::Conf;
 +use crate::utils::conf::TryConf;
 +
 +/// Register all pre expansion lints
 +///
 +/// Pre-expansion lints run before any macro expansion has happened.
 +///
 +/// Note that due to the architecture of the compiler, currently `cfg_attr` attributes on crate
 +/// level (i.e `#![cfg_attr(...)]`) will still be expanded even when using a pre-expansion pass.
 +///
 +/// Used in `./src/driver.rs`.
 +pub fn register_pre_expansion_lints(store: &mut rustc_lint::LintStore, sess: &Session, conf: &Conf) {
 +    // NOTE: Do not add any more pre-expansion passes. These should be removed eventually.
 +
 +    let msrv = conf.msrv.as_ref().and_then(|s| {
 +        parse_msrv(s, None, None).or_else(|| {
 +            sess.err(&format!(
 +                "error reading Clippy's configuration file. `{}` is not a valid Rust version",
 +                s
 +            ));
 +            None
 +        })
 +    });
 +
 +    store.register_pre_expansion_pass(|| Box::new(write::Write::default()));
 +    store.register_pre_expansion_pass(move || Box::new(attrs::EarlyAttributes { msrv }));
 +    store.register_pre_expansion_pass(|| Box::new(dbg_macro::DbgMacro));
 +}
 +
 +#[doc(hidden)]
 +pub fn read_conf(sess: &Session) -> Conf {
 +    let file_name = match utils::conf::lookup_conf_file() {
 +        Ok(Some(path)) => path,
 +        Ok(None) => return Conf::default(),
 +        Err(error) => {
 +            sess.struct_err(&format!("error finding Clippy's configuration file: {}", error))
 +                .emit();
 +            return Conf::default();
 +        },
 +    };
 +
 +    let TryConf { conf, errors } = utils::conf::read(&file_name);
 +    // all conf errors are non-fatal, we just use the default conf in case of error
 +    for error in errors {
 +        sess.struct_err(&format!(
 +            "error reading Clippy's configuration file `{}`: {}",
 +            file_name.display(),
 +            error
 +        ))
 +        .emit();
 +    }
 +
 +    conf
 +}
 +
 +/// Register all lints and lint groups with the rustc plugin registry
 +///
 +/// Used in `./src/driver.rs`.
 +#[allow(clippy::too_many_lines)]
 +pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf: &Conf) {
 +    register_removed_non_tool_lints(store);
 +
 +    include!("lib.deprecated.rs");
 +
 +    include!("lib.register_lints.rs");
 +    include!("lib.register_restriction.rs");
 +    include!("lib.register_pedantic.rs");
 +
 +    #[cfg(feature = "internal")]
 +    include!("lib.register_internal.rs");
 +
 +    include!("lib.register_all.rs");
 +    include!("lib.register_style.rs");
 +    include!("lib.register_complexity.rs");
 +    include!("lib.register_correctness.rs");
 +    include!("lib.register_suspicious.rs");
 +    include!("lib.register_perf.rs");
 +    include!("lib.register_cargo.rs");
 +    include!("lib.register_nursery.rs");
 +
 +    #[cfg(feature = "internal")]
 +    {
 +        if std::env::var("ENABLE_METADATA_COLLECTION").eq(&Ok("1".to_string())) {
 +            store.register_late_pass(|| Box::new(utils::internal_lints::metadata_collector::MetadataCollector::new()));
 +            return;
 +        }
 +    }
 +
 +    // all the internal lints
 +    #[cfg(feature = "internal")]
 +    {
 +        store.register_early_pass(|| Box::new(utils::internal_lints::ClippyLintsInternal));
 +        store.register_early_pass(|| Box::new(utils::internal_lints::ProduceIce));
 +        store.register_late_pass(|| Box::new(utils::inspector::DeepCodeInspector));
 +        store.register_late_pass(|| Box::new(utils::internal_lints::CollapsibleCalls));
 +        store.register_late_pass(|| Box::new(utils::internal_lints::CompilerLintFunctions::new()));
 +        store.register_late_pass(|| Box::new(utils::internal_lints::IfChainStyle));
 +        store.register_late_pass(|| Box::new(utils::internal_lints::InvalidPaths));
 +        store.register_late_pass(|| Box::new(utils::internal_lints::InterningDefinedSymbol::default()));
 +        store.register_late_pass(|| Box::new(utils::internal_lints::LintWithoutLintPass::default()));
 +        store.register_late_pass(|| Box::new(utils::internal_lints::MatchTypeOnDiagItem));
 +        store.register_late_pass(|| Box::new(utils::internal_lints::OuterExpnDataPass));
 +    }
 +
 +    store.register_late_pass(|| Box::new(utils::author::Author));
 +    store.register_late_pass(|| Box::new(await_holding_invalid::AwaitHolding));
 +    store.register_late_pass(|| Box::new(serde_api::SerdeApi));
 +    let vec_box_size_threshold = conf.vec_box_size_threshold;
 +    let type_complexity_threshold = conf.type_complexity_threshold;
 +    let avoid_breaking_exported_api = conf.avoid_breaking_exported_api;
 +    store.register_late_pass(move || {
 +        Box::new(types::Types::new(
 +            vec_box_size_threshold,
 +            type_complexity_threshold,
 +            avoid_breaking_exported_api,
 +        ))
 +    });
 +    store.register_late_pass(|| Box::new(booleans::NonminimalBool));
 +    store.register_late_pass(|| Box::new(needless_bitwise_bool::NeedlessBitwiseBool));
 +    store.register_late_pass(|| Box::new(eq_op::EqOp));
 +    store.register_late_pass(|| Box::new(enum_clike::UnportableVariant));
 +    store.register_late_pass(|| Box::new(float_literal::FloatLiteral));
 +    let verbose_bit_mask_threshold = conf.verbose_bit_mask_threshold;
 +    store.register_late_pass(move || Box::new(bit_mask::BitMask::new(verbose_bit_mask_threshold)));
 +    store.register_late_pass(|| Box::new(ptr::Ptr));
 +    store.register_late_pass(|| Box::new(ptr_eq::PtrEq));
 +    store.register_late_pass(|| Box::new(needless_bool::NeedlessBool));
 +    store.register_late_pass(|| Box::new(needless_option_as_deref::OptionNeedlessDeref));
 +    store.register_late_pass(|| Box::new(needless_bool::BoolComparison));
 +    store.register_late_pass(|| Box::new(needless_for_each::NeedlessForEach));
 +    store.register_late_pass(|| Box::new(misc::MiscLints));
 +    store.register_late_pass(|| Box::new(eta_reduction::EtaReduction));
 +    store.register_late_pass(|| Box::new(identity_op::IdentityOp));
 +    store.register_late_pass(|| Box::new(erasing_op::ErasingOp));
 +    store.register_late_pass(|| Box::new(mut_mut::MutMut));
 +    store.register_late_pass(|| Box::new(mut_reference::UnnecessaryMutPassed));
 +    store.register_late_pass(|| Box::new(len_zero::LenZero));
 +    store.register_late_pass(|| Box::new(attrs::Attributes));
 +    store.register_late_pass(|| Box::new(blocks_in_if_conditions::BlocksInIfConditions));
 +    store.register_late_pass(|| Box::new(collapsible_match::CollapsibleMatch));
 +    store.register_late_pass(|| Box::new(unicode::Unicode));
 +    store.register_late_pass(|| Box::new(uninit_vec::UninitVec));
 +    store.register_late_pass(|| Box::new(unit_hash::UnitHash));
 +    store.register_late_pass(|| Box::new(unit_return_expecting_ord::UnitReturnExpectingOrd));
 +    store.register_late_pass(|| Box::new(strings::StringAdd));
 +    store.register_late_pass(|| Box::new(implicit_return::ImplicitReturn));
 +    store.register_late_pass(|| Box::new(implicit_saturating_sub::ImplicitSaturatingSub));
 +    store.register_late_pass(|| Box::new(default_numeric_fallback::DefaultNumericFallback));
 +    store.register_late_pass(|| Box::new(inconsistent_struct_constructor::InconsistentStructConstructor));
 +    store.register_late_pass(|| Box::new(non_octal_unix_permissions::NonOctalUnixPermissions));
 +    store.register_early_pass(|| Box::new(unnecessary_self_imports::UnnecessarySelfImports));
 +
 +    let msrv = conf.msrv.as_ref().and_then(|s| {
 +        parse_msrv(s, None, None).or_else(|| {
 +            sess.err(&format!(
 +                "error reading Clippy's configuration file. `{}` is not a valid Rust version",
 +                s
 +            ));
 +            None
 +        })
 +    });
 +
 +    let avoid_breaking_exported_api = conf.avoid_breaking_exported_api;
 +    store.register_late_pass(move || Box::new(approx_const::ApproxConstant::new(msrv)));
 +    store.register_late_pass(move || Box::new(methods::Methods::new(avoid_breaking_exported_api, msrv)));
 +    store.register_late_pass(move || Box::new(matches::Matches::new(msrv)));
 +    store.register_early_pass(move || Box::new(manual_non_exhaustive::ManualNonExhaustive::new(msrv)));
 +    store.register_late_pass(move || Box::new(manual_strip::ManualStrip::new(msrv)));
 +    store.register_early_pass(move || Box::new(redundant_static_lifetimes::RedundantStaticLifetimes::new(msrv)));
 +    store.register_early_pass(move || Box::new(redundant_field_names::RedundantFieldNames::new(msrv)));
 +    store.register_late_pass(move || Box::new(checked_conversions::CheckedConversions::new(msrv)));
 +    store.register_late_pass(move || Box::new(mem_replace::MemReplace::new(msrv)));
 +    store.register_late_pass(move || Box::new(ranges::Ranges::new(msrv)));
 +    store.register_late_pass(move || Box::new(from_over_into::FromOverInto::new(msrv)));
 +    store.register_late_pass(move || Box::new(use_self::UseSelf::new(msrv)));
 +    store.register_late_pass(move || Box::new(missing_const_for_fn::MissingConstForFn::new(msrv)));
 +    store.register_late_pass(move || Box::new(needless_question_mark::NeedlessQuestionMark));
 +    store.register_late_pass(move || Box::new(casts::Casts::new(msrv)));
 +    store.register_early_pass(move || Box::new(unnested_or_patterns::UnnestedOrPatterns::new(msrv)));
++    store.register_late_pass(move || Box::new(map_clone::MapClone::new(msrv)));
 +
 +    store.register_late_pass(|| Box::new(size_of_in_element_count::SizeOfInElementCount));
 +    store.register_late_pass(|| Box::new(same_name_method::SameNameMethod));
 +    let max_suggested_slice_pattern_length = conf.max_suggested_slice_pattern_length;
 +    store.register_late_pass(move || {
 +        Box::new(index_refutable_slice::IndexRefutableSlice::new(
 +            max_suggested_slice_pattern_length,
 +            msrv,
 +        ))
 +    });
-     store.register_early_pass(|| Box::new(reference::RefInDeref));
 +    store.register_late_pass(|| Box::new(map_err_ignore::MapErrIgnore));
 +    store.register_late_pass(|| Box::new(shadow::Shadow::default()));
 +    store.register_late_pass(|| Box::new(unit_types::UnitTypes));
 +    store.register_late_pass(|| Box::new(loops::Loops));
 +    store.register_late_pass(|| Box::new(main_recursion::MainRecursion::default()));
 +    store.register_late_pass(|| Box::new(lifetimes::Lifetimes));
 +    store.register_late_pass(|| Box::new(entry::HashMapPass));
 +    store.register_late_pass(|| Box::new(minmax::MinMaxPass));
 +    store.register_late_pass(|| Box::new(open_options::OpenOptions));
 +    store.register_late_pass(|| Box::new(zero_div_zero::ZeroDiv));
 +    store.register_late_pass(|| Box::new(mutex_atomic::Mutex));
 +    store.register_late_pass(|| Box::new(needless_update::NeedlessUpdate));
 +    store.register_late_pass(|| Box::new(needless_borrowed_ref::NeedlessBorrowedRef));
 +    store.register_late_pass(|| Box::new(no_effect::NoEffect));
 +    store.register_late_pass(|| Box::new(temporary_assignment::TemporaryAssignment));
 +    store.register_late_pass(|| Box::new(transmute::Transmute));
 +    let cognitive_complexity_threshold = conf.cognitive_complexity_threshold;
 +    store.register_late_pass(move || {
 +        Box::new(cognitive_complexity::CognitiveComplexity::new(
 +            cognitive_complexity_threshold,
 +        ))
 +    });
 +    let too_large_for_stack = conf.too_large_for_stack;
 +    store.register_late_pass(move || Box::new(escape::BoxedLocal { too_large_for_stack }));
 +    store.register_late_pass(move || Box::new(vec::UselessVec { too_large_for_stack }));
 +    store.register_late_pass(|| Box::new(panic_unimplemented::PanicUnimplemented));
 +    store.register_late_pass(|| Box::new(strings::StringLitAsBytes));
 +    store.register_late_pass(|| Box::new(derive::Derive));
 +    store.register_late_pass(|| Box::new(derivable_impls::DerivableImpls));
 +    store.register_late_pass(|| Box::new(get_last_with_len::GetLastWithLen));
 +    store.register_late_pass(|| Box::new(drop_forget_ref::DropForgetRef));
 +    store.register_late_pass(|| Box::new(empty_enum::EmptyEnum));
 +    store.register_late_pass(|| Box::new(absurd_extreme_comparisons::AbsurdExtremeComparisons));
 +    store.register_late_pass(|| Box::new(invalid_upcast_comparisons::InvalidUpcastComparisons));
 +    store.register_late_pass(|| Box::new(regex::Regex));
 +    store.register_late_pass(|| Box::new(copies::CopyAndPaste));
 +    store.register_late_pass(|| Box::new(copy_iterator::CopyIterator));
 +    store.register_late_pass(|| Box::new(format::UselessFormat));
 +    store.register_late_pass(|| Box::new(swap::Swap));
 +    store.register_late_pass(|| Box::new(overflow_check_conditional::OverflowCheckConditional));
 +    store.register_late_pass(|| Box::new(new_without_default::NewWithoutDefault::default()));
 +    let blacklisted_names = conf.blacklisted_names.iter().cloned().collect::<FxHashSet<_>>();
 +    store.register_late_pass(move || Box::new(blacklisted_name::BlacklistedName::new(blacklisted_names.clone())));
 +    let too_many_arguments_threshold = conf.too_many_arguments_threshold;
 +    let too_many_lines_threshold = conf.too_many_lines_threshold;
 +    store.register_late_pass(move || {
 +        Box::new(functions::Functions::new(
 +            too_many_arguments_threshold,
 +            too_many_lines_threshold,
 +        ))
 +    });
 +    let doc_valid_idents = conf.doc_valid_idents.iter().cloned().collect::<FxHashSet<_>>();
 +    store.register_late_pass(move || Box::new(doc::DocMarkdown::new(doc_valid_idents.clone())));
 +    store.register_late_pass(|| Box::new(neg_multiply::NegMultiply));
 +    store.register_late_pass(|| Box::new(mem_forget::MemForget));
 +    store.register_late_pass(|| Box::new(arithmetic::Arithmetic::default()));
 +    store.register_late_pass(|| Box::new(assign_ops::AssignOps));
 +    store.register_late_pass(|| Box::new(let_if_seq::LetIfSeq));
 +    store.register_late_pass(|| Box::new(eval_order_dependence::EvalOrderDependence));
 +    store.register_late_pass(|| Box::new(missing_doc::MissingDoc::new()));
 +    store.register_late_pass(|| Box::new(missing_inline::MissingInline));
 +    store.register_late_pass(move || Box::new(exhaustive_items::ExhaustiveItems));
 +    store.register_late_pass(|| Box::new(match_result_ok::MatchResultOk));
 +    store.register_late_pass(|| Box::new(partialeq_ne_impl::PartialEqNeImpl));
 +    store.register_late_pass(|| Box::new(unused_io_amount::UnusedIoAmount));
 +    let enum_variant_size_threshold = conf.enum_variant_size_threshold;
 +    store.register_late_pass(move || Box::new(large_enum_variant::LargeEnumVariant::new(enum_variant_size_threshold)));
 +    store.register_late_pass(|| Box::new(explicit_write::ExplicitWrite));
 +    store.register_late_pass(|| Box::new(needless_pass_by_value::NeedlessPassByValue));
 +    let pass_by_ref_or_value = pass_by_ref_or_value::PassByRefOrValue::new(
 +        conf.trivial_copy_size_limit,
 +        conf.pass_by_value_size_limit,
 +        conf.avoid_breaking_exported_api,
 +        &sess.target,
 +    );
 +    store.register_late_pass(move || Box::new(pass_by_ref_or_value));
 +    store.register_late_pass(|| Box::new(ref_option_ref::RefOptionRef));
 +    store.register_late_pass(|| Box::new(try_err::TryErr));
 +    store.register_late_pass(|| Box::new(bytecount::ByteCount));
 +    store.register_late_pass(|| Box::new(infinite_iter::InfiniteIter));
 +    store.register_late_pass(|| Box::new(inline_fn_without_body::InlineFnWithoutBody));
 +    store.register_late_pass(|| Box::new(useless_conversion::UselessConversion::default()));
 +    store.register_late_pass(|| Box::new(implicit_hasher::ImplicitHasher));
 +    store.register_late_pass(|| Box::new(fallible_impl_from::FallibleImplFrom));
 +    store.register_late_pass(|| Box::new(double_comparison::DoubleComparisons));
 +    store.register_late_pass(|| Box::new(question_mark::QuestionMark));
 +    store.register_early_pass(|| Box::new(suspicious_operation_groupings::SuspiciousOperationGroupings));
 +    store.register_late_pass(|| Box::new(suspicious_trait_impl::SuspiciousImpl));
 +    store.register_late_pass(|| Box::new(map_unit_fn::MapUnit));
 +    store.register_late_pass(|| Box::new(inherent_impl::MultipleInherentImpl));
 +    store.register_late_pass(|| Box::new(neg_cmp_op_on_partial_ord::NoNegCompOpForPartialOrd));
 +    store.register_late_pass(|| Box::new(unwrap::Unwrap));
 +    store.register_late_pass(|| Box::new(duration_subsec::DurationSubsec));
 +    store.register_late_pass(|| Box::new(indexing_slicing::IndexingSlicing));
 +    store.register_late_pass(|| Box::new(non_copy_const::NonCopyConst));
 +    store.register_late_pass(|| Box::new(ptr_offset_with_cast::PtrOffsetWithCast));
 +    store.register_late_pass(|| Box::new(redundant_clone::RedundantClone));
 +    store.register_late_pass(|| Box::new(slow_vector_initialization::SlowVectorInit));
 +    store.register_late_pass(|| Box::new(unnecessary_sort_by::UnnecessarySortBy));
 +    store.register_late_pass(move || Box::new(unnecessary_wraps::UnnecessaryWraps::new(avoid_breaking_exported_api)));
 +    store.register_late_pass(|| Box::new(assertions_on_constants::AssertionsOnConstants));
 +    store.register_late_pass(|| Box::new(transmuting_null::TransmutingNull));
 +    store.register_late_pass(|| Box::new(path_buf_push_overwrite::PathBufPushOverwrite));
 +    store.register_late_pass(|| Box::new(integer_division::IntegerDivision));
 +    store.register_late_pass(|| Box::new(inherent_to_string::InherentToString));
 +    let max_trait_bounds = conf.max_trait_bounds;
 +    store.register_late_pass(move || Box::new(trait_bounds::TraitBounds::new(max_trait_bounds)));
 +    store.register_late_pass(|| Box::new(comparison_chain::ComparisonChain));
 +    store.register_late_pass(|| Box::new(mut_key::MutableKeyType));
 +    store.register_late_pass(|| Box::new(modulo_arithmetic::ModuloArithmetic));
 +    store.register_early_pass(|| Box::new(reference::DerefAddrOf));
 +    store.register_early_pass(|| Box::new(double_parens::DoubleParens));
 +    store.register_late_pass(|| Box::new(to_string_in_display::ToStringInDisplay::new()));
 +    store.register_early_pass(|| Box::new(unsafe_removed_from_name::UnsafeNameRemoval));
 +    store.register_early_pass(|| Box::new(else_if_without_else::ElseIfWithoutElse));
 +    store.register_early_pass(|| Box::new(int_plus_one::IntPlusOne));
 +    store.register_early_pass(|| Box::new(formatting::Formatting));
 +    store.register_early_pass(|| Box::new(misc_early::MiscEarlyLints));
 +    store.register_early_pass(|| Box::new(redundant_closure_call::RedundantClosureCall));
 +    store.register_late_pass(|| Box::new(redundant_closure_call::RedundantClosureCall));
 +    store.register_early_pass(|| Box::new(unused_unit::UnusedUnit));
 +    store.register_late_pass(|| Box::new(returns::Return));
 +    store.register_early_pass(|| Box::new(collapsible_if::CollapsibleIf));
 +    store.register_early_pass(|| Box::new(items_after_statements::ItemsAfterStatements));
 +    store.register_early_pass(|| Box::new(precedence::Precedence));
 +    store.register_early_pass(|| Box::new(needless_continue::NeedlessContinue));
 +    store.register_early_pass(|| Box::new(redundant_else::RedundantElse));
 +    store.register_late_pass(|| Box::new(create_dir::CreateDir));
 +    store.register_early_pass(|| Box::new(needless_arbitrary_self_type::NeedlessArbitrarySelfType));
 +    let cargo_ignore_publish = conf.cargo_ignore_publish;
 +    store.register_late_pass(move || Box::new(cargo_common_metadata::CargoCommonMetadata::new(cargo_ignore_publish)));
 +    store.register_late_pass(|| Box::new(multiple_crate_versions::MultipleCrateVersions));
 +    store.register_late_pass(|| Box::new(wildcard_dependencies::WildcardDependencies));
 +    let literal_representation_lint_fraction_readability = conf.unreadable_literal_lint_fractions;
 +    store.register_early_pass(move || {
 +        Box::new(literal_representation::LiteralDigitGrouping::new(
 +            literal_representation_lint_fraction_readability,
 +        ))
 +    });
 +    let literal_representation_threshold = conf.literal_representation_threshold;
 +    store.register_early_pass(move || {
 +        Box::new(literal_representation::DecimalLiteralRepresentation::new(
 +            literal_representation_threshold,
 +        ))
 +    });
 +    let enum_variant_name_threshold = conf.enum_variant_name_threshold;
 +    store.register_late_pass(move || {
 +        Box::new(enum_variants::EnumVariantNames::new(
 +            enum_variant_name_threshold,
 +            avoid_breaking_exported_api,
 +        ))
 +    });
 +    store.register_early_pass(|| Box::new(tabs_in_doc_comments::TabsInDocComments));
 +    let upper_case_acronyms_aggressive = conf.upper_case_acronyms_aggressive;
 +    store.register_late_pass(move || {
 +        Box::new(upper_case_acronyms::UpperCaseAcronyms::new(
 +            avoid_breaking_exported_api,
 +            upper_case_acronyms_aggressive,
 +        ))
 +    });
 +    store.register_late_pass(|| Box::new(default::Default::default()));
 +    store.register_late_pass(|| Box::new(unused_self::UnusedSelf));
 +    store.register_late_pass(|| Box::new(mutable_debug_assertion::DebugAssertWithMutCall));
 +    store.register_late_pass(|| Box::new(exit::Exit));
 +    store.register_late_pass(|| Box::new(to_digit_is_some::ToDigitIsSome));
 +    let array_size_threshold = conf.array_size_threshold;
 +    store.register_late_pass(move || Box::new(large_stack_arrays::LargeStackArrays::new(array_size_threshold)));
 +    store.register_late_pass(move || Box::new(large_const_arrays::LargeConstArrays::new(array_size_threshold)));
 +    store.register_late_pass(|| Box::new(floating_point_arithmetic::FloatingPointArithmetic));
 +    store.register_early_pass(|| Box::new(as_conversions::AsConversions));
 +    store.register_late_pass(|| Box::new(let_underscore::LetUnderscore));
 +    store.register_early_pass(|| Box::new(single_component_path_imports::SingleComponentPathImports));
 +    let max_fn_params_bools = conf.max_fn_params_bools;
 +    let max_struct_bools = conf.max_struct_bools;
 +    store.register_early_pass(move || {
 +        Box::new(excessive_bools::ExcessiveBools::new(
 +            max_struct_bools,
 +            max_fn_params_bools,
 +        ))
 +    });
 +    store.register_early_pass(|| Box::new(option_env_unwrap::OptionEnvUnwrap));
 +    let warn_on_all_wildcard_imports = conf.warn_on_all_wildcard_imports;
 +    store.register_late_pass(move || Box::new(wildcard_imports::WildcardImports::new(warn_on_all_wildcard_imports)));
 +    store.register_late_pass(|| Box::new(verbose_file_reads::VerboseFileReads));
 +    store.register_late_pass(|| Box::new(redundant_pub_crate::RedundantPubCrate::default()));
 +    store.register_late_pass(|| Box::new(unnamed_address::UnnamedAddress));
 +    store.register_late_pass(|| Box::new(dereference::Dereferencing::default()));
 +    store.register_late_pass(|| Box::new(option_if_let_else::OptionIfLetElse));
 +    store.register_late_pass(|| Box::new(future_not_send::FutureNotSend));
 +    store.register_late_pass(|| Box::new(if_let_mutex::IfLetMutex));
 +    store.register_late_pass(|| Box::new(if_not_else::IfNotElse));
 +    store.register_late_pass(|| Box::new(equatable_if_let::PatternEquality));
 +    store.register_late_pass(|| Box::new(mut_mutex_lock::MutMutexLock));
 +    store.register_late_pass(|| Box::new(match_on_vec_items::MatchOnVecItems));
 +    store.register_late_pass(|| Box::new(manual_async_fn::ManualAsyncFn));
 +    store.register_late_pass(|| Box::new(vec_resize_to_zero::VecResizeToZero));
 +    store.register_late_pass(|| Box::new(panic_in_result_fn::PanicInResultFn));
 +    let single_char_binding_names_threshold = conf.single_char_binding_names_threshold;
 +    store.register_early_pass(move || {
 +        Box::new(non_expressive_names::NonExpressiveNames {
 +            single_char_binding_names_threshold,
 +        })
 +    });
 +    let macro_matcher = conf.standard_macro_braces.iter().cloned().collect::<FxHashSet<_>>();
 +    store.register_early_pass(move || Box::new(nonstandard_macro_braces::MacroBraces::new(&macro_matcher)));
 +    store.register_late_pass(|| Box::new(macro_use::MacroUseImports::default()));
 +    store.register_late_pass(|| Box::new(pattern_type_mismatch::PatternTypeMismatch));
 +    store.register_late_pass(|| Box::new(stable_sort_primitive::StableSortPrimitive));
 +    store.register_late_pass(|| Box::new(repeat_once::RepeatOnce));
 +    store.register_late_pass(|| Box::new(unwrap_in_result::UnwrapInResult));
 +    store.register_late_pass(|| Box::new(self_assignment::SelfAssignment));
 +    store.register_late_pass(|| Box::new(manual_unwrap_or::ManualUnwrapOr));
 +    store.register_late_pass(|| Box::new(manual_ok_or::ManualOkOr));
 +    store.register_late_pass(|| Box::new(float_equality_without_abs::FloatEqualityWithoutAbs));
 +    store.register_late_pass(|| Box::new(semicolon_if_nothing_returned::SemicolonIfNothingReturned));
 +    store.register_late_pass(|| Box::new(async_yields_async::AsyncYieldsAsync));
 +    let disallowed_methods = conf.disallowed_methods.clone();
 +    store.register_late_pass(move || Box::new(disallowed_methods::DisallowedMethods::new(disallowed_methods.clone())));
 +    store.register_early_pass(|| Box::new(asm_syntax::InlineAsmX86AttSyntax));
 +    store.register_early_pass(|| Box::new(asm_syntax::InlineAsmX86IntelSyntax));
 +    store.register_late_pass(|| Box::new(undropped_manually_drops::UndroppedManuallyDrops));
 +    store.register_late_pass(|| Box::new(strings::StrToString));
 +    store.register_late_pass(|| Box::new(strings::StringToString));
 +    store.register_late_pass(|| Box::new(zero_sized_map_values::ZeroSizedMapValues));
 +    store.register_late_pass(|| Box::new(vec_init_then_push::VecInitThenPush::default()));
 +    store.register_late_pass(|| {
 +        Box::new(case_sensitive_file_extension_comparisons::CaseSensitiveFileExtensionComparisons)
 +    });
 +    store.register_late_pass(|| Box::new(redundant_slicing::RedundantSlicing));
 +    store.register_late_pass(|| Box::new(from_str_radix_10::FromStrRadix10));
 +    store.register_late_pass(|| Box::new(manual_map::ManualMap));
 +    store.register_late_pass(move || Box::new(if_then_some_else_none::IfThenSomeElseNone::new(msrv)));
 +    store.register_late_pass(|| Box::new(bool_assert_comparison::BoolAssertComparison));
 +    store.register_early_pass(move || Box::new(module_style::ModStyle));
 +    store.register_late_pass(|| Box::new(unused_async::UnusedAsync));
 +    let disallowed_types = conf.disallowed_types.clone();
 +    store.register_late_pass(move || Box::new(disallowed_types::DisallowedTypes::new(disallowed_types.clone())));
 +    let import_renames = conf.enforced_import_renames.clone();
 +    store.register_late_pass(move || {
 +        Box::new(missing_enforced_import_rename::ImportRename::new(
 +            import_renames.clone(),
 +        ))
 +    });
 +    let scripts = conf.allowed_scripts.clone();
 +    store.register_early_pass(move || Box::new(disallowed_script_idents::DisallowedScriptIdents::new(&scripts)));
 +    store.register_late_pass(|| Box::new(strlen_on_c_strings::StrlenOnCStrings));
 +    store.register_late_pass(move || Box::new(self_named_constructors::SelfNamedConstructors));
 +    store.register_late_pass(move || Box::new(feature_name::FeatureName));
 +    store.register_late_pass(move || Box::new(iter_not_returning_iterator::IterNotReturningIterator));
 +    store.register_late_pass(move || Box::new(manual_assert::ManualAssert));
 +    let enable_raw_pointer_heuristic_for_send = conf.enable_raw_pointer_heuristic_for_send;
 +    store.register_late_pass(move || {
 +        Box::new(non_send_fields_in_send_ty::NonSendFieldInSendTy::new(
 +            enable_raw_pointer_heuristic_for_send,
 +        ))
 +    });
 +    store.register_late_pass(move || Box::new(undocumented_unsafe_blocks::UndocumentedUnsafeBlocks::default()));
 +    store.register_late_pass(|| Box::new(match_str_case_mismatch::MatchStrCaseMismatch));
 +    store.register_late_pass(move || Box::new(format_args::FormatArgs));
 +    store.register_late_pass(|| Box::new(trailing_empty_array::TrailingEmptyArray));
 +    store.register_early_pass(|| Box::new(octal_escapes::OctalEscapes));
 +    store.register_late_pass(|| Box::new(needless_late_init::NeedlessLateInit));
 +    store.register_late_pass(|| Box::new(return_self_not_must_use::ReturnSelfNotMustUse));
 +    store.register_late_pass(|| Box::new(init_numbered_fields::NumberedFields));
 +    store.register_early_pass(|| Box::new(single_char_lifetime_names::SingleCharLifetimeNames));
 +    store.register_late_pass(move || Box::new(borrow_as_ptr::BorrowAsPtr::new(msrv)));
 +    store.register_late_pass(move || Box::new(manual_bits::ManualBits::new(msrv)));
 +    // add lints here, do not remove this comment, it's used in `new_lint`
 +}
 +
 +#[rustfmt::skip]
 +fn register_removed_non_tool_lints(store: &mut rustc_lint::LintStore) {
 +    store.register_removed(
 +        "should_assert_eq",
 +        "`assert!()` will be more flexible with RFC 2011",
 +    );
 +    store.register_removed(
 +        "extend_from_slice",
 +        "`.extend_from_slice(_)` is a faster way to extend a Vec by a slice",
 +    );
 +    store.register_removed(
 +        "range_step_by_zero",
 +        "`iterator.step_by(0)` panics nowadays",
 +    );
 +    store.register_removed(
 +        "unstable_as_slice",
 +        "`Vec::as_slice` has been stabilized in 1.7",
 +    );
 +    store.register_removed(
 +        "unstable_as_mut_slice",
 +        "`Vec::as_mut_slice` has been stabilized in 1.7",
 +    );
 +    store.register_removed(
 +        "misaligned_transmute",
 +        "this lint has been split into cast_ptr_alignment and transmute_ptr_to_ptr",
 +    );
 +    store.register_removed(
 +        "assign_ops",
 +        "using compound assignment operators (e.g., `+=`) is harmless",
 +    );
 +    store.register_removed(
 +        "if_let_redundant_pattern_matching",
 +        "this lint has been changed to redundant_pattern_matching",
 +    );
 +    store.register_removed(
 +        "unsafe_vector_initialization",
 +        "the replacement suggested by this lint had substantially different behavior",
 +    );
 +    store.register_removed(
 +        "reverse_range_loop",
 +        "this lint is now included in reversed_empty_ranges",
 +    );
 +}
 +
 +/// Register renamed lints.
 +///
 +/// Used in `./src/driver.rs`.
 +pub fn register_renamed(ls: &mut rustc_lint::LintStore) {
 +    // NOTE: when renaming a lint, add a corresponding test to tests/ui/rename.rs
 +    ls.register_renamed("clippy::stutter", "clippy::module_name_repetitions");
 +    ls.register_renamed("clippy::new_without_default_derive", "clippy::new_without_default");
 +    ls.register_renamed("clippy::cyclomatic_complexity", "clippy::cognitive_complexity");
 +    ls.register_renamed("clippy::const_static_lifetime", "clippy::redundant_static_lifetimes");
 +    ls.register_renamed("clippy::option_and_then_some", "clippy::bind_instead_of_map");
 +    ls.register_renamed("clippy::box_vec", "clippy::box_collection");
 +    ls.register_renamed("clippy::block_in_if_condition_expr", "clippy::blocks_in_if_conditions");
 +    ls.register_renamed("clippy::block_in_if_condition_stmt", "clippy::blocks_in_if_conditions");
 +    ls.register_renamed("clippy::option_map_unwrap_or", "clippy::map_unwrap_or");
 +    ls.register_renamed("clippy::option_map_unwrap_or_else", "clippy::map_unwrap_or");
 +    ls.register_renamed("clippy::result_map_unwrap_or_else", "clippy::map_unwrap_or");
 +    ls.register_renamed("clippy::option_unwrap_used", "clippy::unwrap_used");
 +    ls.register_renamed("clippy::result_unwrap_used", "clippy::unwrap_used");
 +    ls.register_renamed("clippy::option_expect_used", "clippy::expect_used");
 +    ls.register_renamed("clippy::result_expect_used", "clippy::expect_used");
 +    ls.register_renamed("clippy::for_loop_over_option", "clippy::for_loops_over_fallibles");
 +    ls.register_renamed("clippy::for_loop_over_result", "clippy::for_loops_over_fallibles");
 +    ls.register_renamed("clippy::identity_conversion", "clippy::useless_conversion");
 +    ls.register_renamed("clippy::zero_width_space", "clippy::invisible_characters");
 +    ls.register_renamed("clippy::single_char_push_str", "clippy::single_char_add_str");
 +    ls.register_renamed("clippy::if_let_some_result", "clippy::match_result_ok");
 +    ls.register_renamed("clippy::disallowed_type", "clippy::disallowed_types");
 +    ls.register_renamed("clippy::disallowed_method", "clippy::disallowed_methods");
++    ls.register_renamed("clippy::ref_in_deref", "clippy::needless_borrow");
 +
 +    // uplifted lints
 +    ls.register_renamed("clippy::invalid_ref", "invalid_value");
 +    ls.register_renamed("clippy::into_iter_on_array", "array_into_iter");
 +    ls.register_renamed("clippy::unused_label", "unused_labels");
 +    ls.register_renamed("clippy::drop_bounds", "drop_bounds");
 +    ls.register_renamed("clippy::temporary_cstring_as_ptr", "temporary_cstring_as_ptr");
 +    ls.register_renamed("clippy::panic_params", "non_fmt_panics");
 +    ls.register_renamed("clippy::unknown_clippy_lints", "unknown_lints");
 +    ls.register_renamed("clippy::invalid_atomic_ordering", "invalid_atomic_ordering");
 +    ls.register_renamed("clippy::mem_discriminant_non_enum", "enum_intrinsics_non_enums");
 +}
 +
 +// only exists to let the dogfood integration test works.
 +// Don't run clippy as an executable directly
 +#[allow(dead_code)]
 +fn main() {
 +    panic!("Please use the cargo-clippy executable");
 +}
index 565057140454d4af4e3de567c216092365b45408,0000000000000000000000000000000000000000..b09c23f31e97049cbf539d9143593d794d65a9c2
mode 100644,000000..100644
--- /dev/null
@@@ -1,505 -1,0 +1,541 @@@
- use rustc_span::symbol::{kw, Symbol};
 +use clippy_utils::diagnostics::span_lint;
 +use clippy_utils::trait_ref_of_method;
 +use rustc_data_structures::fx::{FxHashMap, FxHashSet};
 +use rustc_hir::intravisit::{
 +    walk_fn_decl, walk_generic_param, walk_generics, walk_item, walk_param_bound, walk_poly_trait_ref, walk_ty, Visitor,
 +};
 +use rustc_hir::FnRetTy::Return;
 +use rustc_hir::{
 +    BareFnTy, BodyId, FnDecl, GenericArg, GenericBound, GenericParam, GenericParamKind, Generics, ImplItem,
 +    ImplItemKind, Item, ItemKind, LangItem, Lifetime, LifetimeName, ParamName, PolyTraitRef, TraitBoundModifier,
 +    TraitFn, TraitItem, TraitItemKind, Ty, TyKind, WhereClause, WherePredicate,
 +};
 +use rustc_lint::{LateContext, LateLintPass};
 +use rustc_session::{declare_lint_pass, declare_tool_lint};
 +use rustc_span::source_map::Span;
-             check_fn_inner(cx, sig.decl, Some(id), generics, item.span, true);
++use rustc_span::symbol::{kw, Ident, Symbol};
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for lifetime annotations which can be removed by
 +    /// relying on lifetime elision.
 +    ///
 +    /// ### Why is this bad?
 +    /// The additional lifetimes make the code look more
 +    /// complicated, while there is nothing out of the ordinary going on. Removing
 +    /// them leads to more readable code.
 +    ///
 +    /// ### Known problems
 +    /// - We bail out if the function has a `where` clause where lifetimes
 +    /// are mentioned due to potential false positives.
 +    /// - Lifetime bounds such as `impl Foo + 'a` and `T: 'a` must be elided with the
 +    /// placeholder notation `'_` because the fully elided notation leaves the type bound to `'static`.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// // Bad: unnecessary lifetime annotations
 +    /// fn in_and_out<'a>(x: &'a u8, y: u8) -> &'a u8 {
 +    ///     x
 +    /// }
 +    ///
 +    /// // Good
 +    /// fn elided(x: &u8, y: u8) -> &u8 {
 +    ///     x
 +    /// }
 +    /// ```
 +    #[clippy::version = "pre 1.29.0"]
 +    pub NEEDLESS_LIFETIMES,
 +    complexity,
 +    "using explicit lifetimes for references in function arguments when elision rules \
 +     would allow omitting them"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for lifetimes in generics that are never used
 +    /// anywhere else.
 +    ///
 +    /// ### Why is this bad?
 +    /// The additional lifetimes make the code look more
 +    /// complicated, while there is nothing out of the ordinary going on. Removing
 +    /// them leads to more readable code.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// // Bad: unnecessary lifetimes
 +    /// fn unused_lifetime<'a>(x: u8) {
 +    ///     // ..
 +    /// }
 +    ///
 +    /// // Good
 +    /// fn no_lifetime(x: u8) {
 +    ///     // ...
 +    /// }
 +    /// ```
 +    #[clippy::version = "pre 1.29.0"]
 +    pub EXTRA_UNUSED_LIFETIMES,
 +    complexity,
 +    "unused lifetimes in function definitions"
 +}
 +
 +declare_lint_pass!(Lifetimes => [NEEDLESS_LIFETIMES, EXTRA_UNUSED_LIFETIMES]);
 +
 +impl<'tcx> LateLintPass<'tcx> for Lifetimes {
 +    fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
 +        if let ItemKind::Fn(ref sig, ref generics, id) = item.kind {
-             let body = match *body {
-                 TraitFn::Required(_) => None,
-                 TraitFn::Provided(id) => Some(id),
++            check_fn_inner(cx, sig.decl, Some(id), None, generics, item.span, true);
 +        }
 +    }
 +
 +    fn check_impl_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx ImplItem<'_>) {
 +        if let ImplItemKind::Fn(ref sig, id) = item.kind {
 +            let report_extra_lifetimes = trait_ref_of_method(cx, item.def_id).is_none();
 +            check_fn_inner(
 +                cx,
 +                sig.decl,
 +                Some(id),
++                None,
 +                &item.generics,
 +                item.span,
 +                report_extra_lifetimes,
 +            );
 +        }
 +    }
 +
 +    fn check_trait_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx TraitItem<'_>) {
 +        if let TraitItemKind::Fn(ref sig, ref body) = item.kind {
-             check_fn_inner(cx, sig.decl, body, &item.generics, item.span, true);
++            let (body, trait_sig) = match *body {
++                TraitFn::Required(sig) => (None, Some(sig)),
++                TraitFn::Provided(id) => (Some(id), None),
 +            };
-     if could_use_elision(cx, decl, body, generics.params) {
++            check_fn_inner(cx, sig.decl, body, trait_sig, &item.generics, item.span, true);
 +        }
 +    }
 +}
 +
 +/// The lifetime of a &-reference.
 +#[derive(PartialEq, Eq, Hash, Debug, Clone)]
 +enum RefLt {
 +    Unnamed,
 +    Static,
 +    Named(Symbol),
 +}
 +
 +fn check_fn_inner<'tcx>(
 +    cx: &LateContext<'tcx>,
 +    decl: &'tcx FnDecl<'_>,
 +    body: Option<BodyId>,
++    trait_sig: Option<&[Ident]>,
 +    generics: &'tcx Generics<'_>,
 +    span: Span,
 +    report_extra_lifetimes: bool,
 +) {
 +    if span.from_expansion() || has_where_lifetimes(cx, &generics.where_clause) {
 +        return;
 +    }
 +
 +    let types = generics
 +        .params
 +        .iter()
 +        .filter(|param| matches!(param.kind, GenericParamKind::Type { .. }));
 +    for typ in types {
 +        for bound in typ.bounds {
 +            let mut visitor = RefVisitor::new(cx);
 +            walk_param_bound(&mut visitor, bound);
 +            if visitor.lts.iter().any(|lt| matches!(lt, RefLt::Named(_))) {
 +                return;
 +            }
 +            if let GenericBound::Trait(ref trait_ref, _) = *bound {
 +                let params = &trait_ref
 +                    .trait_ref
 +                    .path
 +                    .segments
 +                    .last()
 +                    .expect("a path must have at least one segment")
 +                    .args;
 +                if let Some(params) = *params {
 +                    let lifetimes = params.args.iter().filter_map(|arg| match arg {
 +                        GenericArg::Lifetime(lt) => Some(lt),
 +                        _ => None,
 +                    });
 +                    for bound in lifetimes {
 +                        if bound.name != LifetimeName::Static && !bound.is_elided() {
 +                            return;
 +                        }
 +                    }
 +                }
 +            }
 +        }
 +    }
-         checker.visit_expr(&cx.tcx.hir().body(body_id).value);
++    if could_use_elision(cx, decl, body, trait_sig, generics.params) {
 +        span_lint(
 +            cx,
 +            NEEDLESS_LIFETIMES,
 +            span.with_hi(decl.output.span().hi()),
 +            "explicit lifetimes given in parameter types where they could be elided \
 +             (or replaced with `'_` if needed by type declaration)",
 +        );
 +    }
 +    if report_extra_lifetimes {
 +        self::report_extra_lifetimes(cx, decl, generics);
 +    }
 +}
 +
++// elision doesn't work for explicit self types, see rust-lang/rust#69064
++fn explicit_self_type<'tcx>(cx: &LateContext<'tcx>, func: &FnDecl<'tcx>, ident: Option<Ident>) -> bool {
++    if_chain! {
++        if let Some(ident) = ident;
++        if ident.name == kw::SelfLower;
++        if !func.implicit_self.has_implicit_self();
++
++        if let Some(self_ty) = func.inputs.first();
++        then {
++            let mut visitor = RefVisitor::new(cx);
++            visitor.visit_ty(self_ty);
++
++            !visitor.all_lts().is_empty()
++        }
++        else {
++            false
++        }
++    }
++}
++
 +fn could_use_elision<'tcx>(
 +    cx: &LateContext<'tcx>,
 +    func: &'tcx FnDecl<'_>,
 +    body: Option<BodyId>,
++    trait_sig: Option<&[Ident]>,
 +    named_generics: &'tcx [GenericParam<'_>],
 +) -> bool {
 +    // There are two scenarios where elision works:
 +    // * no output references, all input references have different LT
 +    // * output references, exactly one input reference with same LT
 +    // All lifetimes must be unnamed, 'static or defined without bounds on the
 +    // level of the current item.
 +
 +    // check named LTs
 +    let allowed_lts = allowed_lts_from(named_generics);
 +
 +    // these will collect all the lifetimes for references in arg/return types
 +    let mut input_visitor = RefVisitor::new(cx);
 +    let mut output_visitor = RefVisitor::new(cx);
 +
 +    // extract lifetimes in input argument types
 +    for arg in func.inputs {
 +        input_visitor.visit_ty(arg);
 +    }
 +    // extract lifetimes in output type
 +    if let Return(ty) = func.output {
 +        output_visitor.visit_ty(ty);
 +    }
 +    for lt in named_generics {
 +        input_visitor.visit_generic_param(lt);
 +    }
 +
 +    if input_visitor.abort() || output_visitor.abort() {
 +        return false;
 +    }
 +
 +    if allowed_lts
 +        .intersection(
 +            &input_visitor
 +                .nested_elision_site_lts
 +                .iter()
 +                .chain(output_visitor.nested_elision_site_lts.iter())
 +                .cloned()
 +                .filter(|v| matches!(v, RefLt::Named(_)))
 +                .collect(),
 +        )
 +        .next()
 +        .is_some()
 +    {
 +        return false;
 +    }
 +
 +    let input_lts = input_visitor.lts;
 +    let output_lts = output_visitor.lts;
 +
++    if let Some(trait_sig) = trait_sig {
++        if explicit_self_type(cx, func, trait_sig.first().copied()) {
++            return false;
++        }
++    }
++
 +    if let Some(body_id) = body {
++        let body = cx.tcx.hir().body(body_id);
++
++        let first_ident = body.params.first().and_then(|param| param.pat.simple_ident());
++        if explicit_self_type(cx, func, first_ident) {
++            return false;
++        }
++
 +        let mut checker = BodyLifetimeChecker {
 +            lifetimes_used_in_body: false,
 +        };
++        checker.visit_expr(&body.value);
 +        if checker.lifetimes_used_in_body {
 +            return false;
 +        }
 +    }
 +
 +    // check for lifetimes from higher scopes
 +    for lt in input_lts.iter().chain(output_lts.iter()) {
 +        if !allowed_lts.contains(lt) {
 +            return false;
 +        }
 +    }
 +
 +    // no input lifetimes? easy case!
 +    if input_lts.is_empty() {
 +        false
 +    } else if output_lts.is_empty() {
 +        // no output lifetimes, check distinctness of input lifetimes
 +
 +        // only unnamed and static, ok
 +        let unnamed_and_static = input_lts.iter().all(|lt| *lt == RefLt::Unnamed || *lt == RefLt::Static);
 +        if unnamed_and_static {
 +            return false;
 +        }
 +        // we have no output reference, so we only need all distinct lifetimes
 +        input_lts.len() == unique_lifetimes(&input_lts)
 +    } else {
 +        // we have output references, so we need one input reference,
 +        // and all output lifetimes must be the same
 +        if unique_lifetimes(&output_lts) > 1 {
 +            return false;
 +        }
 +        if input_lts.len() == 1 {
 +            match (&input_lts[0], &output_lts[0]) {
 +                (&RefLt::Named(n1), &RefLt::Named(n2)) if n1 == n2 => true,
 +                (&RefLt::Named(_), &RefLt::Unnamed) => true,
 +                _ => false, /* already elided, different named lifetimes
 +                             * or something static going on */
 +            }
 +        } else {
 +            false
 +        }
 +    }
 +}
 +
 +fn allowed_lts_from(named_generics: &[GenericParam<'_>]) -> FxHashSet<RefLt> {
 +    let mut allowed_lts = FxHashSet::default();
 +    for par in named_generics.iter() {
 +        if let GenericParamKind::Lifetime { .. } = par.kind {
 +            if par.bounds.is_empty() {
 +                allowed_lts.insert(RefLt::Named(par.name.ident().name));
 +            }
 +        }
 +    }
 +    allowed_lts.insert(RefLt::Unnamed);
 +    allowed_lts.insert(RefLt::Static);
 +    allowed_lts
 +}
 +
 +/// Number of unique lifetimes in the given vector.
 +#[must_use]
 +fn unique_lifetimes(lts: &[RefLt]) -> usize {
 +    lts.iter().collect::<FxHashSet<_>>().len()
 +}
 +
 +const CLOSURE_TRAIT_BOUNDS: [LangItem; 3] = [LangItem::Fn, LangItem::FnMut, LangItem::FnOnce];
 +
 +/// A visitor usable for `rustc_front::visit::walk_ty()`.
 +struct RefVisitor<'a, 'tcx> {
 +    cx: &'a LateContext<'tcx>,
 +    lts: Vec<RefLt>,
 +    nested_elision_site_lts: Vec<RefLt>,
 +    unelided_trait_object_lifetime: bool,
 +}
 +
 +impl<'a, 'tcx> RefVisitor<'a, 'tcx> {
 +    fn new(cx: &'a LateContext<'tcx>) -> Self {
 +        Self {
 +            cx,
 +            lts: Vec::new(),
 +            nested_elision_site_lts: Vec::new(),
 +            unelided_trait_object_lifetime: false,
 +        }
 +    }
 +
 +    fn record(&mut self, lifetime: &Option<Lifetime>) {
 +        if let Some(ref lt) = *lifetime {
 +            if lt.name == LifetimeName::Static {
 +                self.lts.push(RefLt::Static);
 +            } else if let LifetimeName::Param(ParamName::Fresh(_)) = lt.name {
 +                // Fresh lifetimes generated should be ignored.
 +            } else if lt.is_elided() {
 +                self.lts.push(RefLt::Unnamed);
 +            } else {
 +                self.lts.push(RefLt::Named(lt.name.ident().name));
 +            }
 +        } else {
 +            self.lts.push(RefLt::Unnamed);
 +        }
 +    }
 +
 +    fn all_lts(&self) -> Vec<RefLt> {
 +        self.lts
 +            .iter()
 +            .chain(self.nested_elision_site_lts.iter())
 +            .cloned()
 +            .collect::<Vec<_>>()
 +    }
 +
 +    fn abort(&self) -> bool {
 +        self.unelided_trait_object_lifetime
 +    }
 +}
 +
 +impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {
 +    // for lifetimes as parameters of generics
 +    fn visit_lifetime(&mut self, lifetime: &'tcx Lifetime) {
 +        self.record(&Some(*lifetime));
 +    }
 +
 +    fn visit_poly_trait_ref(&mut self, poly_tref: &'tcx PolyTraitRef<'tcx>, tbm: TraitBoundModifier) {
 +        let trait_ref = &poly_tref.trait_ref;
 +        if CLOSURE_TRAIT_BOUNDS.iter().any(|&item| {
 +            self.cx
 +                .tcx
 +                .lang_items()
 +                .require(item)
 +                .map_or(false, |id| Some(id) == trait_ref.trait_def_id())
 +        }) {
 +            let mut sub_visitor = RefVisitor::new(self.cx);
 +            sub_visitor.visit_trait_ref(trait_ref);
 +            self.nested_elision_site_lts.append(&mut sub_visitor.all_lts());
 +        } else {
 +            walk_poly_trait_ref(self, poly_tref, tbm);
 +        }
 +    }
 +
 +    fn visit_ty(&mut self, ty: &'tcx Ty<'_>) {
 +        match ty.kind {
 +            TyKind::OpaqueDef(item, bounds) => {
 +                let map = self.cx.tcx.hir();
 +                let item = map.item(item);
 +                walk_item(self, item);
 +                walk_ty(self, ty);
 +                self.lts.extend(bounds.iter().filter_map(|bound| match bound {
 +                    GenericArg::Lifetime(l) => Some(RefLt::Named(l.name.ident().name)),
 +                    _ => None,
 +                }));
 +            },
 +            TyKind::BareFn(&BareFnTy { decl, .. }) => {
 +                let mut sub_visitor = RefVisitor::new(self.cx);
 +                sub_visitor.visit_fn_decl(decl);
 +                self.nested_elision_site_lts.append(&mut sub_visitor.all_lts());
 +                return;
 +            },
 +            TyKind::TraitObject(bounds, ref lt, _) => {
 +                if !lt.is_elided() {
 +                    self.unelided_trait_object_lifetime = true;
 +                }
 +                for bound in bounds {
 +                    self.visit_poly_trait_ref(bound, TraitBoundModifier::None);
 +                }
 +                return;
 +            },
 +            _ => (),
 +        }
 +        walk_ty(self, ty);
 +    }
 +}
 +
 +/// Are any lifetimes mentioned in the `where` clause? If so, we don't try to
 +/// reason about elision.
 +fn has_where_lifetimes<'tcx>(cx: &LateContext<'tcx>, where_clause: &'tcx WhereClause<'_>) -> bool {
 +    for predicate in where_clause.predicates {
 +        match *predicate {
 +            WherePredicate::RegionPredicate(..) => return true,
 +            WherePredicate::BoundPredicate(ref pred) => {
 +                // a predicate like F: Trait or F: for<'a> Trait<'a>
 +                let mut visitor = RefVisitor::new(cx);
 +                // walk the type F, it may not contain LT refs
 +                walk_ty(&mut visitor, pred.bounded_ty);
 +                if !visitor.all_lts().is_empty() {
 +                    return true;
 +                }
 +                // if the bounds define new lifetimes, they are fine to occur
 +                let allowed_lts = allowed_lts_from(pred.bound_generic_params);
 +                // now walk the bounds
 +                for bound in pred.bounds.iter() {
 +                    walk_param_bound(&mut visitor, bound);
 +                }
 +                // and check that all lifetimes are allowed
 +                if visitor.all_lts().iter().any(|it| !allowed_lts.contains(it)) {
 +                    return true;
 +                }
 +            },
 +            WherePredicate::EqPredicate(ref pred) => {
 +                let mut visitor = RefVisitor::new(cx);
 +                walk_ty(&mut visitor, pred.lhs_ty);
 +                walk_ty(&mut visitor, pred.rhs_ty);
 +                if !visitor.lts.is_empty() {
 +                    return true;
 +                }
 +            },
 +        }
 +    }
 +    false
 +}
 +
 +struct LifetimeChecker {
 +    map: FxHashMap<Symbol, Span>,
 +}
 +
 +impl<'tcx> Visitor<'tcx> for LifetimeChecker {
 +    // for lifetimes as parameters of generics
 +    fn visit_lifetime(&mut self, lifetime: &'tcx Lifetime) {
 +        self.map.remove(&lifetime.name.ident().name);
 +    }
 +
 +    fn visit_generic_param(&mut self, param: &'tcx GenericParam<'_>) {
 +        // don't actually visit `<'a>` or `<'a: 'b>`
 +        // we've already visited the `'a` declarations and
 +        // don't want to spuriously remove them
 +        // `'b` in `'a: 'b` is useless unless used elsewhere in
 +        // a non-lifetime bound
 +        if let GenericParamKind::Type { .. } = param.kind {
 +            walk_generic_param(self, param);
 +        }
 +    }
 +}
 +
 +fn report_extra_lifetimes<'tcx>(cx: &LateContext<'tcx>, func: &'tcx FnDecl<'_>, generics: &'tcx Generics<'_>) {
 +    let hs = generics
 +        .params
 +        .iter()
 +        .filter_map(|par| match par.kind {
 +            GenericParamKind::Lifetime { .. } => Some((par.name.ident().name, par.span)),
 +            _ => None,
 +        })
 +        .collect();
 +    let mut checker = LifetimeChecker { map: hs };
 +
 +    walk_generics(&mut checker, generics);
 +    walk_fn_decl(&mut checker, func);
 +
 +    for &v in checker.map.values() {
 +        span_lint(
 +            cx,
 +            EXTRA_UNUSED_LIFETIMES,
 +            v,
 +            "this lifetime isn't used in the function definition",
 +        );
 +    }
 +}
 +
 +struct BodyLifetimeChecker {
 +    lifetimes_used_in_body: bool,
 +}
 +
 +impl<'tcx> Visitor<'tcx> for BodyLifetimeChecker {
 +    // for lifetimes as parameters of generics
 +    fn visit_lifetime(&mut self, lifetime: &'tcx Lifetime) {
 +        if lifetime.name.ident().name != kw::Empty && lifetime.name.ident().name != kw::StaticLifetime {
 +            self.lifetimes_used_in_body = true;
 +        }
 +    }
 +}
index 2af3555e370a4b8ec15f0c4204e24276abe324c1,0000000000000000000000000000000000000000..babc6fab3c0fb03d5c617c001001bdb80df97fe2
mode 100644,000000..100644
--- /dev/null
@@@ -1,202 -1,0 +1,202 @@@
-     Term, AsyncGeneratorKind, Block, Body, Expr, ExprKind, FnDecl, FnRetTy, GeneratorKind, GenericArg, GenericBound, HirId,
-     IsAsync, ItemKind, LifetimeName, TraitRef, Ty, TyKind, TypeBindingKind,
 +use clippy_utils::diagnostics::span_lint_and_then;
 +use clippy_utils::match_function_call;
 +use clippy_utils::paths::FUTURE_FROM_GENERATOR;
 +use clippy_utils::source::{position_before_rarrow, snippet_block, snippet_opt};
 +use if_chain::if_chain;
 +use rustc_errors::Applicability;
 +use rustc_hir::intravisit::FnKind;
 +use rustc_hir::{
++    AsyncGeneratorKind, Block, Body, Expr, ExprKind, FnDecl, FnRetTy, GeneratorKind, GenericArg, GenericBound, HirId,
++    IsAsync, ItemKind, LifetimeName, Term, TraitRef, Ty, TyKind, TypeBindingKind,
 +};
 +use rustc_lint::{LateContext, LateLintPass};
 +use rustc_session::{declare_lint_pass, declare_tool_lint};
 +use rustc_span::{sym, Span};
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// It checks for manual implementations of `async` functions.
 +    ///
 +    /// ### Why is this bad?
 +    /// It's more idiomatic to use the dedicated syntax.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// use std::future::Future;
 +    ///
 +    /// fn foo() -> impl Future<Output = i32> { async { 42 } }
 +    /// ```
 +    /// Use instead:
 +    /// ```rust
 +    /// async fn foo() -> i32 { 42 }
 +    /// ```
 +    #[clippy::version = "1.45.0"]
 +    pub MANUAL_ASYNC_FN,
 +    style,
 +    "manual implementations of `async` functions can be simplified using the dedicated syntax"
 +}
 +
 +declare_lint_pass!(ManualAsyncFn => [MANUAL_ASYNC_FN]);
 +
 +impl<'tcx> LateLintPass<'tcx> for ManualAsyncFn {
 +    fn check_fn(
 +        &mut self,
 +        cx: &LateContext<'tcx>,
 +        kind: FnKind<'tcx>,
 +        decl: &'tcx FnDecl<'_>,
 +        body: &'tcx Body<'_>,
 +        span: Span,
 +        _: HirId,
 +    ) {
 +        if_chain! {
 +            if let Some(header) = kind.header();
 +            if header.asyncness == IsAsync::NotAsync;
 +            // Check that this function returns `impl Future`
 +            if let FnRetTy::Return(ret_ty) = decl.output;
 +            if let Some((trait_ref, output_lifetimes)) = future_trait_ref(cx, ret_ty);
 +            if let Some(output) = future_output_ty(trait_ref);
 +            if captures_all_lifetimes(decl.inputs, &output_lifetimes);
 +            // Check that the body of the function consists of one async block
 +            if let ExprKind::Block(block, _) = body.value.kind;
 +            if block.stmts.is_empty();
 +            if let Some(closure_body) = desugared_async_block(cx, block);
 +            then {
 +                let header_span = span.with_hi(ret_ty.span.hi());
 +
 +                span_lint_and_then(
 +                    cx,
 +                    MANUAL_ASYNC_FN,
 +                    header_span,
 +                    "this function can be simplified using the `async fn` syntax",
 +                    |diag| {
 +                        if_chain! {
 +                            if let Some(header_snip) = snippet_opt(cx, header_span);
 +                            if let Some(ret_pos) = position_before_rarrow(&header_snip);
 +                            if let Some((ret_sugg, ret_snip)) = suggested_ret(cx, output);
 +                            then {
 +                                let help = format!("make the function `async` and {}", ret_sugg);
 +                                diag.span_suggestion(
 +                                    header_span,
 +                                    &help,
 +                                    format!("async {}{}", &header_snip[..ret_pos], ret_snip),
 +                                    Applicability::MachineApplicable
 +                                );
 +
 +                                let body_snip = snippet_block(cx, closure_body.value.span, "..", Some(block.span));
 +                                diag.span_suggestion(
 +                                    block.span,
 +                                    "move the body of the async block to the enclosing function",
 +                                    body_snip.to_string(),
 +                                    Applicability::MachineApplicable
 +                                );
 +                            }
 +                        }
 +                    },
 +                );
 +            }
 +        }
 +    }
 +}
 +
 +fn future_trait_ref<'tcx>(
 +    cx: &LateContext<'tcx>,
 +    ty: &'tcx Ty<'tcx>,
 +) -> Option<(&'tcx TraitRef<'tcx>, Vec<LifetimeName>)> {
 +    if_chain! {
 +        if let TyKind::OpaqueDef(item_id, bounds) = ty.kind;
 +        let item = cx.tcx.hir().item(item_id);
 +        if let ItemKind::OpaqueTy(opaque) = &item.kind;
 +        if let Some(trait_ref) = opaque.bounds.iter().find_map(|bound| {
 +            if let GenericBound::Trait(poly, _) = bound {
 +                Some(&poly.trait_ref)
 +            } else {
 +                None
 +            }
 +        });
 +        if trait_ref.trait_def_id() == cx.tcx.lang_items().future_trait();
 +        then {
 +            let output_lifetimes = bounds
 +                .iter()
 +                .filter_map(|bound| {
 +                    if let GenericArg::Lifetime(lt) = bound {
 +                        Some(lt.name)
 +                    } else {
 +                        None
 +                    }
 +                })
 +                .collect();
 +
 +            return Some((trait_ref, output_lifetimes));
 +        }
 +    }
 +
 +    None
 +}
 +
 +fn future_output_ty<'tcx>(trait_ref: &'tcx TraitRef<'tcx>) -> Option<&'tcx Ty<'tcx>> {
 +    if_chain! {
 +        if let Some(segment) = trait_ref.path.segments.last();
 +        if let Some(args) = segment.args;
 +        if args.bindings.len() == 1;
 +        let binding = &args.bindings[0];
 +        if binding.ident.name == sym::Output;
 +        if let TypeBindingKind::Equality{term: Term::Ty(output)} = binding.kind;
 +        then {
 +            return Some(output)
 +        }
 +    }
 +
 +    None
 +}
 +
 +fn captures_all_lifetimes(inputs: &[Ty<'_>], output_lifetimes: &[LifetimeName]) -> bool {
 +    let input_lifetimes: Vec<LifetimeName> = inputs
 +        .iter()
 +        .filter_map(|ty| {
 +            if let TyKind::Rptr(lt, _) = ty.kind {
 +                Some(lt.name)
 +            } else {
 +                None
 +            }
 +        })
 +        .collect();
 +
 +    // The lint should trigger in one of these cases:
 +    // - There are no input lifetimes
 +    // - There's only one output lifetime bound using `+ '_`
 +    // - All input lifetimes are explicitly bound to the output
 +    input_lifetimes.is_empty()
 +        || (output_lifetimes.len() == 1 && matches!(output_lifetimes[0], LifetimeName::Underscore))
 +        || input_lifetimes
 +            .iter()
 +            .all(|in_lt| output_lifetimes.iter().any(|out_lt| in_lt == out_lt))
 +}
 +
 +fn desugared_async_block<'tcx>(cx: &LateContext<'tcx>, block: &'tcx Block<'tcx>) -> Option<&'tcx Body<'tcx>> {
 +    if_chain! {
 +        if let Some(block_expr) = block.expr;
 +        if let Some(args) = match_function_call(cx, block_expr, &FUTURE_FROM_GENERATOR);
 +        if args.len() == 1;
 +        if let Expr{kind: ExprKind::Closure(_, _, body_id, ..), ..} = args[0];
 +        let closure_body = cx.tcx.hir().body(body_id);
 +        if closure_body.generator_kind == Some(GeneratorKind::Async(AsyncGeneratorKind::Block));
 +        then {
 +            return Some(closure_body);
 +        }
 +    }
 +
 +    None
 +}
 +
 +fn suggested_ret(cx: &LateContext<'_>, output: &Ty<'_>) -> Option<(&'static str, String)> {
 +    match output.kind {
 +        TyKind::Tup(tys) if tys.is_empty() => {
 +            let sugg = "remove the return type";
 +            Some((sugg, "".into()))
 +        },
 +        _ => {
 +            let sugg = "return the output of the future directly";
 +            snippet_opt(cx, output.span).map(|snip| (sugg, format!(" -> {}", snip)))
 +        },
 +    }
 +}
index 50bf2527e39a8f4c26cdaac9774949c0542975d7,0000000000000000000000000000000000000000..809aa168a7a0ee2f8152dc3f0b7884a9f20dba5e
mode 100644,000000..100644
--- /dev/null
@@@ -1,107 -1,0 +1,109 @@@
 +use clippy_utils::diagnostics::span_lint_and_sugg;
 +use clippy_utils::source::snippet_opt;
 +use clippy_utils::{match_def_path, meets_msrv, msrvs, paths};
 +use rustc_ast::ast::LitKind;
 +use rustc_errors::Applicability;
 +use rustc_hir::{BinOpKind, Expr, ExprKind, GenericArg, QPath};
 +use rustc_lint::{LateContext, LateLintPass};
 +use rustc_middle::ty::{self, Ty};
 +use rustc_semver::RustcVersion;
 +use rustc_session::{declare_tool_lint, impl_lint_pass};
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for uses of `std::mem::size_of::<T>() * 8` when
 +    /// `T::BITS` is available.
 +    ///
 +    /// ### Why is this bad?
 +    /// Can be written as the shorter `T::BITS`.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// std::mem::size_of::<usize>() * 8;
 +    /// ```
 +    /// Use instead:
 +    /// ```rust
 +    /// usize::BITS;
 +    /// ```
 +    #[clippy::version = "1.60.0"]
 +    pub MANUAL_BITS,
 +    style,
 +    "manual implementation of `size_of::<T>() * 8` can be simplified with `T::BITS`"
 +}
 +
 +#[derive(Clone)]
 +pub struct ManualBits {
 +    msrv: Option<RustcVersion>,
 +}
 +
 +impl ManualBits {
 +    #[must_use]
 +    pub fn new(msrv: Option<RustcVersion>) -> Self {
 +        Self { msrv }
 +    }
 +}
 +
 +impl_lint_pass!(ManualBits => [MANUAL_BITS]);
 +
 +impl<'tcx> LateLintPass<'tcx> for ManualBits {
 +    fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
 +        if !meets_msrv(self.msrv.as_ref(), &msrvs::MANUAL_BITS) {
 +            return;
 +        }
 +
 +        if_chain! {
 +            if let ExprKind::Binary(bin_op, left_expr, right_expr) = expr.kind;
 +            if let BinOpKind::Mul = &bin_op.node;
 +            if let Some((real_ty, resolved_ty, other_expr)) = get_one_size_of_ty(cx, left_expr, right_expr);
 +            if matches!(resolved_ty.kind(), ty::Int(_) | ty::Uint(_));
 +            if let ExprKind::Lit(lit) = &other_expr.kind;
 +            if let LitKind::Int(8, _) = lit.node;
 +
 +            then {
 +                span_lint_and_sugg(
 +                    cx,
 +                    MANUAL_BITS,
 +                    expr.span,
 +                    "usage of `mem::size_of::<T>()` to obtain the size of `T` in bits",
 +                    "consider using",
 +                    format!("{}::BITS", snippet_opt(cx, real_ty.span).unwrap()),
 +                    Applicability::MachineApplicable,
 +                );
 +            }
 +        }
 +    }
++
++    extract_msrv_attr!(LateContext);
 +}
 +
 +fn get_one_size_of_ty<'tcx>(
 +    cx: &LateContext<'tcx>,
 +    expr1: &'tcx Expr<'_>,
 +    expr2: &'tcx Expr<'_>,
 +) -> Option<(&'tcx rustc_hir::Ty<'tcx>, Ty<'tcx>, &'tcx Expr<'tcx>)> {
 +    match (get_size_of_ty(cx, expr1), get_size_of_ty(cx, expr2)) {
 +        (Some((real_ty, resolved_ty)), None) => Some((real_ty, resolved_ty, expr2)),
 +        (None, Some((real_ty, resolved_ty))) => Some((real_ty, resolved_ty, expr1)),
 +        _ => None,
 +    }
 +}
 +
 +fn get_size_of_ty<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) -> Option<(&'tcx rustc_hir::Ty<'tcx>, Ty<'tcx>)> {
 +    if_chain! {
 +        if let ExprKind::Call(count_func, _func_args) = expr.kind;
 +        if let ExprKind::Path(ref count_func_qpath) = count_func.kind;
 +
 +        if let QPath::Resolved(_, count_func_path) = count_func_qpath;
 +        if let Some(segment_zero) = count_func_path.segments.get(0);
 +        if let Some(args) = segment_zero.args;
 +        if let Some(GenericArg::Type(real_ty)) = args.args.get(0);
 +
 +        if let Some(def_id) = cx.qpath_res(count_func_qpath, count_func.hir_id).opt_def_id();
 +        if match_def_path(cx, def_id, &paths::MEM_SIZE_OF);
 +        then {
 +            cx.typeck_results().node_substs(count_func.hir_id).types().next().map(|resolved_ty| (real_ty, resolved_ty))
 +        } else {
 +            None
 +        }
 +    }
 +}
index 22a2552b283a5940c4c54c6e4dff90c1468fb293,0000000000000000000000000000000000000000..3f8eeb736fbd2e5c155054c7176c04dc0abe8bc4
mode 100644,000000..100644
--- /dev/null
@@@ -1,159 -1,0 +1,171 @@@
- use clippy_utils::{is_trait_method, peel_blocks};
 +use clippy_utils::diagnostics::span_lint_and_sugg;
 +use clippy_utils::source::snippet_with_applicability;
 +use clippy_utils::ty::{is_copy, is_type_diagnostic_item};
- use rustc_session::{declare_lint_pass, declare_tool_lint};
++use clippy_utils::{is_trait_method, meets_msrv, msrvs, peel_blocks};
 +use if_chain::if_chain;
 +use rustc_errors::Applicability;
 +use rustc_hir as hir;
 +use rustc_lint::{LateContext, LateLintPass};
 +use rustc_middle::mir::Mutability;
 +use rustc_middle::ty;
 +use rustc_middle::ty::adjustment::Adjust;
- declare_lint_pass!(MapClone => [MAP_CLONE]);
++use rustc_semver::RustcVersion;
++use rustc_session::{declare_tool_lint, impl_lint_pass};
 +use rustc_span::symbol::Ident;
 +use rustc_span::{sym, Span};
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for usage of `map(|x| x.clone())` or
 +    /// dereferencing closures for `Copy` types, on `Iterator` or `Option`,
 +    /// and suggests `cloned()` or `copied()` instead
 +    ///
 +    /// ### Why is this bad?
 +    /// Readability, this can be written more concisely
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// let x = vec![42, 43];
 +    /// let y = x.iter();
 +    /// let z = y.map(|i| *i);
 +    /// ```
 +    ///
 +    /// The correct use would be:
 +    ///
 +    /// ```rust
 +    /// let x = vec![42, 43];
 +    /// let y = x.iter();
 +    /// let z = y.cloned();
 +    /// ```
 +    #[clippy::version = "pre 1.29.0"]
 +    pub MAP_CLONE,
 +    style,
 +    "using `iterator.map(|x| x.clone())`, or dereferencing closures for `Copy` types"
 +}
 +
-                             lint(cx, e.span, args[0].span, true);
++pub struct MapClone {
++    msrv: Option<RustcVersion>,
++}
++
++impl_lint_pass!(MapClone => [MAP_CLONE]);
++
++impl MapClone {
++    pub fn new(msrv: Option<RustcVersion>) -> Self {
++        Self { msrv }
++    }
++}
 +
 +impl<'tcx> LateLintPass<'tcx> for MapClone {
 +    fn check_expr(&mut self, cx: &LateContext<'_>, e: &hir::Expr<'_>) {
 +        if e.span.from_expansion() {
 +            return;
 +        }
 +
 +        if_chain! {
 +            if let hir::ExprKind::MethodCall(method, args, _) = e.kind;
 +            if args.len() == 2;
 +            if method.ident.name == sym::map;
 +            let ty = cx.typeck_results().expr_ty(&args[0]);
 +            if is_type_diagnostic_item(cx, ty, sym::Option) || is_trait_method(cx, e, sym::Iterator);
 +            if let hir::ExprKind::Closure(_, _, body_id, _, _) = args[1].kind;
 +            then {
 +                let closure_body = cx.tcx.hir().body(body_id);
 +                let closure_expr = peel_blocks(&closure_body.value);
 +                match closure_body.params[0].pat.kind {
 +                    hir::PatKind::Ref(inner, hir::Mutability::Not) => if let hir::PatKind::Binding(
 +                        hir::BindingAnnotation::Unannotated, .., name, None
 +                    ) = inner.kind {
 +                        if ident_eq(name, closure_expr) {
-                                         lint(cx, e.span, args[0].span, true);
++                            self.lint_explicit_closure(cx, e.span, args[0].span, true);
 +                        }
 +                    },
 +                    hir::PatKind::Binding(hir::BindingAnnotation::Unannotated, .., name, None) => {
 +                        match closure_expr.kind {
 +                            hir::ExprKind::Unary(hir::UnOp::Deref, inner) => {
 +                                if ident_eq(name, inner) {
 +                                    if let ty::Ref(.., Mutability::Not) = cx.typeck_results().expr_ty(inner).kind() {
-                                             lint(cx, e.span, args[0].span, copy);
++                                        self.lint_explicit_closure(cx, e.span, args[0].span, true);
 +                                    }
 +                                }
 +                            },
 +                            hir::ExprKind::MethodCall(method, [obj], _) => if_chain! {
 +                                if ident_eq(name, obj) && method.ident.name == sym::clone;
 +                                if let Some(fn_id) = cx.typeck_results().type_dependent_def_id(closure_expr.hir_id);
 +                                if let Some(trait_id) = cx.tcx.trait_of_item(fn_id);
 +                                if cx.tcx.lang_items().clone_trait().map_or(false, |id| id == trait_id);
 +                                // no autoderefs
 +                                if !cx.typeck_results().expr_adjustments(obj).iter()
 +                                    .any(|a| matches!(a.kind, Adjust::Deref(Some(..))));
 +                                then {
 +                                    let obj_ty = cx.typeck_results().expr_ty(obj);
 +                                    if let ty::Ref(_, ty, mutability) = obj_ty.kind() {
 +                                        if matches!(mutability, Mutability::Not) {
 +                                            let copy = is_copy(cx, ty);
- fn lint(cx: &LateContext<'_>, replace: Span, root: Span, copied: bool) {
-     let mut applicability = Applicability::MachineApplicable;
-     if copied {
-         span_lint_and_sugg(
-             cx,
-             MAP_CLONE,
-             replace,
-             "you are using an explicit closure for copying elements",
-             "consider calling the dedicated `copied` method",
-             format!(
-                 "{}.copied()",
-                 snippet_with_applicability(cx, root, "..", &mut applicability)
-             ),
-             applicability,
-         );
-     } else {
++                                            self.lint_explicit_closure(cx, e.span, args[0].span, copy);
 +                                        }
 +                                    } else {
 +                                        lint_needless_cloning(cx, e.span, args[0].span);
 +                                    }
 +                                }
 +                            },
 +                            _ => {},
 +                        }
 +                    },
 +                    _ => {},
 +                }
 +            }
 +        }
 +    }
++
++    extract_msrv_attr!(LateContext);
 +}
 +
 +fn ident_eq(name: Ident, path: &hir::Expr<'_>) -> bool {
 +    if let hir::ExprKind::Path(hir::QPath::Resolved(None, path)) = path.kind {
 +        path.segments.len() == 1 && path.segments[0].ident == name
 +    } else {
 +        false
 +    }
 +}
 +
 +fn lint_needless_cloning(cx: &LateContext<'_>, root: Span, receiver: Span) {
 +    span_lint_and_sugg(
 +        cx,
 +        MAP_CLONE,
 +        root.trim_start(receiver).unwrap(),
 +        "you are needlessly cloning iterator elements",
 +        "remove the `map` call",
 +        String::new(),
 +        Applicability::MachineApplicable,
 +    );
 +}
 +
-             "you are using an explicit closure for cloning elements",
-             "consider calling the dedicated `cloned` method",
++impl MapClone {
++    fn lint_explicit_closure(&self, cx: &LateContext<'_>, replace: Span, root: Span, is_copy: bool) {
++        let mut applicability = Applicability::MachineApplicable;
++        let message = if is_copy {
++            "you are using an explicit closure for copying elements"
++        } else {
++            "you are using an explicit closure for cloning elements"
++        };
++        let sugg_method = if is_copy && meets_msrv(self.msrv.as_ref(), &msrvs::ITERATOR_COPIED) {
++            "copied"
++        } else {
++            "cloned"
++        };
++
 +        span_lint_and_sugg(
 +            cx,
 +            MAP_CLONE,
 +            replace,
-                 "{}.cloned()",
-                 snippet_with_applicability(cx, root, "..", &mut applicability)
++            message,
++            &format!("consider calling the dedicated `{}` method", sugg_method),
 +            format!(
++                "{}.{}()",
++                snippet_with_applicability(cx, root, "..", &mut applicability),
++                sugg_method,
 +            ),
 +            applicability,
 +        );
 +    }
 +}
index dfb450c8848adcd4aa4b7fca2663e15a5c088810,0000000000000000000000000000000000000000..2579404fb18cc5b152fd8448903475d4e1ba5bbf
mode 100644,000000..100644
--- /dev/null
@@@ -1,2342 -1,0 +1,2342 @@@
- use rustc_span::sym;
 +use clippy_utils::consts::{constant, constant_full_int, miri_to_const, FullInt};
 +use clippy_utils::diagnostics::{
 +    multispan_sugg, span_lint_and_help, span_lint_and_note, span_lint_and_sugg, span_lint_and_then,
 +};
 +use clippy_utils::macros::{is_panic, root_macro_call};
 +use clippy_utils::source::{expr_block, indent_of, snippet, snippet_block, snippet_opt, snippet_with_applicability};
 +use clippy_utils::sugg::Sugg;
 +use clippy_utils::ty::{implements_trait, is_type_diagnostic_item, match_type, peel_mid_ty_refs};
 +use clippy_utils::visitors::is_local_used;
 +use clippy_utils::{
 +    get_parent_expr, is_lang_ctor, is_lint_allowed, is_refutable, is_unit_expr, is_wild, meets_msrv, msrvs,
 +    path_to_local, path_to_local_id, peel_blocks, peel_hir_pat_refs, peel_n_hir_expr_refs, recurse_or_patterns,
 +    strip_pat_refs,
 +};
 +use clippy_utils::{higher, peel_blocks_with_stmt};
 +use clippy_utils::{paths, search_same, SpanlessEq, SpanlessHash};
 +use core::iter::{once, ExactSizeIterator};
 +use if_chain::if_chain;
 +use rustc_ast::ast::{Attribute, LitKind};
 +use rustc_errors::Applicability;
 +use rustc_hir::def::{CtorKind, DefKind, Res};
 +use rustc_hir::LangItem::{OptionNone, OptionSome};
 +use rustc_hir::{
 +    self as hir, Arm, BindingAnnotation, Block, BorrowKind, Expr, ExprKind, Guard, HirId, Local, MatchSource,
 +    Mutability, Node, Pat, PatKind, PathSegment, QPath, RangeEnd, TyKind,
 +};
 +use rustc_hir::{HirIdMap, HirIdSet};
 +use rustc_lint::{LateContext, LateLintPass};
 +use rustc_middle::ty::{self, Ty, TyS, VariantDef};
 +use rustc_semver::RustcVersion;
 +use rustc_session::{declare_tool_lint, impl_lint_pass};
 +use rustc_span::source_map::{Span, Spanned};
-                     let mut ident_bind_name = String::from("_");
++use rustc_span::{sym, symbol::kw};
 +use std::cmp::Ordering;
 +use std::collections::hash_map::Entry;
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for matches with a single arm where an `if let`
 +    /// will usually suffice.
 +    ///
 +    /// ### Why is this bad?
 +    /// Just readability – `if let` nests less than a `match`.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// # fn bar(stool: &str) {}
 +    /// # let x = Some("abc");
 +    /// // Bad
 +    /// match x {
 +    ///     Some(ref foo) => bar(foo),
 +    ///     _ => (),
 +    /// }
 +    ///
 +    /// // Good
 +    /// if let Some(ref foo) = x {
 +    ///     bar(foo);
 +    /// }
 +    /// ```
 +    #[clippy::version = "pre 1.29.0"]
 +    pub SINGLE_MATCH,
 +    style,
 +    "a `match` statement with a single nontrivial arm (i.e., where the other arm is `_ => {}`) instead of `if let`"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for matches with two arms where an `if let else` will
 +    /// usually suffice.
 +    ///
 +    /// ### Why is this bad?
 +    /// Just readability – `if let` nests less than a `match`.
 +    ///
 +    /// ### Known problems
 +    /// Personal style preferences may differ.
 +    ///
 +    /// ### Example
 +    /// Using `match`:
 +    ///
 +    /// ```rust
 +    /// # fn bar(foo: &usize) {}
 +    /// # let other_ref: usize = 1;
 +    /// # let x: Option<&usize> = Some(&1);
 +    /// match x {
 +    ///     Some(ref foo) => bar(foo),
 +    ///     _ => bar(&other_ref),
 +    /// }
 +    /// ```
 +    ///
 +    /// Using `if let` with `else`:
 +    ///
 +    /// ```rust
 +    /// # fn bar(foo: &usize) {}
 +    /// # let other_ref: usize = 1;
 +    /// # let x: Option<&usize> = Some(&1);
 +    /// if let Some(ref foo) = x {
 +    ///     bar(foo);
 +    /// } else {
 +    ///     bar(&other_ref);
 +    /// }
 +    /// ```
 +    #[clippy::version = "pre 1.29.0"]
 +    pub SINGLE_MATCH_ELSE,
 +    pedantic,
 +    "a `match` statement with two arms where the second arm's pattern is a placeholder instead of a specific match pattern"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for matches where all arms match a reference,
 +    /// suggesting to remove the reference and deref the matched expression
 +    /// instead. It also checks for `if let &foo = bar` blocks.
 +    ///
 +    /// ### Why is this bad?
 +    /// It just makes the code less readable. That reference
 +    /// destructuring adds nothing to the code.
 +    ///
 +    /// ### Example
 +    /// ```rust,ignore
 +    /// // Bad
 +    /// match x {
 +    ///     &A(ref y) => foo(y),
 +    ///     &B => bar(),
 +    ///     _ => frob(&x),
 +    /// }
 +    ///
 +    /// // Good
 +    /// match *x {
 +    ///     A(ref y) => foo(y),
 +    ///     B => bar(),
 +    ///     _ => frob(x),
 +    /// }
 +    /// ```
 +    #[clippy::version = "pre 1.29.0"]
 +    pub MATCH_REF_PATS,
 +    style,
 +    "a `match` or `if let` with all arms prefixed with `&` instead of deref-ing the match expression"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for matches where match expression is a `bool`. It
 +    /// suggests to replace the expression with an `if...else` block.
 +    ///
 +    /// ### Why is this bad?
 +    /// It makes the code less readable.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// # fn foo() {}
 +    /// # fn bar() {}
 +    /// let condition: bool = true;
 +    /// match condition {
 +    ///     true => foo(),
 +    ///     false => bar(),
 +    /// }
 +    /// ```
 +    /// Use if/else instead:
 +    /// ```rust
 +    /// # fn foo() {}
 +    /// # fn bar() {}
 +    /// let condition: bool = true;
 +    /// if condition {
 +    ///     foo();
 +    /// } else {
 +    ///     bar();
 +    /// }
 +    /// ```
 +    #[clippy::version = "pre 1.29.0"]
 +    pub MATCH_BOOL,
 +    pedantic,
 +    "a `match` on a boolean expression instead of an `if..else` block"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for overlapping match arms.
 +    ///
 +    /// ### Why is this bad?
 +    /// It is likely to be an error and if not, makes the code
 +    /// less obvious.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// let x = 5;
 +    /// match x {
 +    ///     1..=10 => println!("1 ... 10"),
 +    ///     5..=15 => println!("5 ... 15"),
 +    ///     _ => (),
 +    /// }
 +    /// ```
 +    #[clippy::version = "pre 1.29.0"]
 +    pub MATCH_OVERLAPPING_ARM,
 +    style,
 +    "a `match` with overlapping arms"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for arm which matches all errors with `Err(_)`
 +    /// and take drastic actions like `panic!`.
 +    ///
 +    /// ### Why is this bad?
 +    /// It is generally a bad practice, similar to
 +    /// catching all exceptions in java with `catch(Exception)`
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// let x: Result<i32, &str> = Ok(3);
 +    /// match x {
 +    ///     Ok(_) => println!("ok"),
 +    ///     Err(_) => panic!("err"),
 +    /// }
 +    /// ```
 +    #[clippy::version = "pre 1.29.0"]
 +    pub MATCH_WILD_ERR_ARM,
 +    pedantic,
 +    "a `match` with `Err(_)` arm and take drastic actions"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for match which is used to add a reference to an
 +    /// `Option` value.
 +    ///
 +    /// ### Why is this bad?
 +    /// Using `as_ref()` or `as_mut()` instead is shorter.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// let x: Option<()> = None;
 +    ///
 +    /// // Bad
 +    /// let r: Option<&()> = match x {
 +    ///     None => None,
 +    ///     Some(ref v) => Some(v),
 +    /// };
 +    ///
 +    /// // Good
 +    /// let r: Option<&()> = x.as_ref();
 +    /// ```
 +    #[clippy::version = "pre 1.29.0"]
 +    pub MATCH_AS_REF,
 +    complexity,
 +    "a `match` on an Option value instead of using `as_ref()` or `as_mut`"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for wildcard enum matches using `_`.
 +    ///
 +    /// ### Why is this bad?
 +    /// New enum variants added by library updates can be missed.
 +    ///
 +    /// ### Known problems
 +    /// Suggested replacements may be incorrect if guards exhaustively cover some
 +    /// variants, and also may not use correct path to enum if it's not present in the current scope.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// # enum Foo { A(usize), B(usize) }
 +    /// # let x = Foo::B(1);
 +    /// // Bad
 +    /// match x {
 +    ///     Foo::A(_) => {},
 +    ///     _ => {},
 +    /// }
 +    ///
 +    /// // Good
 +    /// match x {
 +    ///     Foo::A(_) => {},
 +    ///     Foo::B(_) => {},
 +    /// }
 +    /// ```
 +    #[clippy::version = "1.34.0"]
 +    pub WILDCARD_ENUM_MATCH_ARM,
 +    restriction,
 +    "a wildcard enum match arm using `_`"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for wildcard enum matches for a single variant.
 +    ///
 +    /// ### Why is this bad?
 +    /// New enum variants added by library updates can be missed.
 +    ///
 +    /// ### Known problems
 +    /// Suggested replacements may not use correct path to enum
 +    /// if it's not present in the current scope.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// # enum Foo { A, B, C }
 +    /// # let x = Foo::B;
 +    /// // Bad
 +    /// match x {
 +    ///     Foo::A => {},
 +    ///     Foo::B => {},
 +    ///     _ => {},
 +    /// }
 +    ///
 +    /// // Good
 +    /// match x {
 +    ///     Foo::A => {},
 +    ///     Foo::B => {},
 +    ///     Foo::C => {},
 +    /// }
 +    /// ```
 +    #[clippy::version = "1.45.0"]
 +    pub MATCH_WILDCARD_FOR_SINGLE_VARIANTS,
 +    pedantic,
 +    "a wildcard enum match for a single variant"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for wildcard pattern used with others patterns in same match arm.
 +    ///
 +    /// ### Why is this bad?
 +    /// Wildcard pattern already covers any other pattern as it will match anyway.
 +    /// It makes the code less readable, especially to spot wildcard pattern use in match arm.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// // Bad
 +    /// match "foo" {
 +    ///     "a" => {},
 +    ///     "bar" | _ => {},
 +    /// }
 +    ///
 +    /// // Good
 +    /// match "foo" {
 +    ///     "a" => {},
 +    ///     _ => {},
 +    /// }
 +    /// ```
 +    #[clippy::version = "1.42.0"]
 +    pub WILDCARD_IN_OR_PATTERNS,
 +    complexity,
 +    "a wildcard pattern used with others patterns in same match arm"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for matches being used to destructure a single-variant enum
 +    /// or tuple struct where a `let` will suffice.
 +    ///
 +    /// ### Why is this bad?
 +    /// Just readability – `let` doesn't nest, whereas a `match` does.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// enum Wrapper {
 +    ///     Data(i32),
 +    /// }
 +    ///
 +    /// let wrapper = Wrapper::Data(42);
 +    ///
 +    /// let data = match wrapper {
 +    ///     Wrapper::Data(i) => i,
 +    /// };
 +    /// ```
 +    ///
 +    /// The correct use would be:
 +    /// ```rust
 +    /// enum Wrapper {
 +    ///     Data(i32),
 +    /// }
 +    ///
 +    /// let wrapper = Wrapper::Data(42);
 +    /// let Wrapper::Data(data) = wrapper;
 +    /// ```
 +    #[clippy::version = "pre 1.29.0"]
 +    pub INFALLIBLE_DESTRUCTURING_MATCH,
 +    style,
 +    "a `match` statement with a single infallible arm instead of a `let`"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for useless match that binds to only one value.
 +    ///
 +    /// ### Why is this bad?
 +    /// Readability and needless complexity.
 +    ///
 +    /// ### Known problems
 +    ///  Suggested replacements may be incorrect when `match`
 +    /// is actually binding temporary value, bringing a 'dropped while borrowed' error.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// # let a = 1;
 +    /// # let b = 2;
 +    ///
 +    /// // Bad
 +    /// match (a, b) {
 +    ///     (c, d) => {
 +    ///         // useless match
 +    ///     }
 +    /// }
 +    ///
 +    /// // Good
 +    /// let (c, d) = (a, b);
 +    /// ```
 +    #[clippy::version = "1.43.0"]
 +    pub MATCH_SINGLE_BINDING,
 +    complexity,
 +    "a match with a single binding instead of using `let` statement"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for unnecessary '..' pattern binding on struct when all fields are explicitly matched.
 +    ///
 +    /// ### Why is this bad?
 +    /// Correctness and readability. It's like having a wildcard pattern after
 +    /// matching all enum variants explicitly.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// # struct A { a: i32 }
 +    /// let a = A { a: 5 };
 +    ///
 +    /// // Bad
 +    /// match a {
 +    ///     A { a: 5, .. } => {},
 +    ///     _ => {},
 +    /// }
 +    ///
 +    /// // Good
 +    /// match a {
 +    ///     A { a: 5 } => {},
 +    ///     _ => {},
 +    /// }
 +    /// ```
 +    #[clippy::version = "1.43.0"]
 +    pub REST_PAT_IN_FULLY_BOUND_STRUCTS,
 +    restriction,
 +    "a match on a struct that binds all fields but still uses the wildcard pattern"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Lint for redundant pattern matching over `Result`, `Option`,
 +    /// `std::task::Poll` or `std::net::IpAddr`
 +    ///
 +    /// ### Why is this bad?
 +    /// It's more concise and clear to just use the proper
 +    /// utility function
 +    ///
 +    /// ### Known problems
 +    /// This will change the drop order for the matched type. Both `if let` and
 +    /// `while let` will drop the value at the end of the block, both `if` and `while` will drop the
 +    /// value before entering the block. For most types this change will not matter, but for a few
 +    /// types this will not be an acceptable change (e.g. locks). See the
 +    /// [reference](https://doc.rust-lang.org/reference/destructors.html#drop-scopes) for more about
 +    /// drop order.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// # use std::task::Poll;
 +    /// # use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
 +    /// if let Ok(_) = Ok::<i32, i32>(42) {}
 +    /// if let Err(_) = Err::<i32, i32>(42) {}
 +    /// if let None = None::<()> {}
 +    /// if let Some(_) = Some(42) {}
 +    /// if let Poll::Pending = Poll::Pending::<()> {}
 +    /// if let Poll::Ready(_) = Poll::Ready(42) {}
 +    /// if let IpAddr::V4(_) = IpAddr::V4(Ipv4Addr::LOCALHOST) {}
 +    /// if let IpAddr::V6(_) = IpAddr::V6(Ipv6Addr::LOCALHOST) {}
 +    /// match Ok::<i32, i32>(42) {
 +    ///     Ok(_) => true,
 +    ///     Err(_) => false,
 +    /// };
 +    /// ```
 +    ///
 +    /// The more idiomatic use would be:
 +    ///
 +    /// ```rust
 +    /// # use std::task::Poll;
 +    /// # use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
 +    /// if Ok::<i32, i32>(42).is_ok() {}
 +    /// if Err::<i32, i32>(42).is_err() {}
 +    /// if None::<()>.is_none() {}
 +    /// if Some(42).is_some() {}
 +    /// if Poll::Pending::<()>.is_pending() {}
 +    /// if Poll::Ready(42).is_ready() {}
 +    /// if IpAddr::V4(Ipv4Addr::LOCALHOST).is_ipv4() {}
 +    /// if IpAddr::V6(Ipv6Addr::LOCALHOST).is_ipv6() {}
 +    /// Ok::<i32, i32>(42).is_ok();
 +    /// ```
 +    #[clippy::version = "1.31.0"]
 +    pub REDUNDANT_PATTERN_MATCHING,
 +    style,
 +    "use the proper utility function avoiding an `if let`"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for `match`  or `if let` expressions producing a
 +    /// `bool` that could be written using `matches!`
 +    ///
 +    /// ### Why is this bad?
 +    /// Readability and needless complexity.
 +    ///
 +    /// ### Known problems
 +    /// This lint falsely triggers, if there are arms with
 +    /// `cfg` attributes that remove an arm evaluating to `false`.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// let x = Some(5);
 +    ///
 +    /// // Bad
 +    /// let a = match x {
 +    ///     Some(0) => true,
 +    ///     _ => false,
 +    /// };
 +    ///
 +    /// let a = if let Some(0) = x {
 +    ///     true
 +    /// } else {
 +    ///     false
 +    /// };
 +    ///
 +    /// // Good
 +    /// let a = matches!(x, Some(0));
 +    /// ```
 +    #[clippy::version = "1.47.0"]
 +    pub MATCH_LIKE_MATCHES_MACRO,
 +    style,
 +    "a match that could be written with the matches! macro"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for `match` with identical arm bodies.
 +    ///
 +    /// ### Why is this bad?
 +    /// This is probably a copy & paste error. If arm bodies
 +    /// are the same on purpose, you can factor them
 +    /// [using `|`](https://doc.rust-lang.org/book/patterns.html#multiple-patterns).
 +    ///
 +    /// ### Known problems
 +    /// False positive possible with order dependent `match`
 +    /// (see issue
 +    /// [#860](https://github.com/rust-lang/rust-clippy/issues/860)).
 +    ///
 +    /// ### Example
 +    /// ```rust,ignore
 +    /// match foo {
 +    ///     Bar => bar(),
 +    ///     Quz => quz(),
 +    ///     Baz => bar(), // <= oops
 +    /// }
 +    /// ```
 +    ///
 +    /// This should probably be
 +    /// ```rust,ignore
 +    /// match foo {
 +    ///     Bar => bar(),
 +    ///     Quz => quz(),
 +    ///     Baz => baz(), // <= fixed
 +    /// }
 +    /// ```
 +    ///
 +    /// or if the original code was not a typo:
 +    /// ```rust,ignore
 +    /// match foo {
 +    ///     Bar | Baz => bar(), // <= shows the intent better
 +    ///     Quz => quz(),
 +    /// }
 +    /// ```
 +    #[clippy::version = "pre 1.29.0"]
 +    pub MATCH_SAME_ARMS,
 +    pedantic,
 +    "`match` with identical arm bodies"
 +}
 +
 +#[derive(Default)]
 +pub struct Matches {
 +    msrv: Option<RustcVersion>,
 +    infallible_destructuring_match_linted: bool,
 +}
 +
 +impl Matches {
 +    #[must_use]
 +    pub fn new(msrv: Option<RustcVersion>) -> Self {
 +        Self {
 +            msrv,
 +            ..Matches::default()
 +        }
 +    }
 +}
 +
 +impl_lint_pass!(Matches => [
 +    SINGLE_MATCH,
 +    MATCH_REF_PATS,
 +    MATCH_BOOL,
 +    SINGLE_MATCH_ELSE,
 +    MATCH_OVERLAPPING_ARM,
 +    MATCH_WILD_ERR_ARM,
 +    MATCH_AS_REF,
 +    WILDCARD_ENUM_MATCH_ARM,
 +    MATCH_WILDCARD_FOR_SINGLE_VARIANTS,
 +    WILDCARD_IN_OR_PATTERNS,
 +    MATCH_SINGLE_BINDING,
 +    INFALLIBLE_DESTRUCTURING_MATCH,
 +    REST_PAT_IN_FULLY_BOUND_STRUCTS,
 +    REDUNDANT_PATTERN_MATCHING,
 +    MATCH_LIKE_MATCHES_MACRO,
 +    MATCH_SAME_ARMS,
 +]);
 +
 +impl<'tcx> LateLintPass<'tcx> for Matches {
 +    fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
 +        if expr.span.from_expansion() {
 +            return;
 +        }
 +
 +        redundant_pattern_match::check(cx, expr);
 +
 +        if meets_msrv(self.msrv.as_ref(), &msrvs::MATCHES_MACRO) {
 +            if !check_match_like_matches(cx, expr) {
 +                lint_match_arms(cx, expr);
 +            }
 +        } else {
 +            lint_match_arms(cx, expr);
 +        }
 +
 +        if let ExprKind::Match(ex, arms, MatchSource::Normal) = expr.kind {
 +            check_single_match(cx, ex, arms, expr);
 +            check_match_bool(cx, ex, arms, expr);
 +            check_overlapping_arms(cx, ex, arms);
 +            check_wild_err_arm(cx, ex, arms);
 +            check_wild_enum_match(cx, ex, arms);
 +            check_match_as_ref(cx, ex, arms, expr);
 +            check_wild_in_or_pats(cx, arms);
 +
 +            if self.infallible_destructuring_match_linted {
 +                self.infallible_destructuring_match_linted = false;
 +            } else {
 +                check_match_single_binding(cx, ex, arms, expr);
 +            }
 +        }
 +        if let ExprKind::Match(ex, arms, _) = expr.kind {
 +            check_match_ref_pats(cx, ex, arms.iter().map(|el| el.pat), expr);
 +        }
 +    }
 +
 +    fn check_local(&mut self, cx: &LateContext<'tcx>, local: &'tcx Local<'_>) {
 +        if_chain! {
 +            if !local.span.from_expansion();
 +            if let Some(expr) = local.init;
 +            if let ExprKind::Match(target, arms, MatchSource::Normal) = expr.kind;
 +            if arms.len() == 1 && arms[0].guard.is_none();
 +            if let PatKind::TupleStruct(
 +                QPath::Resolved(None, variant_name), args, _) = arms[0].pat.kind;
 +            if args.len() == 1;
 +            if let PatKind::Binding(_, arg, ..) = strip_pat_refs(&args[0]).kind;
 +            let body = peel_blocks(arms[0].body);
 +            if path_to_local_id(body, arg);
 +
 +            then {
 +                let mut applicability = Applicability::MachineApplicable;
 +                self.infallible_destructuring_match_linted = true;
 +                span_lint_and_sugg(
 +                    cx,
 +                    INFALLIBLE_DESTRUCTURING_MATCH,
 +                    local.span,
 +                    "you seem to be trying to use `match` to destructure a single infallible pattern. \
 +                    Consider using `let`",
 +                    "try this",
 +                    format!(
 +                        "let {}({}) = {};",
 +                        snippet_with_applicability(cx, variant_name.span, "..", &mut applicability),
 +                        snippet_with_applicability(cx, local.pat.span, "..", &mut applicability),
 +                        snippet_with_applicability(cx, target.span, "..", &mut applicability),
 +                    ),
 +                    applicability,
 +                );
 +            }
 +        }
 +    }
 +
 +    fn check_pat(&mut self, cx: &LateContext<'tcx>, pat: &'tcx Pat<'_>) {
 +        if_chain! {
 +            if !pat.span.from_expansion();
 +            if let PatKind::Struct(QPath::Resolved(_, path), fields, true) = pat.kind;
 +            if let Some(def_id) = path.res.opt_def_id();
 +            let ty = cx.tcx.type_of(def_id);
 +            if let ty::Adt(def, _) = ty.kind();
 +            if def.is_struct() || def.is_union();
 +            if fields.len() == def.non_enum_variant().fields.len();
 +
 +            then {
 +                span_lint_and_help(
 +                    cx,
 +                    REST_PAT_IN_FULLY_BOUND_STRUCTS,
 +                    pat.span,
 +                    "unnecessary use of `..` pattern in struct binding. All fields were already bound",
 +                    None,
 +                    "consider removing `..` from this binding",
 +                );
 +            }
 +        }
 +    }
 +
 +    extract_msrv_attr!(LateContext);
 +}
 +
 +#[rustfmt::skip]
 +fn check_single_match(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>], expr: &Expr<'_>) {
 +    if arms.len() == 2 && arms[0].guard.is_none() && arms[1].guard.is_none() {
 +        if expr.span.from_expansion() {
 +            // Don't lint match expressions present in
 +            // macro_rules! block
 +            return;
 +        }
 +        if let PatKind::Or(..) = arms[0].pat.kind {
 +            // don't lint for or patterns for now, this makes
 +            // the lint noisy in unnecessary situations
 +            return;
 +        }
 +        let els = arms[1].body;
 +        let els = if is_unit_expr(peel_blocks(els)) {
 +            None
 +        } else if let ExprKind::Block(Block { stmts, expr: block_expr, .. }, _) = els.kind {
 +            if stmts.len() == 1 && block_expr.is_none() || stmts.is_empty() && block_expr.is_some() {
 +                // single statement/expr "else" block, don't lint
 +                return;
 +            }
 +            // block with 2+ statements or 1 expr and 1+ statement
 +            Some(els)
 +        } else {
 +            // not a block, don't lint
 +            return;
 +        };
 +
 +        let ty = cx.typeck_results().expr_ty(ex);
 +        if *ty.kind() != ty::Bool || is_lint_allowed(cx, MATCH_BOOL, ex.hir_id) {
 +            check_single_match_single_pattern(cx, ex, arms, expr, els);
 +            check_single_match_opt_like(cx, ex, arms, expr, ty, els);
 +        }
 +    }
 +}
 +
 +fn check_single_match_single_pattern(
 +    cx: &LateContext<'_>,
 +    ex: &Expr<'_>,
 +    arms: &[Arm<'_>],
 +    expr: &Expr<'_>,
 +    els: Option<&Expr<'_>>,
 +) {
 +    if is_wild(arms[1].pat) {
 +        report_single_match_single_pattern(cx, ex, arms, expr, els);
 +    }
 +}
 +
 +fn report_single_match_single_pattern(
 +    cx: &LateContext<'_>,
 +    ex: &Expr<'_>,
 +    arms: &[Arm<'_>],
 +    expr: &Expr<'_>,
 +    els: Option<&Expr<'_>>,
 +) {
 +    let lint = if els.is_some() { SINGLE_MATCH_ELSE } else { SINGLE_MATCH };
 +    let els_str = els.map_or(String::new(), |els| {
 +        format!(" else {}", expr_block(cx, els, None, "..", Some(expr.span)))
 +    });
 +
 +    let (pat, pat_ref_count) = peel_hir_pat_refs(arms[0].pat);
 +    let (msg, sugg) = if_chain! {
 +        if let PatKind::Path(_) | PatKind::Lit(_) = pat.kind;
 +        let (ty, ty_ref_count) = peel_mid_ty_refs(cx.typeck_results().expr_ty(ex));
 +        if let Some(spe_trait_id) = cx.tcx.lang_items().structural_peq_trait();
 +        if let Some(pe_trait_id) = cx.tcx.lang_items().eq_trait();
 +        if ty.is_integral() || ty.is_char() || ty.is_str()
 +            || (implements_trait(cx, ty, spe_trait_id, &[])
 +                && implements_trait(cx, ty, pe_trait_id, &[ty.into()]));
 +        then {
 +            // scrutinee derives PartialEq and the pattern is a constant.
 +            let pat_ref_count = match pat.kind {
 +                // string literals are already a reference.
 +                PatKind::Lit(Expr { kind: ExprKind::Lit(lit), .. }) if lit.node.is_str() => pat_ref_count + 1,
 +                _ => pat_ref_count,
 +            };
 +            // References are only implicitly added to the pattern, so no overflow here.
 +            // e.g. will work: match &Some(_) { Some(_) => () }
 +            // will not: match Some(_) { &Some(_) => () }
 +            let ref_count_diff = ty_ref_count - pat_ref_count;
 +
 +            // Try to remove address of expressions first.
 +            let (ex, removed) = peel_n_hir_expr_refs(ex, ref_count_diff);
 +            let ref_count_diff = ref_count_diff - removed;
 +
 +            let msg = "you seem to be trying to use `match` for an equality check. Consider using `if`";
 +            let sugg = format!(
 +                "if {} == {}{} {}{}",
 +                snippet(cx, ex.span, ".."),
 +                // PartialEq for different reference counts may not exist.
 +                "&".repeat(ref_count_diff),
 +                snippet(cx, arms[0].pat.span, ".."),
 +                expr_block(cx, arms[0].body, None, "..", Some(expr.span)),
 +                els_str,
 +            );
 +            (msg, sugg)
 +        } else {
 +            let msg = "you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`";
 +            let sugg = format!(
 +                "if let {} = {} {}{}",
 +                snippet(cx, arms[0].pat.span, ".."),
 +                snippet(cx, ex.span, ".."),
 +                expr_block(cx, arms[0].body, None, "..", Some(expr.span)),
 +                els_str,
 +            );
 +            (msg, sugg)
 +        }
 +    };
 +
 +    span_lint_and_sugg(
 +        cx,
 +        lint,
 +        expr.span,
 +        msg,
 +        "try this",
 +        sugg,
 +        Applicability::HasPlaceholders,
 +    );
 +}
 +
 +fn check_single_match_opt_like(
 +    cx: &LateContext<'_>,
 +    ex: &Expr<'_>,
 +    arms: &[Arm<'_>],
 +    expr: &Expr<'_>,
 +    ty: Ty<'_>,
 +    els: Option<&Expr<'_>>,
 +) {
 +    // list of candidate `Enum`s we know will never get any more members
 +    let candidates = &[
 +        (&paths::COW, "Borrowed"),
 +        (&paths::COW, "Cow::Borrowed"),
 +        (&paths::COW, "Cow::Owned"),
 +        (&paths::COW, "Owned"),
 +        (&paths::OPTION, "None"),
 +        (&paths::RESULT, "Err"),
 +        (&paths::RESULT, "Ok"),
 +    ];
 +
 +    let path = match arms[1].pat.kind {
 +        PatKind::TupleStruct(ref path, inner, _) => {
 +            // Contains any non wildcard patterns (e.g., `Err(err)`)?
 +            if !inner.iter().all(is_wild) {
 +                return;
 +            }
 +            rustc_hir_pretty::to_string(rustc_hir_pretty::NO_ANN, |s| s.print_qpath(path, false))
 +        },
 +        PatKind::Binding(BindingAnnotation::Unannotated, .., ident, None) => ident.to_string(),
 +        PatKind::Path(ref path) => {
 +            rustc_hir_pretty::to_string(rustc_hir_pretty::NO_ANN, |s| s.print_qpath(path, false))
 +        },
 +        _ => return,
 +    };
 +
 +    for &(ty_path, pat_path) in candidates {
 +        if path == *pat_path && match_type(cx, ty, ty_path) {
 +            report_single_match_single_pattern(cx, ex, arms, expr, els);
 +        }
 +    }
 +}
 +
 +fn check_match_bool(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>], expr: &Expr<'_>) {
 +    // Type of expression is `bool`.
 +    if *cx.typeck_results().expr_ty(ex).kind() == ty::Bool {
 +        span_lint_and_then(
 +            cx,
 +            MATCH_BOOL,
 +            expr.span,
 +            "you seem to be trying to match on a boolean expression",
 +            move |diag| {
 +                if arms.len() == 2 {
 +                    // no guards
 +                    let exprs = if let PatKind::Lit(arm_bool) = arms[0].pat.kind {
 +                        if let ExprKind::Lit(ref lit) = arm_bool.kind {
 +                            match lit.node {
 +                                LitKind::Bool(true) => Some((&*arms[0].body, &*arms[1].body)),
 +                                LitKind::Bool(false) => Some((&*arms[1].body, &*arms[0].body)),
 +                                _ => None,
 +                            }
 +                        } else {
 +                            None
 +                        }
 +                    } else {
 +                        None
 +                    };
 +
 +                    if let Some((true_expr, false_expr)) = exprs {
 +                        let sugg = match (is_unit_expr(true_expr), is_unit_expr(false_expr)) {
 +                            (false, false) => Some(format!(
 +                                "if {} {} else {}",
 +                                snippet(cx, ex.span, "b"),
 +                                expr_block(cx, true_expr, None, "..", Some(expr.span)),
 +                                expr_block(cx, false_expr, None, "..", Some(expr.span))
 +                            )),
 +                            (false, true) => Some(format!(
 +                                "if {} {}",
 +                                snippet(cx, ex.span, "b"),
 +                                expr_block(cx, true_expr, None, "..", Some(expr.span))
 +                            )),
 +                            (true, false) => {
 +                                let test = Sugg::hir(cx, ex, "..");
 +                                Some(format!(
 +                                    "if {} {}",
 +                                    !test,
 +                                    expr_block(cx, false_expr, None, "..", Some(expr.span))
 +                                ))
 +                            },
 +                            (true, true) => None,
 +                        };
 +
 +                        if let Some(sugg) = sugg {
 +                            diag.span_suggestion(
 +                                expr.span,
 +                                "consider using an `if`/`else` expression",
 +                                sugg,
 +                                Applicability::HasPlaceholders,
 +                            );
 +                        }
 +                    }
 +                }
 +            },
 +        );
 +    }
 +}
 +
 +fn check_overlapping_arms<'tcx>(cx: &LateContext<'tcx>, ex: &'tcx Expr<'_>, arms: &'tcx [Arm<'_>]) {
 +    if arms.len() >= 2 && cx.typeck_results().expr_ty(ex).is_integral() {
 +        let ranges = all_ranges(cx, arms, cx.typeck_results().expr_ty(ex));
 +        if !ranges.is_empty() {
 +            if let Some((start, end)) = overlapping(&ranges) {
 +                span_lint_and_note(
 +                    cx,
 +                    MATCH_OVERLAPPING_ARM,
 +                    start.span,
 +                    "some ranges overlap",
 +                    Some(end.span),
 +                    "overlaps with this",
 +                );
 +            }
 +        }
 +    }
 +}
 +
 +fn check_wild_err_arm<'tcx>(cx: &LateContext<'tcx>, ex: &Expr<'tcx>, arms: &[Arm<'tcx>]) {
 +    let ex_ty = cx.typeck_results().expr_ty(ex).peel_refs();
 +    if is_type_diagnostic_item(cx, ex_ty, sym::Result) {
 +        for arm in arms {
 +            if let PatKind::TupleStruct(ref path, inner, _) = arm.pat.kind {
 +                let path_str = rustc_hir_pretty::to_string(rustc_hir_pretty::NO_ANN, |s| s.print_qpath(path, false));
 +                if path_str == "Err" {
 +                    let mut matching_wild = inner.iter().any(is_wild);
-                                     ident_bind_name = ident.name.as_str().to_string();
++                    let mut ident_bind_name = kw::Underscore;
 +                    if !matching_wild {
 +                        // Looking for unused bindings (i.e.: `_e`)
 +                        for pat in inner.iter() {
 +                            if let PatKind::Binding(_, id, ident, None) = pat.kind {
 +                                if ident.as_str().starts_with('_') && !is_local_used(cx, arm.body, id) {
-                                 &format!("`Err({})` matches all errors", &ident_bind_name),
++                                    ident_bind_name = ident.name;
 +                                    matching_wild = true;
 +                                }
 +                            }
 +                        }
 +                    }
 +                    if_chain! {
 +                        if matching_wild;
 +                        if let Some(macro_call) = root_macro_call(peel_blocks_with_stmt(arm.body).span);
 +                        if is_panic(cx, macro_call.def_id);
 +                        then {
 +                            // `Err(_)` or `Err(_e)` arm with `panic!` found
 +                            span_lint_and_note(cx,
 +                                MATCH_WILD_ERR_ARM,
 +                                arm.pat.span,
++                                &format!("`Err({})` matches all errors", ident_bind_name),
 +                                None,
 +                                "match each error separately or use the error output, or use `.except(msg)` if the error case is unreachable",
 +                            );
 +                        }
 +                    }
 +                }
 +            }
 +        }
 +    }
 +}
 +
 +enum CommonPrefixSearcher<'a> {
 +    None,
 +    Path(&'a [PathSegment<'a>]),
 +    Mixed,
 +}
 +impl<'a> CommonPrefixSearcher<'a> {
 +    fn with_path(&mut self, path: &'a [PathSegment<'a>]) {
 +        match path {
 +            [path @ .., _] => self.with_prefix(path),
 +            [] => (),
 +        }
 +    }
 +
 +    fn with_prefix(&mut self, path: &'a [PathSegment<'a>]) {
 +        match self {
 +            Self::None => *self = Self::Path(path),
 +            Self::Path(self_path)
 +                if path
 +                    .iter()
 +                    .map(|p| p.ident.name)
 +                    .eq(self_path.iter().map(|p| p.ident.name)) => {},
 +            Self::Path(_) => *self = Self::Mixed,
 +            Self::Mixed => (),
 +        }
 +    }
 +}
 +
 +fn is_hidden(cx: &LateContext<'_>, variant_def: &VariantDef) -> bool {
 +    let attrs = cx.tcx.get_attrs(variant_def.def_id);
 +    clippy_utils::attrs::is_doc_hidden(attrs) || clippy_utils::attrs::is_unstable(attrs)
 +}
 +
 +#[allow(clippy::too_many_lines)]
 +fn check_wild_enum_match(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>]) {
 +    let ty = cx.typeck_results().expr_ty(ex).peel_refs();
 +    let adt_def = match ty.kind() {
 +        ty::Adt(adt_def, _)
 +            if adt_def.is_enum()
 +                && !(is_type_diagnostic_item(cx, ty, sym::Option) || is_type_diagnostic_item(cx, ty, sym::Result)) =>
 +        {
 +            adt_def
 +        },
 +        _ => return,
 +    };
 +
 +    // First pass - check for violation, but don't do much book-keeping because this is hopefully
 +    // the uncommon case, and the book-keeping is slightly expensive.
 +    let mut wildcard_span = None;
 +    let mut wildcard_ident = None;
 +    let mut has_non_wild = false;
 +    for arm in arms {
 +        match peel_hir_pat_refs(arm.pat).0.kind {
 +            PatKind::Wild => wildcard_span = Some(arm.pat.span),
 +            PatKind::Binding(_, _, ident, None) => {
 +                wildcard_span = Some(arm.pat.span);
 +                wildcard_ident = Some(ident);
 +            },
 +            _ => has_non_wild = true,
 +        }
 +    }
 +    let wildcard_span = match wildcard_span {
 +        Some(x) if has_non_wild => x,
 +        _ => return,
 +    };
 +
 +    // Accumulate the variants which should be put in place of the wildcard because they're not
 +    // already covered.
 +    let has_hidden = adt_def.variants.iter().any(|x| is_hidden(cx, x));
 +    let mut missing_variants: Vec<_> = adt_def.variants.iter().filter(|x| !is_hidden(cx, x)).collect();
 +
 +    let mut path_prefix = CommonPrefixSearcher::None;
 +    for arm in arms {
 +        // Guards mean that this case probably isn't exhaustively covered. Technically
 +        // this is incorrect, as we should really check whether each variant is exhaustively
 +        // covered by the set of guards that cover it, but that's really hard to do.
 +        recurse_or_patterns(arm.pat, |pat| {
 +            let path = match &peel_hir_pat_refs(pat).0.kind {
 +                PatKind::Path(path) => {
 +                    #[allow(clippy::match_same_arms)]
 +                    let id = match cx.qpath_res(path, pat.hir_id) {
 +                        Res::Def(
 +                            DefKind::Const | DefKind::ConstParam | DefKind::AnonConst | DefKind::InlineConst,
 +                            _,
 +                        ) => return,
 +                        Res::Def(_, id) => id,
 +                        _ => return,
 +                    };
 +                    if arm.guard.is_none() {
 +                        missing_variants.retain(|e| e.ctor_def_id != Some(id));
 +                    }
 +                    path
 +                },
 +                PatKind::TupleStruct(path, patterns, ..) => {
 +                    if let Some(id) = cx.qpath_res(path, pat.hir_id).opt_def_id() {
 +                        if arm.guard.is_none() && patterns.iter().all(|p| !is_refutable(cx, p)) {
 +                            missing_variants.retain(|e| e.ctor_def_id != Some(id));
 +                        }
 +                    }
 +                    path
 +                },
 +                PatKind::Struct(path, patterns, ..) => {
 +                    if let Some(id) = cx.qpath_res(path, pat.hir_id).opt_def_id() {
 +                        if arm.guard.is_none() && patterns.iter().all(|p| !is_refutable(cx, p.pat)) {
 +                            missing_variants.retain(|e| e.def_id != id);
 +                        }
 +                    }
 +                    path
 +                },
 +                _ => return,
 +            };
 +            match path {
 +                QPath::Resolved(_, path) => path_prefix.with_path(path.segments),
 +                QPath::TypeRelative(
 +                    hir::Ty {
 +                        kind: TyKind::Path(QPath::Resolved(_, path)),
 +                        ..
 +                    },
 +                    _,
 +                ) => path_prefix.with_prefix(path.segments),
 +                _ => (),
 +            }
 +        });
 +    }
 +
 +    let format_suggestion = |variant: &VariantDef| {
 +        format!(
 +            "{}{}{}{}",
 +            if let Some(ident) = wildcard_ident {
 +                format!("{} @ ", ident.name)
 +            } else {
 +                String::new()
 +            },
 +            if let CommonPrefixSearcher::Path(path_prefix) = path_prefix {
 +                let mut s = String::new();
 +                for seg in path_prefix {
 +                    s.push_str(seg.ident.as_str());
 +                    s.push_str("::");
 +                }
 +                s
 +            } else {
 +                let mut s = cx.tcx.def_path_str(adt_def.did);
 +                s.push_str("::");
 +                s
 +            },
 +            variant.name,
 +            match variant.ctor_kind {
 +                CtorKind::Fn if variant.fields.len() == 1 => "(_)",
 +                CtorKind::Fn => "(..)",
 +                CtorKind::Const => "",
 +                CtorKind::Fictive => "{ .. }",
 +            }
 +        )
 +    };
 +
 +    match missing_variants.as_slice() {
 +        [] => (),
 +        [x] if !adt_def.is_variant_list_non_exhaustive() && !has_hidden => span_lint_and_sugg(
 +            cx,
 +            MATCH_WILDCARD_FOR_SINGLE_VARIANTS,
 +            wildcard_span,
 +            "wildcard matches only a single variant and will also match any future added variants",
 +            "try this",
 +            format_suggestion(x),
 +            Applicability::MaybeIncorrect,
 +        ),
 +        variants => {
 +            let mut suggestions: Vec<_> = variants.iter().copied().map(format_suggestion).collect();
 +            let message = if adt_def.is_variant_list_non_exhaustive() || has_hidden {
 +                suggestions.push("_".into());
 +                "wildcard matches known variants and will also match future added variants"
 +            } else {
 +                "wildcard match will also match any future added variants"
 +            };
 +
 +            span_lint_and_sugg(
 +                cx,
 +                WILDCARD_ENUM_MATCH_ARM,
 +                wildcard_span,
 +                message,
 +                "try this",
 +                suggestions.join(" | "),
 +                Applicability::MaybeIncorrect,
 +            );
 +        },
 +    };
 +}
 +
 +fn check_match_ref_pats<'a, 'b, I>(cx: &LateContext<'_>, ex: &Expr<'_>, pats: I, expr: &Expr<'_>)
 +where
 +    'b: 'a,
 +    I: Clone + Iterator<Item = &'a Pat<'b>>,
 +{
 +    if !has_multiple_ref_pats(pats.clone()) {
 +        return;
 +    }
 +
 +    let (first_sugg, msg, title);
 +    let span = ex.span.source_callsite();
 +    if let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner) = ex.kind {
 +        first_sugg = once((span, Sugg::hir_with_macro_callsite(cx, inner, "..").to_string()));
 +        msg = "try";
 +        title = "you don't need to add `&` to both the expression and the patterns";
 +    } else {
 +        first_sugg = once((span, Sugg::hir_with_macro_callsite(cx, ex, "..").deref().to_string()));
 +        msg = "instead of prefixing all patterns with `&`, you can dereference the expression";
 +        title = "you don't need to add `&` to all patterns";
 +    }
 +
 +    let remaining_suggs = pats.filter_map(|pat| {
 +        if let PatKind::Ref(refp, _) = pat.kind {
 +            Some((pat.span, snippet(cx, refp.span, "..").to_string()))
 +        } else {
 +            None
 +        }
 +    });
 +
 +    span_lint_and_then(cx, MATCH_REF_PATS, expr.span, title, |diag| {
 +        if !expr.span.from_expansion() {
 +            multispan_sugg(diag, msg, first_sugg.chain(remaining_suggs));
 +        }
 +    });
 +}
 +
 +fn check_match_as_ref(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>], expr: &Expr<'_>) {
 +    if arms.len() == 2 && arms[0].guard.is_none() && arms[1].guard.is_none() {
 +        let arm_ref: Option<BindingAnnotation> = if is_none_arm(cx, &arms[0]) {
 +            is_ref_some_arm(cx, &arms[1])
 +        } else if is_none_arm(cx, &arms[1]) {
 +            is_ref_some_arm(cx, &arms[0])
 +        } else {
 +            None
 +        };
 +        if let Some(rb) = arm_ref {
 +            let suggestion = if rb == BindingAnnotation::Ref {
 +                "as_ref"
 +            } else {
 +                "as_mut"
 +            };
 +
 +            let output_ty = cx.typeck_results().expr_ty(expr);
 +            let input_ty = cx.typeck_results().expr_ty(ex);
 +
 +            let cast = if_chain! {
 +                if let ty::Adt(_, substs) = input_ty.kind();
 +                let input_ty = substs.type_at(0);
 +                if let ty::Adt(_, substs) = output_ty.kind();
 +                let output_ty = substs.type_at(0);
 +                if let ty::Ref(_, output_ty, _) = *output_ty.kind();
 +                if input_ty != output_ty;
 +                then {
 +                    ".map(|x| x as _)"
 +                } else {
 +                    ""
 +                }
 +            };
 +
 +            let mut applicability = Applicability::MachineApplicable;
 +            span_lint_and_sugg(
 +                cx,
 +                MATCH_AS_REF,
 +                expr.span,
 +                &format!("use `{}()` instead", suggestion),
 +                "try this",
 +                format!(
 +                    "{}.{}(){}",
 +                    snippet_with_applicability(cx, ex.span, "_", &mut applicability),
 +                    suggestion,
 +                    cast,
 +                ),
 +                applicability,
 +            );
 +        }
 +    }
 +}
 +
 +fn check_wild_in_or_pats(cx: &LateContext<'_>, arms: &[Arm<'_>]) {
 +    for arm in arms {
 +        if let PatKind::Or(fields) = arm.pat.kind {
 +            // look for multiple fields in this arm that contains at least one Wild pattern
 +            if fields.len() > 1 && fields.iter().any(is_wild) {
 +                span_lint_and_help(
 +                    cx,
 +                    WILDCARD_IN_OR_PATTERNS,
 +                    arm.pat.span,
 +                    "wildcard pattern covers any other pattern as it will match anyway",
 +                    None,
 +                    "consider handling `_` separately",
 +                );
 +            }
 +        }
 +    }
 +}
 +
 +/// Lint a `match` or `if let .. { .. } else { .. }` expr that could be replaced by `matches!`
 +fn check_match_like_matches<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) -> bool {
 +    if let Some(higher::IfLet {
 +        let_pat,
 +        let_expr,
 +        if_then,
 +        if_else: Some(if_else),
 +    }) = higher::IfLet::hir(cx, expr)
 +    {
 +        return find_matches_sugg(
 +            cx,
 +            let_expr,
 +            IntoIterator::into_iter([(&[][..], Some(let_pat), if_then, None), (&[][..], None, if_else, None)]),
 +            expr,
 +            true,
 +        );
 +    }
 +
 +    if let ExprKind::Match(scrut, arms, MatchSource::Normal) = expr.kind {
 +        return find_matches_sugg(
 +            cx,
 +            scrut,
 +            arms.iter().map(|arm| {
 +                (
 +                    cx.tcx.hir().attrs(arm.hir_id),
 +                    Some(arm.pat),
 +                    arm.body,
 +                    arm.guard.as_ref(),
 +                )
 +            }),
 +            expr,
 +            false,
 +        );
 +    }
 +
 +    false
 +}
 +
 +/// Lint a `match` or `if let` for replacement by `matches!`
 +fn find_matches_sugg<'a, 'b, I>(
 +    cx: &LateContext<'_>,
 +    ex: &Expr<'_>,
 +    mut iter: I,
 +    expr: &Expr<'_>,
 +    is_if_let: bool,
 +) -> bool
 +where
 +    'b: 'a,
 +    I: Clone
 +        + DoubleEndedIterator
 +        + ExactSizeIterator
 +        + Iterator<
 +            Item = (
 +                &'a [Attribute],
 +                Option<&'a Pat<'b>>,
 +                &'a Expr<'b>,
 +                Option<&'a Guard<'b>>,
 +            ),
 +        >,
 +{
 +    if_chain! {
 +        if iter.len() >= 2;
 +        if cx.typeck_results().expr_ty(expr).is_bool();
 +        if let Some((_, last_pat_opt, last_expr, _)) = iter.next_back();
 +        let iter_without_last = iter.clone();
 +        if let Some((first_attrs, _, first_expr, first_guard)) = iter.next();
 +        if let Some(b0) = find_bool_lit(&first_expr.kind, is_if_let);
 +        if let Some(b1) = find_bool_lit(&last_expr.kind, is_if_let);
 +        if b0 != b1;
 +        if first_guard.is_none() || iter.len() == 0;
 +        if first_attrs.is_empty();
 +        if iter
 +            .all(|arm| {
 +                find_bool_lit(&arm.2.kind, is_if_let).map_or(false, |b| b == b0) && arm.3.is_none() && arm.0.is_empty()
 +            });
 +        then {
 +            if let Some(last_pat) = last_pat_opt {
 +                if !is_wild(last_pat) {
 +                    return false;
 +                }
 +            }
 +
 +            // The suggestion may be incorrect, because some arms can have `cfg` attributes
 +            // evaluated into `false` and so such arms will be stripped before.
 +            let mut applicability = Applicability::MaybeIncorrect;
 +            let pat = {
 +                use itertools::Itertools as _;
 +                iter_without_last
 +                    .filter_map(|arm| {
 +                        let pat_span = arm.1?.span;
 +                        Some(snippet_with_applicability(cx, pat_span, "..", &mut applicability))
 +                    })
 +                    .join(" | ")
 +            };
 +            let pat_and_guard = if let Some(Guard::If(g)) = first_guard {
 +                format!("{} if {}", pat, snippet_with_applicability(cx, g.span, "..", &mut applicability))
 +            } else {
 +                pat
 +            };
 +
 +            // strip potential borrows (#6503), but only if the type is a reference
 +            let mut ex_new = ex;
 +            if let ExprKind::AddrOf(BorrowKind::Ref, .., ex_inner) = ex.kind {
 +                if let ty::Ref(..) = cx.typeck_results().expr_ty(ex_inner).kind() {
 +                    ex_new = ex_inner;
 +                }
 +            };
 +            span_lint_and_sugg(
 +                cx,
 +                MATCH_LIKE_MATCHES_MACRO,
 +                expr.span,
 +                &format!("{} expression looks like `matches!` macro", if is_if_let { "if let .. else" } else { "match" }),
 +                "try this",
 +                format!(
 +                    "{}matches!({}, {})",
 +                    if b0 { "" } else { "!" },
 +                    snippet_with_applicability(cx, ex_new.span, "..", &mut applicability),
 +                    pat_and_guard,
 +                ),
 +                applicability,
 +            );
 +            true
 +        } else {
 +            false
 +        }
 +    }
 +}
 +
 +/// Extract a `bool` or `{ bool }`
 +fn find_bool_lit(ex: &ExprKind<'_>, is_if_let: bool) -> Option<bool> {
 +    match ex {
 +        ExprKind::Lit(Spanned {
 +            node: LitKind::Bool(b), ..
 +        }) => Some(*b),
 +        ExprKind::Block(
 +            rustc_hir::Block {
 +                stmts: &[],
 +                expr: Some(exp),
 +                ..
 +            },
 +            _,
 +        ) if is_if_let => {
 +            if let ExprKind::Lit(Spanned {
 +                node: LitKind::Bool(b), ..
 +            }) = exp.kind
 +            {
 +                Some(b)
 +            } else {
 +                None
 +            }
 +        },
 +        _ => None,
 +    }
 +}
 +
 +#[allow(clippy::too_many_lines)]
 +fn check_match_single_binding<'a>(cx: &LateContext<'a>, ex: &Expr<'a>, arms: &[Arm<'_>], expr: &Expr<'_>) {
 +    if expr.span.from_expansion() || arms.len() != 1 || is_refutable(cx, arms[0].pat) {
 +        return;
 +    }
 +
 +    // HACK:
 +    // This is a hack to deal with arms that are excluded by macros like `#[cfg]`. It is only used here
 +    // to prevent false positives as there is currently no better way to detect if code was excluded by
 +    // a macro. See PR #6435
 +    if_chain! {
 +        if let Some(match_snippet) = snippet_opt(cx, expr.span);
 +        if let Some(arm_snippet) = snippet_opt(cx, arms[0].span);
 +        if let Some(ex_snippet) = snippet_opt(cx, ex.span);
 +        let rest_snippet = match_snippet.replace(&arm_snippet, "").replace(&ex_snippet, "");
 +        if rest_snippet.contains("=>");
 +        then {
 +            // The code it self contains another thick arrow "=>"
 +            // -> Either another arm or a comment
 +            return;
 +        }
 +    }
 +
 +    let matched_vars = ex.span;
 +    let bind_names = arms[0].pat.span;
 +    let match_body = peel_blocks(arms[0].body);
 +    let mut snippet_body = if match_body.span.from_expansion() {
 +        Sugg::hir_with_macro_callsite(cx, match_body, "..").to_string()
 +    } else {
 +        snippet_block(cx, match_body.span, "..", Some(expr.span)).to_string()
 +    };
 +
 +    // Do we need to add ';' to suggestion ?
 +    match match_body.kind {
 +        ExprKind::Block(block, _) => {
 +            // macro + expr_ty(body) == ()
 +            if block.span.from_expansion() && cx.typeck_results().expr_ty(match_body).is_unit() {
 +                snippet_body.push(';');
 +            }
 +        },
 +        _ => {
 +            // expr_ty(body) == ()
 +            if cx.typeck_results().expr_ty(match_body).is_unit() {
 +                snippet_body.push(';');
 +            }
 +        },
 +    }
 +
 +    let mut applicability = Applicability::MaybeIncorrect;
 +    match arms[0].pat.kind {
 +        PatKind::Binding(..) | PatKind::Tuple(_, _) | PatKind::Struct(..) => {
 +            // If this match is in a local (`let`) stmt
 +            let (target_span, sugg) = if let Some(parent_let_node) = opt_parent_let(cx, ex) {
 +                (
 +                    parent_let_node.span,
 +                    format!(
 +                        "let {} = {};\n{}let {} = {};",
 +                        snippet_with_applicability(cx, bind_names, "..", &mut applicability),
 +                        snippet_with_applicability(cx, matched_vars, "..", &mut applicability),
 +                        " ".repeat(indent_of(cx, expr.span).unwrap_or(0)),
 +                        snippet_with_applicability(cx, parent_let_node.pat.span, "..", &mut applicability),
 +                        snippet_body
 +                    ),
 +                )
 +            } else {
 +                // If we are in closure, we need curly braces around suggestion
 +                let mut indent = " ".repeat(indent_of(cx, ex.span).unwrap_or(0));
 +                let (mut cbrace_start, mut cbrace_end) = ("".to_string(), "".to_string());
 +                if let Some(parent_expr) = get_parent_expr(cx, expr) {
 +                    if let ExprKind::Closure(..) = parent_expr.kind {
 +                        cbrace_end = format!("\n{}}}", indent);
 +                        // Fix body indent due to the closure
 +                        indent = " ".repeat(indent_of(cx, bind_names).unwrap_or(0));
 +                        cbrace_start = format!("{{\n{}", indent);
 +                    }
 +                }
 +                // If the parent is already an arm, and the body is another match statement,
 +                // we need curly braces around suggestion
 +                let parent_node_id = cx.tcx.hir().get_parent_node(expr.hir_id);
 +                if let Node::Arm(arm) = &cx.tcx.hir().get(parent_node_id) {
 +                    if let ExprKind::Match(..) = arm.body.kind {
 +                        cbrace_end = format!("\n{}}}", indent);
 +                        // Fix body indent due to the match
 +                        indent = " ".repeat(indent_of(cx, bind_names).unwrap_or(0));
 +                        cbrace_start = format!("{{\n{}", indent);
 +                    }
 +                }
 +                (
 +                    expr.span,
 +                    format!(
 +                        "{}let {} = {};\n{}{}{}",
 +                        cbrace_start,
 +                        snippet_with_applicability(cx, bind_names, "..", &mut applicability),
 +                        snippet_with_applicability(cx, matched_vars, "..", &mut applicability),
 +                        indent,
 +                        snippet_body,
 +                        cbrace_end
 +                    ),
 +                )
 +            };
 +            span_lint_and_sugg(
 +                cx,
 +                MATCH_SINGLE_BINDING,
 +                target_span,
 +                "this match could be written as a `let` statement",
 +                "consider using `let` statement",
 +                sugg,
 +                applicability,
 +            );
 +        },
 +        PatKind::Wild => {
 +            if ex.can_have_side_effects() {
 +                let indent = " ".repeat(indent_of(cx, expr.span).unwrap_or(0));
 +                let sugg = format!(
 +                    "{};\n{}{}",
 +                    snippet_with_applicability(cx, ex.span, "..", &mut applicability),
 +                    indent,
 +                    snippet_body
 +                );
 +                span_lint_and_sugg(
 +                    cx,
 +                    MATCH_SINGLE_BINDING,
 +                    expr.span,
 +                    "this match could be replaced by its scrutinee and body",
 +                    "consider using the scrutinee and body instead",
 +                    sugg,
 +                    applicability,
 +                );
 +            } else {
 +                span_lint_and_sugg(
 +                    cx,
 +                    MATCH_SINGLE_BINDING,
 +                    expr.span,
 +                    "this match could be replaced by its body itself",
 +                    "consider using the match body instead",
 +                    snippet_body,
 +                    Applicability::MachineApplicable,
 +                );
 +            }
 +        },
 +        _ => (),
 +    }
 +}
 +
 +/// Returns true if the `ex` match expression is in a local (`let`) statement
 +fn opt_parent_let<'a>(cx: &LateContext<'a>, ex: &Expr<'a>) -> Option<&'a Local<'a>> {
 +    let map = &cx.tcx.hir();
 +    if_chain! {
 +        if let Some(Node::Expr(parent_arm_expr)) = map.find(map.get_parent_node(ex.hir_id));
 +        if let Some(Node::Local(parent_let_expr)) = map.find(map.get_parent_node(parent_arm_expr.hir_id));
 +        then {
 +            return Some(parent_let_expr);
 +        }
 +    }
 +    None
 +}
 +
 +/// Gets the ranges for each range pattern arm. Applies `ty` bounds for open ranges.
 +fn all_ranges<'tcx>(cx: &LateContext<'tcx>, arms: &'tcx [Arm<'_>], ty: Ty<'tcx>) -> Vec<SpannedRange<FullInt>> {
 +    arms.iter()
 +        .filter_map(|arm| {
 +            if let Arm { pat, guard: None, .. } = *arm {
 +                if let PatKind::Range(ref lhs, ref rhs, range_end) = pat.kind {
 +                    let lhs_const = match lhs {
 +                        Some(lhs) => constant(cx, cx.typeck_results(), lhs)?.0,
 +                        None => miri_to_const(ty.numeric_min_val(cx.tcx)?)?,
 +                    };
 +                    let rhs_const = match rhs {
 +                        Some(rhs) => constant(cx, cx.typeck_results(), rhs)?.0,
 +                        None => miri_to_const(ty.numeric_max_val(cx.tcx)?)?,
 +                    };
 +
 +                    let lhs_val = lhs_const.int_value(cx, ty)?;
 +                    let rhs_val = rhs_const.int_value(cx, ty)?;
 +
 +                    let rhs_bound = match range_end {
 +                        RangeEnd::Included => EndBound::Included(rhs_val),
 +                        RangeEnd::Excluded => EndBound::Excluded(rhs_val),
 +                    };
 +                    return Some(SpannedRange {
 +                        span: pat.span,
 +                        node: (lhs_val, rhs_bound),
 +                    });
 +                }
 +
 +                if let PatKind::Lit(value) = pat.kind {
 +                    let value = constant_full_int(cx, cx.typeck_results(), value)?;
 +                    return Some(SpannedRange {
 +                        span: pat.span,
 +                        node: (value, EndBound::Included(value)),
 +                    });
 +                }
 +            }
 +            None
 +        })
 +        .collect()
 +}
 +
 +#[derive(Clone, Copy, Debug, Eq, PartialEq)]
 +pub enum EndBound<T> {
 +    Included(T),
 +    Excluded(T),
 +}
 +
 +#[derive(Debug, Eq, PartialEq)]
 +struct SpannedRange<T> {
 +    pub span: Span,
 +    pub node: (T, EndBound<T>),
 +}
 +
 +// Checks if arm has the form `None => None`
 +fn is_none_arm(cx: &LateContext<'_>, arm: &Arm<'_>) -> bool {
 +    matches!(arm.pat.kind, PatKind::Path(ref qpath) if is_lang_ctor(cx, qpath, OptionNone))
 +}
 +
 +// Checks if arm has the form `Some(ref v) => Some(v)` (checks for `ref` and `ref mut`)
 +fn is_ref_some_arm(cx: &LateContext<'_>, arm: &Arm<'_>) -> Option<BindingAnnotation> {
 +    if_chain! {
 +        if let PatKind::TupleStruct(ref qpath, [first_pat, ..], _) = arm.pat.kind;
 +        if is_lang_ctor(cx, qpath, OptionSome);
 +        if let PatKind::Binding(rb, .., ident, _) = first_pat.kind;
 +        if rb == BindingAnnotation::Ref || rb == BindingAnnotation::RefMut;
 +        if let ExprKind::Call(e, args) = peel_blocks(arm.body).kind;
 +        if let ExprKind::Path(ref some_path) = e.kind;
 +        if is_lang_ctor(cx, some_path, OptionSome) && args.len() == 1;
 +        if let ExprKind::Path(QPath::Resolved(_, path2)) = args[0].kind;
 +        if path2.segments.len() == 1 && ident.name == path2.segments[0].ident.name;
 +        then {
 +            return Some(rb)
 +        }
 +    }
 +    None
 +}
 +
 +fn has_multiple_ref_pats<'a, 'b, I>(pats: I) -> bool
 +where
 +    'b: 'a,
 +    I: Iterator<Item = &'a Pat<'b>>,
 +{
 +    let mut ref_count = 0;
 +    for opt in pats.map(|pat| match pat.kind {
 +        PatKind::Ref(..) => Some(true), // &-patterns
 +        PatKind::Wild => Some(false),   // an "anything" wildcard is also fine
 +        _ => None,                      // any other pattern is not fine
 +    }) {
 +        if let Some(inner) = opt {
 +            if inner {
 +                ref_count += 1;
 +            }
 +        } else {
 +            return false;
 +        }
 +    }
 +    ref_count > 1
 +}
 +
 +fn overlapping<T>(ranges: &[SpannedRange<T>]) -> Option<(&SpannedRange<T>, &SpannedRange<T>)>
 +where
 +    T: Copy + Ord,
 +{
 +    #[derive(Copy, Clone, Debug, Eq, Ord, PartialEq, PartialOrd)]
 +    enum BoundKind {
 +        EndExcluded,
 +        Start,
 +        EndIncluded,
 +    }
 +
 +    #[derive(Copy, Clone, Debug, Eq, PartialEq)]
 +    struct RangeBound<'a, T>(T, BoundKind, &'a SpannedRange<T>);
 +
 +    impl<'a, T: Copy + Ord> PartialOrd for RangeBound<'a, T> {
 +        fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
 +            Some(self.cmp(other))
 +        }
 +    }
 +
 +    impl<'a, T: Copy + Ord> Ord for RangeBound<'a, T> {
 +        fn cmp(&self, RangeBound(other_value, other_kind, _): &Self) -> Ordering {
 +            let RangeBound(self_value, self_kind, _) = *self;
 +            (self_value, self_kind).cmp(&(*other_value, *other_kind))
 +        }
 +    }
 +
 +    let mut values = Vec::with_capacity(2 * ranges.len());
 +
 +    for r @ SpannedRange { node: (start, end), .. } in ranges {
 +        values.push(RangeBound(*start, BoundKind::Start, r));
 +        values.push(match end {
 +            EndBound::Excluded(val) => RangeBound(*val, BoundKind::EndExcluded, r),
 +            EndBound::Included(val) => RangeBound(*val, BoundKind::EndIncluded, r),
 +        });
 +    }
 +
 +    values.sort();
 +
 +    let mut started = vec![];
 +
 +    for RangeBound(_, kind, range) in values {
 +        match kind {
 +            BoundKind::Start => started.push(range),
 +            BoundKind::EndExcluded | BoundKind::EndIncluded => {
 +                let mut overlap = None;
 +
 +                while let Some(last_started) = started.pop() {
 +                    if last_started == range {
 +                        break;
 +                    }
 +                    overlap = Some(last_started);
 +                }
 +
 +                if let Some(first_overlapping) = overlap {
 +                    return Some((range, first_overlapping));
 +                }
 +            },
 +        }
 +    }
 +
 +    None
 +}
 +
 +mod redundant_pattern_match {
 +    use super::REDUNDANT_PATTERN_MATCHING;
 +    use clippy_utils::diagnostics::span_lint_and_then;
 +    use clippy_utils::higher;
 +    use clippy_utils::source::snippet;
 +    use clippy_utils::sugg::Sugg;
 +    use clippy_utils::ty::{implements_trait, is_type_diagnostic_item, is_type_lang_item, match_type};
 +    use clippy_utils::{is_lang_ctor, is_qpath_def_path, is_trait_method, paths};
 +    use if_chain::if_chain;
 +    use rustc_ast::ast::LitKind;
 +    use rustc_data_structures::fx::FxHashSet;
 +    use rustc_errors::Applicability;
 +    use rustc_hir::LangItem::{OptionNone, OptionSome, PollPending, PollReady, ResultErr, ResultOk};
 +    use rustc_hir::{
 +        intravisit::{walk_expr, Visitor},
 +        Arm, Block, Expr, ExprKind, LangItem, MatchSource, Node, Pat, PatKind, QPath, UnOp,
 +    };
 +    use rustc_lint::LateContext;
 +    use rustc_middle::ty::{self, subst::GenericArgKind, Ty};
 +    use rustc_span::sym;
 +
 +    pub fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
 +        if let Some(higher::IfLet {
 +            if_else,
 +            let_pat,
 +            let_expr,
 +            ..
 +        }) = higher::IfLet::hir(cx, expr)
 +        {
 +            find_sugg_for_if_let(cx, expr, let_pat, let_expr, "if", if_else.is_some());
 +        }
 +        if let ExprKind::Match(op, arms, MatchSource::Normal) = &expr.kind {
 +            find_sugg_for_match(cx, expr, op, arms);
 +        }
 +        if let Some(higher::WhileLet { let_pat, let_expr, .. }) = higher::WhileLet::hir(expr) {
 +            find_sugg_for_if_let(cx, expr, let_pat, let_expr, "while", false);
 +        }
 +    }
 +
 +    /// Checks if the drop order for a type matters. Some std types implement drop solely to
 +    /// deallocate memory. For these types, and composites containing them, changing the drop order
 +    /// won't result in any observable side effects.
 +    fn type_needs_ordered_drop<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool {
 +        type_needs_ordered_drop_inner(cx, ty, &mut FxHashSet::default())
 +    }
 +
 +    fn type_needs_ordered_drop_inner<'tcx>(
 +        cx: &LateContext<'tcx>,
 +        ty: Ty<'tcx>,
 +        seen: &mut FxHashSet<Ty<'tcx>>,
 +    ) -> bool {
 +        if !seen.insert(ty) {
 +            return false;
 +        }
 +        if !ty.needs_drop(cx.tcx, cx.param_env) {
 +            false
 +        } else if !cx
 +            .tcx
 +            .lang_items()
 +            .drop_trait()
 +            .map_or(false, |id| implements_trait(cx, ty, id, &[]))
 +        {
 +            // This type doesn't implement drop, so no side effects here.
 +            // Check if any component type has any.
 +            match ty.kind() {
 +                ty::Tuple(_) => ty.tuple_fields().any(|ty| type_needs_ordered_drop_inner(cx, ty, seen)),
 +                ty::Array(ty, _) => type_needs_ordered_drop_inner(cx, ty, seen),
 +                ty::Adt(adt, subs) => adt
 +                    .all_fields()
 +                    .map(|f| f.ty(cx.tcx, subs))
 +                    .any(|ty| type_needs_ordered_drop_inner(cx, ty, seen)),
 +                _ => true,
 +            }
 +        }
 +        // Check for std types which implement drop, but only for memory allocation.
 +        else if is_type_diagnostic_item(cx, ty, sym::Vec)
 +            || is_type_lang_item(cx, ty, LangItem::OwnedBox)
 +            || is_type_diagnostic_item(cx, ty, sym::Rc)
 +            || is_type_diagnostic_item(cx, ty, sym::Arc)
 +            || is_type_diagnostic_item(cx, ty, sym::cstring_type)
 +            || is_type_diagnostic_item(cx, ty, sym::BTreeMap)
 +            || is_type_diagnostic_item(cx, ty, sym::LinkedList)
 +            || match_type(cx, ty, &paths::WEAK_RC)
 +            || match_type(cx, ty, &paths::WEAK_ARC)
 +        {
 +            // Check all of the generic arguments.
 +            if let ty::Adt(_, subs) = ty.kind() {
 +                subs.types().any(|ty| type_needs_ordered_drop_inner(cx, ty, seen))
 +            } else {
 +                true
 +            }
 +        } else {
 +            true
 +        }
 +    }
 +
 +    // Extract the generic arguments out of a type
 +    fn try_get_generic_ty(ty: Ty<'_>, index: usize) -> Option<Ty<'_>> {
 +        if_chain! {
 +            if let ty::Adt(_, subs) = ty.kind();
 +            if let Some(sub) = subs.get(index);
 +            if let GenericArgKind::Type(sub_ty) = sub.unpack();
 +            then {
 +                Some(sub_ty)
 +            } else {
 +                None
 +            }
 +        }
 +    }
 +
 +    // Checks if there are any temporaries created in the given expression for which drop order
 +    // matters.
 +    fn temporaries_need_ordered_drop<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) -> bool {
 +        struct V<'a, 'tcx> {
 +            cx: &'a LateContext<'tcx>,
 +            res: bool,
 +        }
 +        impl<'a, 'tcx> Visitor<'tcx> for V<'a, 'tcx> {
 +            fn visit_expr(&mut self, expr: &'tcx Expr<'tcx>) {
 +                match expr.kind {
 +                    // Taking the reference of a value leaves a temporary
 +                    // e.g. In `&String::new()` the string is a temporary value.
 +                    // Remaining fields are temporary values
 +                    // e.g. In `(String::new(), 0).1` the string is a temporary value.
 +                    ExprKind::AddrOf(_, _, expr) | ExprKind::Field(expr, _) => {
 +                        if !matches!(expr.kind, ExprKind::Path(_)) {
 +                            if type_needs_ordered_drop(self.cx, self.cx.typeck_results().expr_ty(expr)) {
 +                                self.res = true;
 +                            } else {
 +                                self.visit_expr(expr);
 +                            }
 +                        }
 +                    },
 +                    // the base type is alway taken by reference.
 +                    // e.g. In `(vec![0])[0]` the vector is a temporary value.
 +                    ExprKind::Index(base, index) => {
 +                        if !matches!(base.kind, ExprKind::Path(_)) {
 +                            if type_needs_ordered_drop(self.cx, self.cx.typeck_results().expr_ty(base)) {
 +                                self.res = true;
 +                            } else {
 +                                self.visit_expr(base);
 +                            }
 +                        }
 +                        self.visit_expr(index);
 +                    },
 +                    // Method calls can take self by reference.
 +                    // e.g. In `String::new().len()` the string is a temporary value.
 +                    ExprKind::MethodCall(_, [self_arg, args @ ..], _) => {
 +                        if !matches!(self_arg.kind, ExprKind::Path(_)) {
 +                            let self_by_ref = self
 +                                .cx
 +                                .typeck_results()
 +                                .type_dependent_def_id(expr.hir_id)
 +                                .map_or(false, |id| self.cx.tcx.fn_sig(id).skip_binder().inputs()[0].is_ref());
 +                            if self_by_ref
 +                                && type_needs_ordered_drop(self.cx, self.cx.typeck_results().expr_ty(self_arg))
 +                            {
 +                                self.res = true;
 +                            } else {
 +                                self.visit_expr(self_arg);
 +                            }
 +                        }
 +                        args.iter().for_each(|arg| self.visit_expr(arg));
 +                    },
 +                    // Either explicitly drops values, or changes control flow.
 +                    ExprKind::DropTemps(_)
 +                    | ExprKind::Ret(_)
 +                    | ExprKind::Break(..)
 +                    | ExprKind::Yield(..)
 +                    | ExprKind::Block(Block { expr: None, .. }, _)
 +                    | ExprKind::Loop(..) => (),
 +
 +                    // Only consider the final expression.
 +                    ExprKind::Block(Block { expr: Some(expr), .. }, _) => self.visit_expr(expr),
 +
 +                    _ => walk_expr(self, expr),
 +                }
 +            }
 +        }
 +
 +        let mut v = V { cx, res: false };
 +        v.visit_expr(expr);
 +        v.res
 +    }
 +
 +    fn find_sugg_for_if_let<'tcx>(
 +        cx: &LateContext<'tcx>,
 +        expr: &'tcx Expr<'_>,
 +        let_pat: &Pat<'_>,
 +        let_expr: &'tcx Expr<'_>,
 +        keyword: &'static str,
 +        has_else: bool,
 +    ) {
 +        // also look inside refs
 +        let mut kind = &let_pat.kind;
 +        // if we have &None for example, peel it so we can detect "if let None = x"
 +        if let PatKind::Ref(inner, _mutability) = kind {
 +            kind = &inner.kind;
 +        }
 +        let op_ty = cx.typeck_results().expr_ty(let_expr);
 +        // Determine which function should be used, and the type contained by the corresponding
 +        // variant.
 +        let (good_method, inner_ty) = match kind {
 +            PatKind::TupleStruct(ref path, [sub_pat], _) => {
 +                if let PatKind::Wild = sub_pat.kind {
 +                    if is_lang_ctor(cx, path, ResultOk) {
 +                        ("is_ok()", try_get_generic_ty(op_ty, 0).unwrap_or(op_ty))
 +                    } else if is_lang_ctor(cx, path, ResultErr) {
 +                        ("is_err()", try_get_generic_ty(op_ty, 1).unwrap_or(op_ty))
 +                    } else if is_lang_ctor(cx, path, OptionSome) {
 +                        ("is_some()", op_ty)
 +                    } else if is_lang_ctor(cx, path, PollReady) {
 +                        ("is_ready()", op_ty)
 +                    } else if is_qpath_def_path(cx, path, sub_pat.hir_id, &paths::IPADDR_V4) {
 +                        ("is_ipv4()", op_ty)
 +                    } else if is_qpath_def_path(cx, path, sub_pat.hir_id, &paths::IPADDR_V6) {
 +                        ("is_ipv6()", op_ty)
 +                    } else {
 +                        return;
 +                    }
 +                } else {
 +                    return;
 +                }
 +            },
 +            PatKind::Path(ref path) => {
 +                let method = if is_lang_ctor(cx, path, OptionNone) {
 +                    "is_none()"
 +                } else if is_lang_ctor(cx, path, PollPending) {
 +                    "is_pending()"
 +                } else {
 +                    return;
 +                };
 +                // `None` and `Pending` don't have an inner type.
 +                (method, cx.tcx.types.unit)
 +            },
 +            _ => return,
 +        };
 +
 +        // If this is the last expression in a block or there is an else clause then the whole
 +        // type needs to be considered, not just the inner type of the branch being matched on.
 +        // Note the last expression in a block is dropped after all local bindings.
 +        let check_ty = if has_else
 +            || (keyword == "if" && matches!(cx.tcx.hir().parent_iter(expr.hir_id).next(), Some((_, Node::Block(..)))))
 +        {
 +            op_ty
 +        } else {
 +            inner_ty
 +        };
 +
 +        // All temporaries created in the scrutinee expression are dropped at the same time as the
 +        // scrutinee would be, so they have to be considered as well.
 +        // e.g. in `if let Some(x) = foo.lock().unwrap().baz.as_ref() { .. }` the lock will be held
 +        // for the duration if body.
 +        let needs_drop = type_needs_ordered_drop(cx, check_ty) || temporaries_need_ordered_drop(cx, let_expr);
 +
 +        // check that `while_let_on_iterator` lint does not trigger
 +        if_chain! {
 +            if keyword == "while";
 +            if let ExprKind::MethodCall(method_path, _, _) = let_expr.kind;
 +            if method_path.ident.name == sym::next;
 +            if is_trait_method(cx, let_expr, sym::Iterator);
 +            then {
 +                return;
 +            }
 +        }
 +
 +        let result_expr = match &let_expr.kind {
 +            ExprKind::AddrOf(_, _, borrowed) => borrowed,
 +            ExprKind::Unary(UnOp::Deref, deref) => deref,
 +            _ => let_expr,
 +        };
 +
 +        span_lint_and_then(
 +            cx,
 +            REDUNDANT_PATTERN_MATCHING,
 +            let_pat.span,
 +            &format!("redundant pattern matching, consider using `{}`", good_method),
 +            |diag| {
 +                // if/while let ... = ... { ... }
 +                // ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 +                let expr_span = expr.span;
 +
 +                // if/while let ... = ... { ... }
 +                //                 ^^^
 +                let op_span = result_expr.span.source_callsite();
 +
 +                // if/while let ... = ... { ... }
 +                // ^^^^^^^^^^^^^^^^^^^
 +                let span = expr_span.until(op_span.shrink_to_hi());
 +
 +                let app = if needs_drop {
 +                    Applicability::MaybeIncorrect
 +                } else {
 +                    Applicability::MachineApplicable
 +                };
 +
 +                let sugg = Sugg::hir_with_macro_callsite(cx, result_expr, "_")
 +                    .maybe_par()
 +                    .to_string();
 +
 +                diag.span_suggestion(span, "try this", format!("{} {}.{}", keyword, sugg, good_method), app);
 +
 +                if needs_drop {
 +                    diag.note("this will change drop order of the result, as well as all temporaries");
 +                    diag.note("add `#[allow(clippy::redundant_pattern_matching)]` if this is important");
 +                }
 +            },
 +        );
 +    }
 +
 +    fn find_sugg_for_match<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, op: &Expr<'_>, arms: &[Arm<'_>]) {
 +        if arms.len() == 2 {
 +            let node_pair = (&arms[0].pat.kind, &arms[1].pat.kind);
 +
 +            let found_good_method = match node_pair {
 +                (
 +                    PatKind::TupleStruct(ref path_left, patterns_left, _),
 +                    PatKind::TupleStruct(ref path_right, patterns_right, _),
 +                ) if patterns_left.len() == 1 && patterns_right.len() == 1 => {
 +                    if let (PatKind::Wild, PatKind::Wild) = (&patterns_left[0].kind, &patterns_right[0].kind) {
 +                        find_good_method_for_match(
 +                            cx,
 +                            arms,
 +                            path_left,
 +                            path_right,
 +                            &paths::RESULT_OK,
 +                            &paths::RESULT_ERR,
 +                            "is_ok()",
 +                            "is_err()",
 +                        )
 +                        .or_else(|| {
 +                            find_good_method_for_match(
 +                                cx,
 +                                arms,
 +                                path_left,
 +                                path_right,
 +                                &paths::IPADDR_V4,
 +                                &paths::IPADDR_V6,
 +                                "is_ipv4()",
 +                                "is_ipv6()",
 +                            )
 +                        })
 +                    } else {
 +                        None
 +                    }
 +                },
 +                (PatKind::TupleStruct(ref path_left, patterns, _), PatKind::Path(ref path_right))
 +                | (PatKind::Path(ref path_left), PatKind::TupleStruct(ref path_right, patterns, _))
 +                    if patterns.len() == 1 =>
 +                {
 +                    if let PatKind::Wild = patterns[0].kind {
 +                        find_good_method_for_match(
 +                            cx,
 +                            arms,
 +                            path_left,
 +                            path_right,
 +                            &paths::OPTION_SOME,
 +                            &paths::OPTION_NONE,
 +                            "is_some()",
 +                            "is_none()",
 +                        )
 +                        .or_else(|| {
 +                            find_good_method_for_match(
 +                                cx,
 +                                arms,
 +                                path_left,
 +                                path_right,
 +                                &paths::POLL_READY,
 +                                &paths::POLL_PENDING,
 +                                "is_ready()",
 +                                "is_pending()",
 +                            )
 +                        })
 +                    } else {
 +                        None
 +                    }
 +                },
 +                _ => None,
 +            };
 +
 +            if let Some(good_method) = found_good_method {
 +                let span = expr.span.to(op.span);
 +                let result_expr = match &op.kind {
 +                    ExprKind::AddrOf(_, _, borrowed) => borrowed,
 +                    _ => op,
 +                };
 +                span_lint_and_then(
 +                    cx,
 +                    REDUNDANT_PATTERN_MATCHING,
 +                    expr.span,
 +                    &format!("redundant pattern matching, consider using `{}`", good_method),
 +                    |diag| {
 +                        diag.span_suggestion(
 +                            span,
 +                            "try this",
 +                            format!("{}.{}", snippet(cx, result_expr.span, "_"), good_method),
 +                            Applicability::MaybeIncorrect, // snippet
 +                        );
 +                    },
 +                );
 +            }
 +        }
 +    }
 +
 +    #[allow(clippy::too_many_arguments)]
 +    fn find_good_method_for_match<'a>(
 +        cx: &LateContext<'_>,
 +        arms: &[Arm<'_>],
 +        path_left: &QPath<'_>,
 +        path_right: &QPath<'_>,
 +        expected_left: &[&str],
 +        expected_right: &[&str],
 +        should_be_left: &'a str,
 +        should_be_right: &'a str,
 +    ) -> Option<&'a str> {
 +        let body_node_pair = if is_qpath_def_path(cx, path_left, arms[0].pat.hir_id, expected_left)
 +            && is_qpath_def_path(cx, path_right, arms[1].pat.hir_id, expected_right)
 +        {
 +            (&(*arms[0].body).kind, &(*arms[1].body).kind)
 +        } else if is_qpath_def_path(cx, path_right, arms[1].pat.hir_id, expected_left)
 +            && is_qpath_def_path(cx, path_left, arms[0].pat.hir_id, expected_right)
 +        {
 +            (&(*arms[1].body).kind, &(*arms[0].body).kind)
 +        } else {
 +            return None;
 +        };
 +
 +        match body_node_pair {
 +            (ExprKind::Lit(ref lit_left), ExprKind::Lit(ref lit_right)) => match (&lit_left.node, &lit_right.node) {
 +                (LitKind::Bool(true), LitKind::Bool(false)) => Some(should_be_left),
 +                (LitKind::Bool(false), LitKind::Bool(true)) => Some(should_be_right),
 +                _ => None,
 +            },
 +            _ => None,
 +        }
 +    }
 +}
 +
 +#[test]
 +fn test_overlapping() {
 +    use rustc_span::source_map::DUMMY_SP;
 +
 +    let sp = |s, e| SpannedRange {
 +        span: DUMMY_SP,
 +        node: (s, e),
 +    };
 +
 +    assert_eq!(None, overlapping::<u8>(&[]));
 +    assert_eq!(None, overlapping(&[sp(1, EndBound::Included(4))]));
 +    assert_eq!(
 +        None,
 +        overlapping(&[sp(1, EndBound::Included(4)), sp(5, EndBound::Included(6))])
 +    );
 +    assert_eq!(
 +        None,
 +        overlapping(&[
 +            sp(1, EndBound::Included(4)),
 +            sp(5, EndBound::Included(6)),
 +            sp(10, EndBound::Included(11))
 +        ],)
 +    );
 +    assert_eq!(
 +        Some((&sp(1, EndBound::Included(4)), &sp(3, EndBound::Included(6)))),
 +        overlapping(&[sp(1, EndBound::Included(4)), sp(3, EndBound::Included(6))])
 +    );
 +    assert_eq!(
 +        Some((&sp(5, EndBound::Included(6)), &sp(6, EndBound::Included(11)))),
 +        overlapping(&[
 +            sp(1, EndBound::Included(4)),
 +            sp(5, EndBound::Included(6)),
 +            sp(6, EndBound::Included(11))
 +        ],)
 +    );
 +}
 +
 +/// Implementation of `MATCH_SAME_ARMS`.
 +fn lint_match_arms<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'_>) {
 +    if let ExprKind::Match(_, arms, MatchSource::Normal) = expr.kind {
 +        let hash = |&(_, arm): &(usize, &Arm<'_>)| -> u64 {
 +            let mut h = SpanlessHash::new(cx);
 +            h.hash_expr(arm.body);
 +            h.finish()
 +        };
 +
 +        let eq = |&(lindex, lhs): &(usize, &Arm<'_>), &(rindex, rhs): &(usize, &Arm<'_>)| -> bool {
 +            let min_index = usize::min(lindex, rindex);
 +            let max_index = usize::max(lindex, rindex);
 +
 +            let mut local_map: HirIdMap<HirId> = HirIdMap::default();
 +            let eq_fallback = |a: &Expr<'_>, b: &Expr<'_>| {
 +                if_chain! {
 +                    if let Some(a_id) = path_to_local(a);
 +                    if let Some(b_id) = path_to_local(b);
 +                    let entry = match local_map.entry(a_id) {
 +                        Entry::Vacant(entry) => entry,
 +                        // check if using the same bindings as before
 +                        Entry::Occupied(entry) => return *entry.get() == b_id,
 +                    };
 +                    // the names technically don't have to match; this makes the lint more conservative
 +                    if cx.tcx.hir().name(a_id) == cx.tcx.hir().name(b_id);
 +                    if TyS::same_type(cx.typeck_results().expr_ty(a), cx.typeck_results().expr_ty(b));
 +                    if pat_contains_local(lhs.pat, a_id);
 +                    if pat_contains_local(rhs.pat, b_id);
 +                    then {
 +                        entry.insert(b_id);
 +                        true
 +                    } else {
 +                        false
 +                    }
 +                }
 +            };
 +            // Arms with a guard are ignored, those can’t always be merged together
 +            // This is also the case for arms in-between each there is an arm with a guard
 +            (min_index..=max_index).all(|index| arms[index].guard.is_none())
 +                && SpanlessEq::new(cx)
 +                    .expr_fallback(eq_fallback)
 +                    .eq_expr(lhs.body, rhs.body)
 +                // these checks could be removed to allow unused bindings
 +                && bindings_eq(lhs.pat, local_map.keys().copied().collect())
 +                && bindings_eq(rhs.pat, local_map.values().copied().collect())
 +        };
 +
 +        let indexed_arms: Vec<(usize, &Arm<'_>)> = arms.iter().enumerate().collect();
 +        for (&(_, i), &(_, j)) in search_same(&indexed_arms, hash, eq) {
 +            span_lint_and_then(
 +                cx,
 +                MATCH_SAME_ARMS,
 +                j.body.span,
 +                "this `match` has identical arm bodies",
 +                |diag| {
 +                    diag.span_note(i.body.span, "same as this");
 +
 +                    // Note: this does not use `span_suggestion` on purpose:
 +                    // there is no clean way
 +                    // to remove the other arm. Building a span and suggest to replace it to ""
 +                    // makes an even more confusing error message. Also in order not to make up a
 +                    // span for the whole pattern, the suggestion is only shown when there is only
 +                    // one pattern. The user should know about `|` if they are already using it…
 +
 +                    let lhs = snippet(cx, i.pat.span, "<pat1>");
 +                    let rhs = snippet(cx, j.pat.span, "<pat2>");
 +
 +                    if let PatKind::Wild = j.pat.kind {
 +                        // if the last arm is _, then i could be integrated into _
 +                        // note that i.pat cannot be _, because that would mean that we're
 +                        // hiding all the subsequent arms, and rust won't compile
 +                        diag.span_note(
 +                            i.body.span,
 +                            &format!(
 +                                "`{}` has the same arm body as the `_` wildcard, consider removing it",
 +                                lhs
 +                            ),
 +                        );
 +                    } else {
 +                        diag.span_help(i.pat.span, &format!("consider refactoring into `{} | {}`", lhs, rhs,))
 +                            .help("...or consider changing the match arm bodies");
 +                    }
 +                },
 +            );
 +        }
 +    }
 +}
 +
 +fn pat_contains_local(pat: &Pat<'_>, id: HirId) -> bool {
 +    let mut result = false;
 +    pat.walk_short(|p| {
 +        result |= matches!(p.kind, PatKind::Binding(_, binding_id, ..) if binding_id == id);
 +        !result
 +    });
 +    result
 +}
 +
 +/// Returns true if all the bindings in the `Pat` are in `ids` and vice versa
 +fn bindings_eq(pat: &Pat<'_>, mut ids: HirIdSet) -> bool {
 +    let mut result = true;
 +    pat.each_binding_or_first(&mut |_, id, _, _| result &= ids.remove(&id));
 +    result && ids.is_empty()
 +}
index e7d2d550a3032e58af49db5ddf99cc970ab2d4fb,0000000000000000000000000000000000000000..d813edab687e87a47fe08b6dc9fa46ecc00b42a0
mode 100644,000000..100644
--- /dev/null
@@@ -1,173 -1,0 +1,173 @@@
-                         && (method_name.ident.name == sym::as_str || method_name.ident.name == sym!(as_ref))
 +use clippy_utils::diagnostics::span_lint_and_sugg;
 +use clippy_utils::macros::{root_macro_call_first_node, FormatArgsExpn};
 +use clippy_utils::source::snippet_with_applicability;
 +use clippy_utils::ty::is_type_diagnostic_item;
 +use rustc_errors::Applicability;
 +use rustc_hir as hir;
 +use rustc_lint::LateContext;
 +use rustc_middle::ty;
 +use rustc_span::source_map::Span;
 +use rustc_span::symbol::sym;
 +use std::borrow::Cow;
 +
 +use super::EXPECT_FUN_CALL;
 +
 +/// Checks for the `EXPECT_FUN_CALL` lint.
 +#[allow(clippy::too_many_lines)]
 +pub(super) fn check<'tcx>(
 +    cx: &LateContext<'tcx>,
 +    expr: &hir::Expr<'_>,
 +    method_span: Span,
 +    name: &str,
 +    args: &'tcx [hir::Expr<'tcx>],
 +) {
 +    // Strip `&`, `as_ref()` and `as_str()` off `arg` until we're left with either a `String` or
 +    // `&str`
 +    fn get_arg_root<'a>(cx: &LateContext<'_>, arg: &'a hir::Expr<'a>) -> &'a hir::Expr<'a> {
 +        let mut arg_root = arg;
 +        loop {
 +            arg_root = match &arg_root.kind {
 +                hir::ExprKind::AddrOf(hir::BorrowKind::Ref, _, expr) => expr,
 +                hir::ExprKind::MethodCall(method_name, call_args, _) => {
 +                    if call_args.len() == 1
++                        && (method_name.ident.name == sym::as_str || method_name.ident.name == sym::as_ref)
 +                        && {
 +                            let arg_type = cx.typeck_results().expr_ty(&call_args[0]);
 +                            let base_type = arg_type.peel_refs();
 +                            *base_type.kind() == ty::Str || is_type_diagnostic_item(cx, base_type, sym::String)
 +                        }
 +                    {
 +                        &call_args[0]
 +                    } else {
 +                        break;
 +                    }
 +                },
 +                _ => break,
 +            };
 +        }
 +        arg_root
 +    }
 +
 +    // Only `&'static str` or `String` can be used directly in the `panic!`. Other types should be
 +    // converted to string.
 +    fn requires_to_string(cx: &LateContext<'_>, arg: &hir::Expr<'_>) -> bool {
 +        let arg_ty = cx.typeck_results().expr_ty(arg);
 +        if is_type_diagnostic_item(cx, arg_ty, sym::String) {
 +            return false;
 +        }
 +        if let ty::Ref(_, ty, ..) = arg_ty.kind() {
 +            if *ty.kind() == ty::Str && can_be_static_str(cx, arg) {
 +                return false;
 +            }
 +        };
 +        true
 +    }
 +
 +    // Check if an expression could have type `&'static str`, knowing that it
 +    // has type `&str` for some lifetime.
 +    fn can_be_static_str(cx: &LateContext<'_>, arg: &hir::Expr<'_>) -> bool {
 +        match arg.kind {
 +            hir::ExprKind::Lit(_) => true,
 +            hir::ExprKind::Call(fun, _) => {
 +                if let hir::ExprKind::Path(ref p) = fun.kind {
 +                    match cx.qpath_res(p, fun.hir_id) {
 +                        hir::def::Res::Def(hir::def::DefKind::Fn | hir::def::DefKind::AssocFn, def_id) => matches!(
 +                            cx.tcx.fn_sig(def_id).output().skip_binder().kind(),
 +                            ty::Ref(ty::ReStatic, ..)
 +                        ),
 +                        _ => false,
 +                    }
 +                } else {
 +                    false
 +                }
 +            },
 +            hir::ExprKind::MethodCall(..) => {
 +                cx.typeck_results()
 +                    .type_dependent_def_id(arg.hir_id)
 +                    .map_or(false, |method_id| {
 +                        matches!(
 +                            cx.tcx.fn_sig(method_id).output().skip_binder().kind(),
 +                            ty::Ref(ty::ReStatic, ..)
 +                        )
 +                    })
 +            },
 +            hir::ExprKind::Path(ref p) => matches!(
 +                cx.qpath_res(p, arg.hir_id),
 +                hir::def::Res::Def(hir::def::DefKind::Const | hir::def::DefKind::Static, _)
 +            ),
 +            _ => false,
 +        }
 +    }
 +
 +    fn is_call(node: &hir::ExprKind<'_>) -> bool {
 +        match node {
 +            hir::ExprKind::AddrOf(hir::BorrowKind::Ref, _, expr) => {
 +                is_call(&expr.kind)
 +            },
 +            hir::ExprKind::Call(..)
 +            | hir::ExprKind::MethodCall(..)
 +            // These variants are debatable or require further examination
 +            | hir::ExprKind::If(..)
 +            | hir::ExprKind::Match(..)
 +            | hir::ExprKind::Block{ .. } => true,
 +            _ => false,
 +        }
 +    }
 +
 +    if args.len() != 2 || name != "expect" || !is_call(&args[1].kind) {
 +        return;
 +    }
 +
 +    let receiver_type = cx.typeck_results().expr_ty_adjusted(&args[0]);
 +    let closure_args = if is_type_diagnostic_item(cx, receiver_type, sym::Option) {
 +        "||"
 +    } else if is_type_diagnostic_item(cx, receiver_type, sym::Result) {
 +        "|_|"
 +    } else {
 +        return;
 +    };
 +
 +    let arg_root = get_arg_root(cx, &args[1]);
 +
 +    let span_replace_word = method_span.with_hi(expr.span.hi());
 +
 +    let mut applicability = Applicability::MachineApplicable;
 +
 +    //Special handling for `format!` as arg_root
 +    if let Some(macro_call) = root_macro_call_first_node(cx, arg_root) {
 +        if !cx.tcx.is_diagnostic_item(sym::format_macro, macro_call.def_id) {
 +            return;
 +        }
 +        let Some(format_args) = FormatArgsExpn::find_nested(cx, arg_root, macro_call.expn) else { return };
 +        let span = format_args.inputs_span();
 +        let sugg = snippet_with_applicability(cx, span, "..", &mut applicability);
 +        span_lint_and_sugg(
 +            cx,
 +            EXPECT_FUN_CALL,
 +            span_replace_word,
 +            &format!("use of `{}` followed by a function call", name),
 +            "try this",
 +            format!("unwrap_or_else({} panic!({}))", closure_args, sugg),
 +            applicability,
 +        );
 +        return;
 +    }
 +
 +    let mut arg_root_snippet: Cow<'_, _> = snippet_with_applicability(cx, arg_root.span, "..", &mut applicability);
 +    if requires_to_string(cx, arg_root) {
 +        arg_root_snippet.to_mut().push_str(".to_string()");
 +    }
 +
 +    span_lint_and_sugg(
 +        cx,
 +        EXPECT_FUN_CALL,
 +        span_replace_word,
 +        &format!("use of `{}` followed by a function call", name),
 +        "try this",
 +        format!(
 +            "unwrap_or_else({} {{ panic!(\"{{}}\", {}) }})",
 +            closure_args, arg_root_snippet
 +        ),
 +        applicability,
 +    );
 +}
index 137c9628eb45c930c230abc341f0f7efe2e8d1fa,0000000000000000000000000000000000000000..4b43448bf7b98a39f30d39ca9e1e76097e03f6ed
mode 100644,000000..100644
--- /dev/null
@@@ -1,2652 -1,0 +1,2652 @@@
-                           ty::Term::Ty(ty) => ty,
-                           ty::Term::Const(_c) => continue,
 +mod bind_instead_of_map;
 +mod bytes_nth;
 +mod chars_cmp;
 +mod chars_cmp_with_unwrap;
 +mod chars_last_cmp;
 +mod chars_last_cmp_with_unwrap;
 +mod chars_next_cmp;
 +mod chars_next_cmp_with_unwrap;
 +mod clone_on_copy;
 +mod clone_on_ref_ptr;
 +mod cloned_instead_of_copied;
 +mod expect_fun_call;
 +mod expect_used;
 +mod extend_with_drain;
 +mod filetype_is_file;
 +mod filter_map;
 +mod filter_map_identity;
 +mod filter_map_next;
 +mod filter_next;
 +mod flat_map_identity;
 +mod flat_map_option;
 +mod from_iter_instead_of_collect;
 +mod get_unwrap;
 +mod implicit_clone;
 +mod inefficient_to_string;
 +mod inspect_for_each;
 +mod into_iter_on_ref;
 +mod iter_cloned_collect;
 +mod iter_count;
 +mod iter_next_slice;
 +mod iter_nth;
 +mod iter_nth_zero;
 +mod iter_overeager_cloned;
 +mod iter_skip_next;
 +mod iterator_step_by_zero;
 +mod manual_saturating_arithmetic;
 +mod manual_str_repeat;
 +mod map_collect_result_unit;
 +mod map_flatten;
 +mod map_identity;
 +mod map_unwrap_or;
 +mod ok_expect;
 +mod option_as_ref_deref;
 +mod option_map_or_none;
 +mod option_map_unwrap_or;
 +mod or_fun_call;
 +mod search_is_some;
 +mod single_char_add_str;
 +mod single_char_insert_string;
 +mod single_char_pattern;
 +mod single_char_push_string;
 +mod skip_while_next;
 +mod str_splitn;
 +mod string_extend_chars;
 +mod suspicious_map;
 +mod suspicious_splitn;
 +mod uninit_assumed_init;
 +mod unnecessary_filter_map;
 +mod unnecessary_fold;
 +mod unnecessary_iter_cloned;
 +mod unnecessary_lazy_eval;
 +mod unnecessary_to_owned;
 +mod unwrap_or_else_default;
 +mod unwrap_used;
 +mod useless_asref;
 +mod utils;
 +mod wrong_self_convention;
 +mod zst_offset;
 +
 +use bind_instead_of_map::BindInsteadOfMap;
 +use clippy_utils::consts::{constant, Constant};
 +use clippy_utils::diagnostics::{span_lint, span_lint_and_help};
 +use clippy_utils::ty::{contains_adt_constructor, contains_ty, implements_trait, is_copy, is_type_diagnostic_item};
 +use clippy_utils::{contains_return, get_trait_def_id, iter_input_pats, meets_msrv, msrvs, paths, return_ty};
 +use if_chain::if_chain;
 +use rustc_hir as hir;
 +use rustc_hir::def::Res;
 +use rustc_hir::{Expr, ExprKind, PrimTy, QPath, TraitItem, TraitItemKind};
 +use rustc_lint::{LateContext, LateLintPass, LintContext};
 +use rustc_middle::lint::in_external_macro;
 +use rustc_middle::ty::{self, TraitRef, Ty, TyS};
 +use rustc_semver::RustcVersion;
 +use rustc_session::{declare_tool_lint, impl_lint_pass};
 +use rustc_span::{sym, Span};
 +use rustc_typeck::hir_ty_to_ty;
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for usages of `cloned()` on an `Iterator` or `Option` where
 +    /// `copied()` could be used instead.
 +    ///
 +    /// ### Why is this bad?
 +    /// `copied()` is better because it guarantees that the type being cloned
 +    /// implements `Copy`.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// [1, 2, 3].iter().cloned();
 +    /// ```
 +    /// Use instead:
 +    /// ```rust
 +    /// [1, 2, 3].iter().copied();
 +    /// ```
 +    #[clippy::version = "1.53.0"]
 +    pub CLONED_INSTEAD_OF_COPIED,
 +    pedantic,
 +    "used `cloned` where `copied` could be used instead"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for usage of `_.cloned().<func>()` where call to `.cloned()` can be postponed.
 +    ///
 +    /// ### Why is this bad?
 +    /// It's often inefficient to clone all elements of an iterator, when eventually, only some
 +    /// of them will be consumed.
 +    ///
 +    /// ### Examples
 +    /// ```rust
 +    /// # let vec = vec!["string".to_string()];
 +    ///
 +    /// // Bad
 +    /// vec.iter().cloned().take(10);
 +    ///
 +    /// // Good
 +    /// vec.iter().take(10).cloned();
 +    ///
 +    /// // Bad
 +    /// vec.iter().cloned().last();
 +    ///
 +    /// // Good
 +    /// vec.iter().last().cloned();
 +    ///
 +    /// ```
 +    /// ### Known Problems
 +    /// This `lint` removes the side of effect of cloning items in the iterator.
 +    /// A code that relies on that side-effect could fail.
 +    ///
 +    #[clippy::version = "1.59.0"]
 +    pub ITER_OVEREAGER_CLONED,
 +    perf,
 +    "using `cloned()` early with `Iterator::iter()` can lead to some performance inefficiencies"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for usages of `Iterator::flat_map()` where `filter_map()` could be
 +    /// used instead.
 +    ///
 +    /// ### Why is this bad?
 +    /// When applicable, `filter_map()` is more clear since it shows that
 +    /// `Option` is used to produce 0 or 1 items.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// let nums: Vec<i32> = ["1", "2", "whee!"].iter().flat_map(|x| x.parse().ok()).collect();
 +    /// ```
 +    /// Use instead:
 +    /// ```rust
 +    /// let nums: Vec<i32> = ["1", "2", "whee!"].iter().filter_map(|x| x.parse().ok()).collect();
 +    /// ```
 +    #[clippy::version = "1.53.0"]
 +    pub FLAT_MAP_OPTION,
 +    pedantic,
 +    "used `flat_map` where `filter_map` could be used instead"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for `.unwrap()` calls on `Option`s and on `Result`s.
 +    ///
 +    /// ### Why is this bad?
 +    /// It is better to handle the `None` or `Err` case,
 +    /// or at least call `.expect(_)` with a more helpful message. Still, for a lot of
 +    /// quick-and-dirty code, `unwrap` is a good choice, which is why this lint is
 +    /// `Allow` by default.
 +    ///
 +    /// `result.unwrap()` will let the thread panic on `Err` values.
 +    /// Normally, you want to implement more sophisticated error handling,
 +    /// and propagate errors upwards with `?` operator.
 +    ///
 +    /// Even if you want to panic on errors, not all `Error`s implement good
 +    /// messages on display. Therefore, it may be beneficial to look at the places
 +    /// where they may get displayed. Activate this lint to do just that.
 +    ///
 +    /// ### Examples
 +    /// ```rust
 +    /// # let opt = Some(1);
 +    ///
 +    /// // Bad
 +    /// opt.unwrap();
 +    ///
 +    /// // Good
 +    /// opt.expect("more helpful message");
 +    /// ```
 +    ///
 +    /// // or
 +    ///
 +    /// ```rust
 +    /// # let res: Result<usize, ()> = Ok(1);
 +    ///
 +    /// // Bad
 +    /// res.unwrap();
 +    ///
 +    /// // Good
 +    /// res.expect("more helpful message");
 +    /// ```
 +    #[clippy::version = "1.45.0"]
 +    pub UNWRAP_USED,
 +    restriction,
 +    "using `.unwrap()` on `Result` or `Option`, which should at least get a better message using `expect()`"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for `.expect()` calls on `Option`s and `Result`s.
 +    ///
 +    /// ### Why is this bad?
 +    /// Usually it is better to handle the `None` or `Err` case.
 +    /// Still, for a lot of quick-and-dirty code, `expect` is a good choice, which is why
 +    /// this lint is `Allow` by default.
 +    ///
 +    /// `result.expect()` will let the thread panic on `Err`
 +    /// values. Normally, you want to implement more sophisticated error handling,
 +    /// and propagate errors upwards with `?` operator.
 +    ///
 +    /// ### Examples
 +    /// ```rust,ignore
 +    /// # let opt = Some(1);
 +    ///
 +    /// // Bad
 +    /// opt.expect("one");
 +    ///
 +    /// // Good
 +    /// let opt = Some(1);
 +    /// opt?;
 +    /// ```
 +    ///
 +    /// // or
 +    ///
 +    /// ```rust
 +    /// # let res: Result<usize, ()> = Ok(1);
 +    ///
 +    /// // Bad
 +    /// res.expect("one");
 +    ///
 +    /// // Good
 +    /// res?;
 +    /// # Ok::<(), ()>(())
 +    /// ```
 +    #[clippy::version = "1.45.0"]
 +    pub EXPECT_USED,
 +    restriction,
 +    "using `.expect()` on `Result` or `Option`, which might be better handled"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for methods that should live in a trait
 +    /// implementation of a `std` trait (see [llogiq's blog
 +    /// post](http://llogiq.github.io/2015/07/30/traits.html) for further
 +    /// information) instead of an inherent implementation.
 +    ///
 +    /// ### Why is this bad?
 +    /// Implementing the traits improve ergonomics for users of
 +    /// the code, often with very little cost. Also people seeing a `mul(...)`
 +    /// method
 +    /// may expect `*` to work equally, so you should have good reason to disappoint
 +    /// them.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// struct X;
 +    /// impl X {
 +    ///     fn add(&self, other: &X) -> X {
 +    ///         // ..
 +    /// # X
 +    ///     }
 +    /// }
 +    /// ```
 +    #[clippy::version = "pre 1.29.0"]
 +    pub SHOULD_IMPLEMENT_TRAIT,
 +    style,
 +    "defining a method that should be implementing a std trait"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for methods with certain name prefixes and which
 +    /// doesn't match how self is taken. The actual rules are:
 +    ///
 +    /// |Prefix |Postfix     |`self` taken           | `self` type  |
 +    /// |-------|------------|-----------------------|--------------|
 +    /// |`as_`  | none       |`&self` or `&mut self` | any          |
 +    /// |`from_`| none       | none                  | any          |
 +    /// |`into_`| none       |`self`                 | any          |
 +    /// |`is_`  | none       |`&self` or none        | any          |
 +    /// |`to_`  | `_mut`     |`&mut self`            | any          |
 +    /// |`to_`  | not `_mut` |`self`                 | `Copy`       |
 +    /// |`to_`  | not `_mut` |`&self`                | not `Copy`   |
 +    ///
 +    /// Note: Clippy doesn't trigger methods with `to_` prefix in:
 +    /// - Traits definition.
 +    /// Clippy can not tell if a type that implements a trait is `Copy` or not.
 +    /// - Traits implementation, when `&self` is taken.
 +    /// The method signature is controlled by the trait and often `&self` is required for all types that implement the trait
 +    /// (see e.g. the `std::string::ToString` trait).
 +    ///
 +    /// Clippy allows `Pin<&Self>` and `Pin<&mut Self>` if `&self` and `&mut self` is required.
 +    ///
 +    /// Please find more info here:
 +    /// https://rust-lang.github.io/api-guidelines/naming.html#ad-hoc-conversions-follow-as_-to_-into_-conventions-c-conv
 +    ///
 +    /// ### Why is this bad?
 +    /// Consistency breeds readability. If you follow the
 +    /// conventions, your users won't be surprised that they, e.g., need to supply a
 +    /// mutable reference to a `as_..` function.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// # struct X;
 +    /// impl X {
 +    ///     fn as_str(self) -> &'static str {
 +    ///         // ..
 +    /// # ""
 +    ///     }
 +    /// }
 +    /// ```
 +    #[clippy::version = "pre 1.29.0"]
 +    pub WRONG_SELF_CONVENTION,
 +    style,
 +    "defining a method named with an established prefix (like \"into_\") that takes `self` with the wrong convention"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for usage of `ok().expect(..)`.
 +    ///
 +    /// ### Why is this bad?
 +    /// Because you usually call `expect()` on the `Result`
 +    /// directly to get a better error message.
 +    ///
 +    /// ### Known problems
 +    /// The error type needs to implement `Debug`
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// # let x = Ok::<_, ()>(());
 +    ///
 +    /// // Bad
 +    /// x.ok().expect("why did I do this again?");
 +    ///
 +    /// // Good
 +    /// x.expect("why did I do this again?");
 +    /// ```
 +    #[clippy::version = "pre 1.29.0"]
 +    pub OK_EXPECT,
 +    style,
 +    "using `ok().expect()`, which gives worse error messages than calling `expect` directly on the Result"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for usages of `_.unwrap_or_else(Default::default)` on `Option` and
 +    /// `Result` values.
 +    ///
 +    /// ### Why is this bad?
 +    /// Readability, these can be written as `_.unwrap_or_default`, which is
 +    /// simpler and more concise.
 +    ///
 +    /// ### Examples
 +    /// ```rust
 +    /// # let x = Some(1);
 +    ///
 +    /// // Bad
 +    /// x.unwrap_or_else(Default::default);
 +    /// x.unwrap_or_else(u32::default);
 +    ///
 +    /// // Good
 +    /// x.unwrap_or_default();
 +    /// ```
 +    #[clippy::version = "1.56.0"]
 +    pub UNWRAP_OR_ELSE_DEFAULT,
 +    style,
 +    "using `.unwrap_or_else(Default::default)`, which is more succinctly expressed as `.unwrap_or_default()`"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for usage of `option.map(_).unwrap_or(_)` or `option.map(_).unwrap_or_else(_)` or
 +    /// `result.map(_).unwrap_or_else(_)`.
 +    ///
 +    /// ### Why is this bad?
 +    /// Readability, these can be written more concisely (resp.) as
 +    /// `option.map_or(_, _)`, `option.map_or_else(_, _)` and `result.map_or_else(_, _)`.
 +    ///
 +    /// ### Known problems
 +    /// The order of the arguments is not in execution order
 +    ///
 +    /// ### Examples
 +    /// ```rust
 +    /// # let x = Some(1);
 +    ///
 +    /// // Bad
 +    /// x.map(|a| a + 1).unwrap_or(0);
 +    ///
 +    /// // Good
 +    /// x.map_or(0, |a| a + 1);
 +    /// ```
 +    ///
 +    /// // or
 +    ///
 +    /// ```rust
 +    /// # let x: Result<usize, ()> = Ok(1);
 +    /// # fn some_function(foo: ()) -> usize { 1 }
 +    ///
 +    /// // Bad
 +    /// x.map(|a| a + 1).unwrap_or_else(some_function);
 +    ///
 +    /// // Good
 +    /// x.map_or_else(some_function, |a| a + 1);
 +    /// ```
 +    #[clippy::version = "1.45.0"]
 +    pub MAP_UNWRAP_OR,
 +    pedantic,
 +    "using `.map(f).unwrap_or(a)` or `.map(f).unwrap_or_else(func)`, which are more succinctly expressed as `map_or(a, f)` or `map_or_else(a, f)`"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for usage of `_.map_or(None, _)`.
 +    ///
 +    /// ### Why is this bad?
 +    /// Readability, this can be written more concisely as
 +    /// `_.and_then(_)`.
 +    ///
 +    /// ### Known problems
 +    /// The order of the arguments is not in execution order.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// # let opt = Some(1);
 +    ///
 +    /// // Bad
 +    /// opt.map_or(None, |a| Some(a + 1));
 +    ///
 +    /// // Good
 +    /// opt.and_then(|a| Some(a + 1));
 +    /// ```
 +    #[clippy::version = "pre 1.29.0"]
 +    pub OPTION_MAP_OR_NONE,
 +    style,
 +    "using `Option.map_or(None, f)`, which is more succinctly expressed as `and_then(f)`"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for usage of `_.map_or(None, Some)`.
 +    ///
 +    /// ### Why is this bad?
 +    /// Readability, this can be written more concisely as
 +    /// `_.ok()`.
 +    ///
 +    /// ### Example
 +    /// Bad:
 +    /// ```rust
 +    /// # let r: Result<u32, &str> = Ok(1);
 +    /// assert_eq!(Some(1), r.map_or(None, Some));
 +    /// ```
 +    ///
 +    /// Good:
 +    /// ```rust
 +    /// # let r: Result<u32, &str> = Ok(1);
 +    /// assert_eq!(Some(1), r.ok());
 +    /// ```
 +    #[clippy::version = "1.44.0"]
 +    pub RESULT_MAP_OR_INTO_OPTION,
 +    style,
 +    "using `Result.map_or(None, Some)`, which is more succinctly expressed as `ok()`"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for usage of `_.and_then(|x| Some(y))`, `_.and_then(|x| Ok(y))` or
 +    /// `_.or_else(|x| Err(y))`.
 +    ///
 +    /// ### Why is this bad?
 +    /// Readability, this can be written more concisely as
 +    /// `_.map(|x| y)` or `_.map_err(|x| y)`.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// # fn opt() -> Option<&'static str> { Some("42") }
 +    /// # fn res() -> Result<&'static str, &'static str> { Ok("42") }
 +    /// let _ = opt().and_then(|s| Some(s.len()));
 +    /// let _ = res().and_then(|s| if s.len() == 42 { Ok(10) } else { Ok(20) });
 +    /// let _ = res().or_else(|s| if s.len() == 42 { Err(10) } else { Err(20) });
 +    /// ```
 +    ///
 +    /// The correct use would be:
 +    ///
 +    /// ```rust
 +    /// # fn opt() -> Option<&'static str> { Some("42") }
 +    /// # fn res() -> Result<&'static str, &'static str> { Ok("42") }
 +    /// let _ = opt().map(|s| s.len());
 +    /// let _ = res().map(|s| if s.len() == 42 { 10 } else { 20 });
 +    /// let _ = res().map_err(|s| if s.len() == 42 { 10 } else { 20 });
 +    /// ```
 +    #[clippy::version = "1.45.0"]
 +    pub BIND_INSTEAD_OF_MAP,
 +    complexity,
 +    "using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)`"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for usage of `_.filter(_).next()`.
 +    ///
 +    /// ### Why is this bad?
 +    /// Readability, this can be written more concisely as
 +    /// `_.find(_)`.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// # let vec = vec![1];
 +    /// vec.iter().filter(|x| **x == 0).next();
 +    /// ```
 +    /// Could be written as
 +    /// ```rust
 +    /// # let vec = vec![1];
 +    /// vec.iter().find(|x| **x == 0);
 +    /// ```
 +    #[clippy::version = "pre 1.29.0"]
 +    pub FILTER_NEXT,
 +    complexity,
 +    "using `filter(p).next()`, which is more succinctly expressed as `.find(p)`"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for usage of `_.skip_while(condition).next()`.
 +    ///
 +    /// ### Why is this bad?
 +    /// Readability, this can be written more concisely as
 +    /// `_.find(!condition)`.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// # let vec = vec![1];
 +    /// vec.iter().skip_while(|x| **x == 0).next();
 +    /// ```
 +    /// Could be written as
 +    /// ```rust
 +    /// # let vec = vec![1];
 +    /// vec.iter().find(|x| **x != 0);
 +    /// ```
 +    #[clippy::version = "1.42.0"]
 +    pub SKIP_WHILE_NEXT,
 +    complexity,
 +    "using `skip_while(p).next()`, which is more succinctly expressed as `.find(!p)`"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for usage of `_.map(_).flatten(_)` on `Iterator` and `Option`
 +    ///
 +    /// ### Why is this bad?
 +    /// Readability, this can be written more concisely as
 +    /// `_.flat_map(_)`
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// let vec = vec![vec![1]];
 +    ///
 +    /// // Bad
 +    /// vec.iter().map(|x| x.iter()).flatten();
 +    ///
 +    /// // Good
 +    /// vec.iter().flat_map(|x| x.iter());
 +    /// ```
 +    #[clippy::version = "1.31.0"]
 +    pub MAP_FLATTEN,
 +    complexity,
 +    "using combinations of `flatten` and `map` which can usually be written as a single method call"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for usage of `_.filter(_).map(_)` that can be written more simply
 +    /// as `filter_map(_)`.
 +    ///
 +    /// ### Why is this bad?
 +    /// Redundant code in the `filter` and `map` operations is poor style and
 +    /// less performant.
 +    ///
 +     /// ### Example
 +    /// Bad:
 +    /// ```rust
 +    /// (0_i32..10)
 +    ///     .filter(|n| n.checked_add(1).is_some())
 +    ///     .map(|n| n.checked_add(1).unwrap());
 +    /// ```
 +    ///
 +    /// Good:
 +    /// ```rust
 +    /// (0_i32..10).filter_map(|n| n.checked_add(1));
 +    /// ```
 +    #[clippy::version = "1.51.0"]
 +    pub MANUAL_FILTER_MAP,
 +    complexity,
 +    "using `_.filter(_).map(_)` in a way that can be written more simply as `filter_map(_)`"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for usage of `_.find(_).map(_)` that can be written more simply
 +    /// as `find_map(_)`.
 +    ///
 +    /// ### Why is this bad?
 +    /// Redundant code in the `find` and `map` operations is poor style and
 +    /// less performant.
 +    ///
 +     /// ### Example
 +    /// Bad:
 +    /// ```rust
 +    /// (0_i32..10)
 +    ///     .find(|n| n.checked_add(1).is_some())
 +    ///     .map(|n| n.checked_add(1).unwrap());
 +    /// ```
 +    ///
 +    /// Good:
 +    /// ```rust
 +    /// (0_i32..10).find_map(|n| n.checked_add(1));
 +    /// ```
 +    #[clippy::version = "1.51.0"]
 +    pub MANUAL_FIND_MAP,
 +    complexity,
 +    "using `_.find(_).map(_)` in a way that can be written more simply as `find_map(_)`"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for usage of `_.filter_map(_).next()`.
 +    ///
 +    /// ### Why is this bad?
 +    /// Readability, this can be written more concisely as
 +    /// `_.find_map(_)`.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    ///  (0..3).filter_map(|x| if x == 2 { Some(x) } else { None }).next();
 +    /// ```
 +    /// Can be written as
 +    ///
 +    /// ```rust
 +    ///  (0..3).find_map(|x| if x == 2 { Some(x) } else { None });
 +    /// ```
 +    #[clippy::version = "1.36.0"]
 +    pub FILTER_MAP_NEXT,
 +    pedantic,
 +    "using combination of `filter_map` and `next` which can usually be written as a single method call"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for usage of `flat_map(|x| x)`.
 +    ///
 +    /// ### Why is this bad?
 +    /// Readability, this can be written more concisely by using `flatten`.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// # let iter = vec![vec![0]].into_iter();
 +    /// iter.flat_map(|x| x);
 +    /// ```
 +    /// Can be written as
 +    /// ```rust
 +    /// # let iter = vec![vec![0]].into_iter();
 +    /// iter.flatten();
 +    /// ```
 +    #[clippy::version = "1.39.0"]
 +    pub FLAT_MAP_IDENTITY,
 +    complexity,
 +    "call to `flat_map` where `flatten` is sufficient"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for an iterator or string search (such as `find()`,
 +    /// `position()`, or `rposition()`) followed by a call to `is_some()` or `is_none()`.
 +    ///
 +    /// ### Why is this bad?
 +    /// Readability, this can be written more concisely as:
 +    /// * `_.any(_)`, or `_.contains(_)` for `is_some()`,
 +    /// * `!_.any(_)`, or `!_.contains(_)` for `is_none()`.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// let vec = vec![1];
 +    /// vec.iter().find(|x| **x == 0).is_some();
 +    ///
 +    /// let _ = "hello world".find("world").is_none();
 +    /// ```
 +    /// Could be written as
 +    /// ```rust
 +    /// let vec = vec![1];
 +    /// vec.iter().any(|x| *x == 0);
 +    ///
 +    /// let _ = !"hello world".contains("world");
 +    /// ```
 +    #[clippy::version = "pre 1.29.0"]
 +    pub SEARCH_IS_SOME,
 +    complexity,
 +    "using an iterator or string search followed by `is_some()` or `is_none()`, which is more succinctly expressed as a call to `any()` or `contains()` (with negation in case of `is_none()`)"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for usage of `.chars().next()` on a `str` to check
 +    /// if it starts with a given char.
 +    ///
 +    /// ### Why is this bad?
 +    /// Readability, this can be written more concisely as
 +    /// `_.starts_with(_)`.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// let name = "foo";
 +    /// if name.chars().next() == Some('_') {};
 +    /// ```
 +    /// Could be written as
 +    /// ```rust
 +    /// let name = "foo";
 +    /// if name.starts_with('_') {};
 +    /// ```
 +    #[clippy::version = "pre 1.29.0"]
 +    pub CHARS_NEXT_CMP,
 +    style,
 +    "using `.chars().next()` to check if a string starts with a char"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for calls to `.or(foo(..))`, `.unwrap_or(foo(..))`,
 +    /// etc., and suggests to use `or_else`, `unwrap_or_else`, etc., or
 +    /// `unwrap_or_default` instead.
 +    ///
 +    /// ### Why is this bad?
 +    /// The function will always be called and potentially
 +    /// allocate an object acting as the default.
 +    ///
 +    /// ### Known problems
 +    /// If the function has side-effects, not calling it will
 +    /// change the semantic of the program, but you shouldn't rely on that anyway.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// # let foo = Some(String::new());
 +    /// foo.unwrap_or(String::new());
 +    /// ```
 +    /// this can instead be written:
 +    /// ```rust
 +    /// # let foo = Some(String::new());
 +    /// foo.unwrap_or_else(String::new);
 +    /// ```
 +    /// or
 +    /// ```rust
 +    /// # let foo = Some(String::new());
 +    /// foo.unwrap_or_default();
 +    /// ```
 +    #[clippy::version = "pre 1.29.0"]
 +    pub OR_FUN_CALL,
 +    perf,
 +    "using any `*or` method with a function call, which suggests `*or_else`"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for calls to `.expect(&format!(...))`, `.expect(foo(..))`,
 +    /// etc., and suggests to use `unwrap_or_else` instead
 +    ///
 +    /// ### Why is this bad?
 +    /// The function will always be called.
 +    ///
 +    /// ### Known problems
 +    /// If the function has side-effects, not calling it will
 +    /// change the semantics of the program, but you shouldn't rely on that anyway.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// # let foo = Some(String::new());
 +    /// # let err_code = "418";
 +    /// # let err_msg = "I'm a teapot";
 +    /// foo.expect(&format!("Err {}: {}", err_code, err_msg));
 +    /// ```
 +    /// or
 +    /// ```rust
 +    /// # let foo = Some(String::new());
 +    /// # let err_code = "418";
 +    /// # let err_msg = "I'm a teapot";
 +    /// foo.expect(format!("Err {}: {}", err_code, err_msg).as_str());
 +    /// ```
 +    /// this can instead be written:
 +    /// ```rust
 +    /// # let foo = Some(String::new());
 +    /// # let err_code = "418";
 +    /// # let err_msg = "I'm a teapot";
 +    /// foo.unwrap_or_else(|| panic!("Err {}: {}", err_code, err_msg));
 +    /// ```
 +    #[clippy::version = "pre 1.29.0"]
 +    pub EXPECT_FUN_CALL,
 +    perf,
 +    "using any `expect` method with a function call"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for usage of `.clone()` on a `Copy` type.
 +    ///
 +    /// ### Why is this bad?
 +    /// The only reason `Copy` types implement `Clone` is for
 +    /// generics, not for using the `clone` method on a concrete type.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// 42u64.clone();
 +    /// ```
 +    #[clippy::version = "pre 1.29.0"]
 +    pub CLONE_ON_COPY,
 +    complexity,
 +    "using `clone` on a `Copy` type"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for usage of `.clone()` on a ref-counted pointer,
 +    /// (`Rc`, `Arc`, `rc::Weak`, or `sync::Weak`), and suggests calling Clone via unified
 +    /// function syntax instead (e.g., `Rc::clone(foo)`).
 +    ///
 +    /// ### Why is this bad?
 +    /// Calling '.clone()' on an Rc, Arc, or Weak
 +    /// can obscure the fact that only the pointer is being cloned, not the underlying
 +    /// data.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// # use std::rc::Rc;
 +    /// let x = Rc::new(1);
 +    ///
 +    /// // Bad
 +    /// x.clone();
 +    ///
 +    /// // Good
 +    /// Rc::clone(&x);
 +    /// ```
 +    #[clippy::version = "pre 1.29.0"]
 +    pub CLONE_ON_REF_PTR,
 +    restriction,
 +    "using 'clone' on a ref-counted pointer"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for usage of `.clone()` on an `&&T`.
 +    ///
 +    /// ### Why is this bad?
 +    /// Cloning an `&&T` copies the inner `&T`, instead of
 +    /// cloning the underlying `T`.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// fn main() {
 +    ///     let x = vec![1];
 +    ///     let y = &&x;
 +    ///     let z = y.clone();
 +    ///     println!("{:p} {:p}", *y, z); // prints out the same pointer
 +    /// }
 +    /// ```
 +    #[clippy::version = "pre 1.29.0"]
 +    pub CLONE_DOUBLE_REF,
 +    correctness,
 +    "using `clone` on `&&T`"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for usage of `.to_string()` on an `&&T` where
 +    /// `T` implements `ToString` directly (like `&&str` or `&&String`).
 +    ///
 +    /// ### Why is this bad?
 +    /// This bypasses the specialized implementation of
 +    /// `ToString` and instead goes through the more expensive string formatting
 +    /// facilities.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// // Generic implementation for `T: Display` is used (slow)
 +    /// ["foo", "bar"].iter().map(|s| s.to_string());
 +    ///
 +    /// // OK, the specialized impl is used
 +    /// ["foo", "bar"].iter().map(|&s| s.to_string());
 +    /// ```
 +    #[clippy::version = "1.40.0"]
 +    pub INEFFICIENT_TO_STRING,
 +    pedantic,
 +    "using `to_string` on `&&T` where `T: ToString`"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for `new` not returning a type that contains `Self`.
 +    ///
 +    /// ### Why is this bad?
 +    /// As a convention, `new` methods are used to make a new
 +    /// instance of a type.
 +    ///
 +    /// ### Example
 +    /// In an impl block:
 +    /// ```rust
 +    /// # struct Foo;
 +    /// # struct NotAFoo;
 +    /// impl Foo {
 +    ///     fn new() -> NotAFoo {
 +    /// # NotAFoo
 +    ///     }
 +    /// }
 +    /// ```
 +    ///
 +    /// ```rust
 +    /// # struct Foo;
 +    /// struct Bar(Foo);
 +    /// impl Foo {
 +    ///     // Bad. The type name must contain `Self`
 +    ///     fn new() -> Bar {
 +    /// # Bar(Foo)
 +    ///     }
 +    /// }
 +    /// ```
 +    ///
 +    /// ```rust
 +    /// # struct Foo;
 +    /// # struct FooError;
 +    /// impl Foo {
 +    ///     // Good. Return type contains `Self`
 +    ///     fn new() -> Result<Foo, FooError> {
 +    /// # Ok(Foo)
 +    ///     }
 +    /// }
 +    /// ```
 +    ///
 +    /// Or in a trait definition:
 +    /// ```rust
 +    /// pub trait Trait {
 +    ///     // Bad. The type name must contain `Self`
 +    ///     fn new();
 +    /// }
 +    /// ```
 +    ///
 +    /// ```rust
 +    /// pub trait Trait {
 +    ///     // Good. Return type contains `Self`
 +    ///     fn new() -> Self;
 +    /// }
 +    /// ```
 +    #[clippy::version = "pre 1.29.0"]
 +    pub NEW_RET_NO_SELF,
 +    style,
 +    "not returning type containing `Self` in a `new` method"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for string methods that receive a single-character
 +    /// `str` as an argument, e.g., `_.split("x")`.
 +    ///
 +    /// ### Why is this bad?
 +    /// Performing these methods using a `char` is faster than
 +    /// using a `str`.
 +    ///
 +    /// ### Known problems
 +    /// Does not catch multi-byte unicode characters.
 +    ///
 +    /// ### Example
 +    /// ```rust,ignore
 +    /// // Bad
 +    /// _.split("x");
 +    ///
 +    /// // Good
 +    /// _.split('x');
 +    #[clippy::version = "pre 1.29.0"]
 +    pub SINGLE_CHAR_PATTERN,
 +    perf,
 +    "using a single-character str where a char could be used, e.g., `_.split(\"x\")`"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for calling `.step_by(0)` on iterators which panics.
 +    ///
 +    /// ### Why is this bad?
 +    /// This very much looks like an oversight. Use `panic!()` instead if you
 +    /// actually intend to panic.
 +    ///
 +    /// ### Example
 +    /// ```rust,should_panic
 +    /// for x in (0..100).step_by(0) {
 +    ///     //..
 +    /// }
 +    /// ```
 +    #[clippy::version = "pre 1.29.0"]
 +    pub ITERATOR_STEP_BY_ZERO,
 +    correctness,
 +    "using `Iterator::step_by(0)`, which will panic at runtime"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for indirect collection of populated `Option`
 +    ///
 +    /// ### Why is this bad?
 +    /// `Option` is like a collection of 0-1 things, so `flatten`
 +    /// automatically does this without suspicious-looking `unwrap` calls.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// let _ = std::iter::empty::<Option<i32>>().filter(Option::is_some).map(Option::unwrap);
 +    /// ```
 +    /// Use instead:
 +    /// ```rust
 +    /// let _ = std::iter::empty::<Option<i32>>().flatten();
 +    /// ```
 +    #[clippy::version = "1.53.0"]
 +    pub OPTION_FILTER_MAP,
 +    complexity,
 +    "filtering `Option` for `Some` then force-unwrapping, which can be one type-safe operation"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for the use of `iter.nth(0)`.
 +    ///
 +    /// ### Why is this bad?
 +    /// `iter.next()` is equivalent to
 +    /// `iter.nth(0)`, as they both consume the next element,
 +    ///  but is more readable.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// # use std::collections::HashSet;
 +    /// // Bad
 +    /// # let mut s = HashSet::new();
 +    /// # s.insert(1);
 +    /// let x = s.iter().nth(0);
 +    ///
 +    /// // Good
 +    /// # let mut s = HashSet::new();
 +    /// # s.insert(1);
 +    /// let x = s.iter().next();
 +    /// ```
 +    #[clippy::version = "1.42.0"]
 +    pub ITER_NTH_ZERO,
 +    style,
 +    "replace `iter.nth(0)` with `iter.next()`"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for use of `.iter().nth()` (and the related
 +    /// `.iter_mut().nth()`) on standard library types with *O*(1) element access.
 +    ///
 +    /// ### Why is this bad?
 +    /// `.get()` and `.get_mut()` are more efficient and more
 +    /// readable.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// let some_vec = vec![0, 1, 2, 3];
 +    /// let bad_vec = some_vec.iter().nth(3);
 +    /// let bad_slice = &some_vec[..].iter().nth(3);
 +    /// ```
 +    /// The correct use would be:
 +    /// ```rust
 +    /// let some_vec = vec![0, 1, 2, 3];
 +    /// let bad_vec = some_vec.get(3);
 +    /// let bad_slice = &some_vec[..].get(3);
 +    /// ```
 +    #[clippy::version = "pre 1.29.0"]
 +    pub ITER_NTH,
 +    perf,
 +    "using `.iter().nth()` on a standard library type with O(1) element access"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for use of `.skip(x).next()` on iterators.
 +    ///
 +    /// ### Why is this bad?
 +    /// `.nth(x)` is cleaner
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// let some_vec = vec![0, 1, 2, 3];
 +    /// let bad_vec = some_vec.iter().skip(3).next();
 +    /// let bad_slice = &some_vec[..].iter().skip(3).next();
 +    /// ```
 +    /// The correct use would be:
 +    /// ```rust
 +    /// let some_vec = vec![0, 1, 2, 3];
 +    /// let bad_vec = some_vec.iter().nth(3);
 +    /// let bad_slice = &some_vec[..].iter().nth(3);
 +    /// ```
 +    #[clippy::version = "pre 1.29.0"]
 +    pub ITER_SKIP_NEXT,
 +    style,
 +    "using `.skip(x).next()` on an iterator"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for use of `.get().unwrap()` (or
 +    /// `.get_mut().unwrap`) on a standard library type which implements `Index`
 +    ///
 +    /// ### Why is this bad?
 +    /// Using the Index trait (`[]`) is more clear and more
 +    /// concise.
 +    ///
 +    /// ### Known problems
 +    /// Not a replacement for error handling: Using either
 +    /// `.unwrap()` or the Index trait (`[]`) carries the risk of causing a `panic`
 +    /// if the value being accessed is `None`. If the use of `.get().unwrap()` is a
 +    /// temporary placeholder for dealing with the `Option` type, then this does
 +    /// not mitigate the need for error handling. If there is a chance that `.get()`
 +    /// will be `None` in your program, then it is advisable that the `None` case
 +    /// is handled in a future refactor instead of using `.unwrap()` or the Index
 +    /// trait.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// let mut some_vec = vec![0, 1, 2, 3];
 +    /// let last = some_vec.get(3).unwrap();
 +    /// *some_vec.get_mut(0).unwrap() = 1;
 +    /// ```
 +    /// The correct use would be:
 +    /// ```rust
 +    /// let mut some_vec = vec![0, 1, 2, 3];
 +    /// let last = some_vec[3];
 +    /// some_vec[0] = 1;
 +    /// ```
 +    #[clippy::version = "pre 1.29.0"]
 +    pub GET_UNWRAP,
 +    restriction,
 +    "using `.get().unwrap()` or `.get_mut().unwrap()` when using `[]` would work instead"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for occurrences where one vector gets extended instead of append
 +    ///
 +    /// ### Why is this bad?
 +    /// Using `append` instead of `extend` is more concise and faster
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// let mut a = vec![1, 2, 3];
 +    /// let mut b = vec![4, 5, 6];
 +    ///
 +    /// // Bad
 +    /// a.extend(b.drain(..));
 +    ///
 +    /// // Good
 +    /// a.append(&mut b);
 +    /// ```
 +    #[clippy::version = "1.55.0"]
 +    pub EXTEND_WITH_DRAIN,
 +    perf,
 +    "using vec.append(&mut vec) to move the full range of a vecor to another"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for the use of `.extend(s.chars())` where s is a
 +    /// `&str` or `String`.
 +    ///
 +    /// ### Why is this bad?
 +    /// `.push_str(s)` is clearer
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// let abc = "abc";
 +    /// let def = String::from("def");
 +    /// let mut s = String::new();
 +    /// s.extend(abc.chars());
 +    /// s.extend(def.chars());
 +    /// ```
 +    /// The correct use would be:
 +    /// ```rust
 +    /// let abc = "abc";
 +    /// let def = String::from("def");
 +    /// let mut s = String::new();
 +    /// s.push_str(abc);
 +    /// s.push_str(&def);
 +    /// ```
 +    #[clippy::version = "pre 1.29.0"]
 +    pub STRING_EXTEND_CHARS,
 +    style,
 +    "using `x.extend(s.chars())` where s is a `&str` or `String`"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for the use of `.cloned().collect()` on slice to
 +    /// create a `Vec`.
 +    ///
 +    /// ### Why is this bad?
 +    /// `.to_vec()` is clearer
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// let s = [1, 2, 3, 4, 5];
 +    /// let s2: Vec<isize> = s[..].iter().cloned().collect();
 +    /// ```
 +    /// The better use would be:
 +    /// ```rust
 +    /// let s = [1, 2, 3, 4, 5];
 +    /// let s2: Vec<isize> = s.to_vec();
 +    /// ```
 +    #[clippy::version = "pre 1.29.0"]
 +    pub ITER_CLONED_COLLECT,
 +    style,
 +    "using `.cloned().collect()` on slice to create a `Vec`"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for usage of `_.chars().last()` or
 +    /// `_.chars().next_back()` on a `str` to check if it ends with a given char.
 +    ///
 +    /// ### Why is this bad?
 +    /// Readability, this can be written more concisely as
 +    /// `_.ends_with(_)`.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// # let name = "_";
 +    ///
 +    /// // Bad
 +    /// name.chars().last() == Some('_') || name.chars().next_back() == Some('-');
 +    ///
 +    /// // Good
 +    /// name.ends_with('_') || name.ends_with('-');
 +    /// ```
 +    #[clippy::version = "pre 1.29.0"]
 +    pub CHARS_LAST_CMP,
 +    style,
 +    "using `.chars().last()` or `.chars().next_back()` to check if a string ends with a char"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for usage of `.as_ref()` or `.as_mut()` where the
 +    /// types before and after the call are the same.
 +    ///
 +    /// ### Why is this bad?
 +    /// The call is unnecessary.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// # fn do_stuff(x: &[i32]) {}
 +    /// let x: &[i32] = &[1, 2, 3, 4, 5];
 +    /// do_stuff(x.as_ref());
 +    /// ```
 +    /// The correct use would be:
 +    /// ```rust
 +    /// # fn do_stuff(x: &[i32]) {}
 +    /// let x: &[i32] = &[1, 2, 3, 4, 5];
 +    /// do_stuff(x);
 +    /// ```
 +    #[clippy::version = "pre 1.29.0"]
 +    pub USELESS_ASREF,
 +    complexity,
 +    "using `as_ref` where the types before and after the call are the same"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for using `fold` when a more succinct alternative exists.
 +    /// Specifically, this checks for `fold`s which could be replaced by `any`, `all`,
 +    /// `sum` or `product`.
 +    ///
 +    /// ### Why is this bad?
 +    /// Readability.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// let _ = (0..3).fold(false, |acc, x| acc || x > 2);
 +    /// ```
 +    /// This could be written as:
 +    /// ```rust
 +    /// let _ = (0..3).any(|x| x > 2);
 +    /// ```
 +    #[clippy::version = "pre 1.29.0"]
 +    pub UNNECESSARY_FOLD,
 +    style,
 +    "using `fold` when a more succinct alternative exists"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for `filter_map` calls which could be replaced by `filter` or `map`.
 +    /// More specifically it checks if the closure provided is only performing one of the
 +    /// filter or map operations and suggests the appropriate option.
 +    ///
 +    /// ### Why is this bad?
 +    /// Complexity. The intent is also clearer if only a single
 +    /// operation is being performed.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// let _ = (0..3).filter_map(|x| if x > 2 { Some(x) } else { None });
 +    ///
 +    /// // As there is no transformation of the argument this could be written as:
 +    /// let _ = (0..3).filter(|&x| x > 2);
 +    /// ```
 +    ///
 +    /// ```rust
 +    /// let _ = (0..4).filter_map(|x| Some(x + 1));
 +    ///
 +    /// // As there is no conditional check on the argument this could be written as:
 +    /// let _ = (0..4).map(|x| x + 1);
 +    /// ```
 +    #[clippy::version = "1.31.0"]
 +    pub UNNECESSARY_FILTER_MAP,
 +    complexity,
 +    "using `filter_map` when a more succinct alternative exists"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for `into_iter` calls on references which should be replaced by `iter`
 +    /// or `iter_mut`.
 +    ///
 +    /// ### Why is this bad?
 +    /// Readability. Calling `into_iter` on a reference will not move out its
 +    /// content into the resulting iterator, which is confusing. It is better just call `iter` or
 +    /// `iter_mut` directly.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// // Bad
 +    /// let _ = (&vec![3, 4, 5]).into_iter();
 +    ///
 +    /// // Good
 +    /// let _ = (&vec![3, 4, 5]).iter();
 +    /// ```
 +    #[clippy::version = "1.32.0"]
 +    pub INTO_ITER_ON_REF,
 +    style,
 +    "using `.into_iter()` on a reference"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for calls to `map` followed by a `count`.
 +    ///
 +    /// ### Why is this bad?
 +    /// It looks suspicious. Maybe `map` was confused with `filter`.
 +    /// If the `map` call is intentional, this should be rewritten
 +    /// using `inspect`. Or, if you intend to drive the iterator to
 +    /// completion, you can just use `for_each` instead.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// let _ = (0..3).map(|x| x + 2).count();
 +    /// ```
 +    #[clippy::version = "1.39.0"]
 +    pub SUSPICIOUS_MAP,
 +    suspicious,
 +    "suspicious usage of map"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for `MaybeUninit::uninit().assume_init()`.
 +    ///
 +    /// ### Why is this bad?
 +    /// For most types, this is undefined behavior.
 +    ///
 +    /// ### Known problems
 +    /// For now, we accept empty tuples and tuples / arrays
 +    /// of `MaybeUninit`. There may be other types that allow uninitialized
 +    /// data, but those are not yet rigorously defined.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// // Beware the UB
 +    /// use std::mem::MaybeUninit;
 +    ///
 +    /// let _: usize = unsafe { MaybeUninit::uninit().assume_init() };
 +    /// ```
 +    ///
 +    /// Note that the following is OK:
 +    ///
 +    /// ```rust
 +    /// use std::mem::MaybeUninit;
 +    ///
 +    /// let _: [MaybeUninit<bool>; 5] = unsafe {
 +    ///     MaybeUninit::uninit().assume_init()
 +    /// };
 +    /// ```
 +    #[clippy::version = "1.39.0"]
 +    pub UNINIT_ASSUMED_INIT,
 +    correctness,
 +    "`MaybeUninit::uninit().assume_init()`"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for `.checked_add/sub(x).unwrap_or(MAX/MIN)`.
 +    ///
 +    /// ### Why is this bad?
 +    /// These can be written simply with `saturating_add/sub` methods.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// # let y: u32 = 0;
 +    /// # let x: u32 = 100;
 +    /// let add = x.checked_add(y).unwrap_or(u32::MAX);
 +    /// let sub = x.checked_sub(y).unwrap_or(u32::MIN);
 +    /// ```
 +    ///
 +    /// can be written using dedicated methods for saturating addition/subtraction as:
 +    ///
 +    /// ```rust
 +    /// # let y: u32 = 0;
 +    /// # let x: u32 = 100;
 +    /// let add = x.saturating_add(y);
 +    /// let sub = x.saturating_sub(y);
 +    /// ```
 +    #[clippy::version = "1.39.0"]
 +    pub MANUAL_SATURATING_ARITHMETIC,
 +    style,
 +    "`.chcked_add/sub(x).unwrap_or(MAX/MIN)`"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for `offset(_)`, `wrapping_`{`add`, `sub`}, etc. on raw pointers to
 +    /// zero-sized types
 +    ///
 +    /// ### Why is this bad?
 +    /// This is a no-op, and likely unintended
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// unsafe { (&() as *const ()).offset(1) };
 +    /// ```
 +    #[clippy::version = "1.41.0"]
 +    pub ZST_OFFSET,
 +    correctness,
 +    "Check for offset calculations on raw pointers to zero-sized types"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for `FileType::is_file()`.
 +    ///
 +    /// ### Why is this bad?
 +    /// When people testing a file type with `FileType::is_file`
 +    /// they are testing whether a path is something they can get bytes from. But
 +    /// `is_file` doesn't cover special file types in unix-like systems, and doesn't cover
 +    /// symlink in windows. Using `!FileType::is_dir()` is a better way to that intention.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// # || {
 +    /// let metadata = std::fs::metadata("foo.txt")?;
 +    /// let filetype = metadata.file_type();
 +    ///
 +    /// if filetype.is_file() {
 +    ///     // read file
 +    /// }
 +    /// # Ok::<_, std::io::Error>(())
 +    /// # };
 +    /// ```
 +    ///
 +    /// should be written as:
 +    ///
 +    /// ```rust
 +    /// # || {
 +    /// let metadata = std::fs::metadata("foo.txt")?;
 +    /// let filetype = metadata.file_type();
 +    ///
 +    /// if !filetype.is_dir() {
 +    ///     // read file
 +    /// }
 +    /// # Ok::<_, std::io::Error>(())
 +    /// # };
 +    /// ```
 +    #[clippy::version = "1.42.0"]
 +    pub FILETYPE_IS_FILE,
 +    restriction,
 +    "`FileType::is_file` is not recommended to test for readable file type"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for usage of `_.as_ref().map(Deref::deref)` or it's aliases (such as String::as_str).
 +    ///
 +    /// ### Why is this bad?
 +    /// Readability, this can be written more concisely as
 +    /// `_.as_deref()`.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// # let opt = Some("".to_string());
 +    /// opt.as_ref().map(String::as_str)
 +    /// # ;
 +    /// ```
 +    /// Can be written as
 +    /// ```rust
 +    /// # let opt = Some("".to_string());
 +    /// opt.as_deref()
 +    /// # ;
 +    /// ```
 +    #[clippy::version = "1.42.0"]
 +    pub OPTION_AS_REF_DEREF,
 +    complexity,
 +    "using `as_ref().map(Deref::deref)`, which is more succinctly expressed as `as_deref()`"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for usage of `iter().next()` on a Slice or an Array
 +    ///
 +    /// ### Why is this bad?
 +    /// These can be shortened into `.get()`
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// # let a = [1, 2, 3];
 +    /// # let b = vec![1, 2, 3];
 +    /// a[2..].iter().next();
 +    /// b.iter().next();
 +    /// ```
 +    /// should be written as:
 +    /// ```rust
 +    /// # let a = [1, 2, 3];
 +    /// # let b = vec![1, 2, 3];
 +    /// a.get(2);
 +    /// b.get(0);
 +    /// ```
 +    #[clippy::version = "1.46.0"]
 +    pub ITER_NEXT_SLICE,
 +    style,
 +    "using `.iter().next()` on a sliced array, which can be shortened to just `.get()`"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Warns when using `push_str`/`insert_str` with a single-character string literal
 +    /// where `push`/`insert` with a `char` would work fine.
 +    ///
 +    /// ### Why is this bad?
 +    /// It's less clear that we are pushing a single character.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// let mut string = String::new();
 +    /// string.insert_str(0, "R");
 +    /// string.push_str("R");
 +    /// ```
 +    /// Could be written as
 +    /// ```rust
 +    /// let mut string = String::new();
 +    /// string.insert(0, 'R');
 +    /// string.push('R');
 +    /// ```
 +    #[clippy::version = "1.49.0"]
 +    pub SINGLE_CHAR_ADD_STR,
 +    style,
 +    "`push_str()` or `insert_str()` used with a single-character string literal as parameter"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// As the counterpart to `or_fun_call`, this lint looks for unnecessary
 +    /// lazily evaluated closures on `Option` and `Result`.
 +    ///
 +    /// This lint suggests changing the following functions, when eager evaluation results in
 +    /// simpler code:
 +    ///  - `unwrap_or_else` to `unwrap_or`
 +    ///  - `and_then` to `and`
 +    ///  - `or_else` to `or`
 +    ///  - `get_or_insert_with` to `get_or_insert`
 +    ///  - `ok_or_else` to `ok_or`
 +    ///
 +    /// ### Why is this bad?
 +    /// Using eager evaluation is shorter and simpler in some cases.
 +    ///
 +    /// ### Known problems
 +    /// It is possible, but not recommended for `Deref` and `Index` to have
 +    /// side effects. Eagerly evaluating them can change the semantics of the program.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// // example code where clippy issues a warning
 +    /// let opt: Option<u32> = None;
 +    ///
 +    /// opt.unwrap_or_else(|| 42);
 +    /// ```
 +    /// Use instead:
 +    /// ```rust
 +    /// let opt: Option<u32> = None;
 +    ///
 +    /// opt.unwrap_or(42);
 +    /// ```
 +    #[clippy::version = "1.48.0"]
 +    pub UNNECESSARY_LAZY_EVALUATIONS,
 +    style,
 +    "using unnecessary lazy evaluation, which can be replaced with simpler eager evaluation"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for usage of `_.map(_).collect::<Result<(), _>()`.
 +    ///
 +    /// ### Why is this bad?
 +    /// Using `try_for_each` instead is more readable and idiomatic.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// (0..3).map(|t| Err(t)).collect::<Result<(), _>>();
 +    /// ```
 +    /// Use instead:
 +    /// ```rust
 +    /// (0..3).try_for_each(|t| Err(t));
 +    /// ```
 +    #[clippy::version = "1.49.0"]
 +    pub MAP_COLLECT_RESULT_UNIT,
 +    style,
 +    "using `.map(_).collect::<Result<(),_>()`, which can be replaced with `try_for_each`"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for `from_iter()` function calls on types that implement the `FromIterator`
 +    /// trait.
 +    ///
 +    /// ### Why is this bad?
 +    /// It is recommended style to use collect. See
 +    /// [FromIterator documentation](https://doc.rust-lang.org/std/iter/trait.FromIterator.html)
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// use std::iter::FromIterator;
 +    ///
 +    /// let five_fives = std::iter::repeat(5).take(5);
 +    ///
 +    /// let v = Vec::from_iter(five_fives);
 +    ///
 +    /// assert_eq!(v, vec![5, 5, 5, 5, 5]);
 +    /// ```
 +    /// Use instead:
 +    /// ```rust
 +    /// let five_fives = std::iter::repeat(5).take(5);
 +    ///
 +    /// let v: Vec<i32> = five_fives.collect();
 +    ///
 +    /// assert_eq!(v, vec![5, 5, 5, 5, 5]);
 +    /// ```
 +    #[clippy::version = "1.49.0"]
 +    pub FROM_ITER_INSTEAD_OF_COLLECT,
 +    pedantic,
 +    "use `.collect()` instead of `::from_iter()`"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for usage of `inspect().for_each()`.
 +    ///
 +    /// ### Why is this bad?
 +    /// It is the same as performing the computation
 +    /// inside `inspect` at the beginning of the closure in `for_each`.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// [1,2,3,4,5].iter()
 +    /// .inspect(|&x| println!("inspect the number: {}", x))
 +    /// .for_each(|&x| {
 +    ///     assert!(x >= 0);
 +    /// });
 +    /// ```
 +    /// Can be written as
 +    /// ```rust
 +    /// [1,2,3,4,5].iter()
 +    /// .for_each(|&x| {
 +    ///     println!("inspect the number: {}", x);
 +    ///     assert!(x >= 0);
 +    /// });
 +    /// ```
 +    #[clippy::version = "1.51.0"]
 +    pub INSPECT_FOR_EACH,
 +    complexity,
 +    "using `.inspect().for_each()`, which can be replaced with `.for_each()`"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for usage of `filter_map(|x| x)`.
 +    ///
 +    /// ### Why is this bad?
 +    /// Readability, this can be written more concisely by using `flatten`.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// # let iter = vec![Some(1)].into_iter();
 +    /// iter.filter_map(|x| x);
 +    /// ```
 +    /// Use instead:
 +    /// ```rust
 +    /// # let iter = vec![Some(1)].into_iter();
 +    /// iter.flatten();
 +    /// ```
 +    #[clippy::version = "1.52.0"]
 +    pub FILTER_MAP_IDENTITY,
 +    complexity,
 +    "call to `filter_map` where `flatten` is sufficient"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for instances of `map(f)` where `f` is the identity function.
 +    ///
 +    /// ### Why is this bad?
 +    /// It can be written more concisely without the call to `map`.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// let x = [1, 2, 3];
 +    /// let y: Vec<_> = x.iter().map(|x| x).map(|x| 2*x).collect();
 +    /// ```
 +    /// Use instead:
 +    /// ```rust
 +    /// let x = [1, 2, 3];
 +    /// let y: Vec<_> = x.iter().map(|x| 2*x).collect();
 +    /// ```
 +    #[clippy::version = "1.52.0"]
 +    pub MAP_IDENTITY,
 +    complexity,
 +    "using iterator.map(|x| x)"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for the use of `.bytes().nth()`.
 +    ///
 +    /// ### Why is this bad?
 +    /// `.as_bytes().get()` is more efficient and more
 +    /// readable.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// // Bad
 +    /// let _ = "Hello".bytes().nth(3);
 +    ///
 +    /// // Good
 +    /// let _ = "Hello".as_bytes().get(3);
 +    /// ```
 +    #[clippy::version = "1.52.0"]
 +    pub BYTES_NTH,
 +    style,
 +    "replace `.bytes().nth()` with `.as_bytes().get()`"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for the usage of `_.to_owned()`, `vec.to_vec()`, or similar when calling `_.clone()` would be clearer.
 +    ///
 +    /// ### Why is this bad?
 +    /// These methods do the same thing as `_.clone()` but may be confusing as
 +    /// to why we are calling `to_vec` on something that is already a `Vec` or calling `to_owned` on something that is already owned.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// let a = vec![1, 2, 3];
 +    /// let b = a.to_vec();
 +    /// let c = a.to_owned();
 +    /// ```
 +    /// Use instead:
 +    /// ```rust
 +    /// let a = vec![1, 2, 3];
 +    /// let b = a.clone();
 +    /// let c = a.clone();
 +    /// ```
 +    #[clippy::version = "1.52.0"]
 +    pub IMPLICIT_CLONE,
 +    pedantic,
 +    "implicitly cloning a value by invoking a function on its dereferenced type"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for the use of `.iter().count()`.
 +    ///
 +    /// ### Why is this bad?
 +    /// `.len()` is more efficient and more
 +    /// readable.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// // Bad
 +    /// let some_vec = vec![0, 1, 2, 3];
 +    /// let _ = some_vec.iter().count();
 +    /// let _ = &some_vec[..].iter().count();
 +    ///
 +    /// // Good
 +    /// let some_vec = vec![0, 1, 2, 3];
 +    /// let _ = some_vec.len();
 +    /// let _ = &some_vec[..].len();
 +    /// ```
 +    #[clippy::version = "1.52.0"]
 +    pub ITER_COUNT,
 +    complexity,
 +    "replace `.iter().count()` with `.len()`"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for calls to [`splitn`]
 +    /// (https://doc.rust-lang.org/std/primitive.str.html#method.splitn) and
 +    /// related functions with either zero or one splits.
 +    ///
 +    /// ### Why is this bad?
 +    /// These calls don't actually split the value and are
 +    /// likely to be intended as a different number.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// // Bad
 +    /// let s = "";
 +    /// for x in s.splitn(1, ":") {
 +    ///     // use x
 +    /// }
 +    ///
 +    /// // Good
 +    /// let s = "";
 +    /// for x in s.splitn(2, ":") {
 +    ///     // use x
 +    /// }
 +    /// ```
 +    #[clippy::version = "1.54.0"]
 +    pub SUSPICIOUS_SPLITN,
 +    correctness,
 +    "checks for `.splitn(0, ..)` and `.splitn(1, ..)`"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for manual implementations of `str::repeat`
 +    ///
 +    /// ### Why is this bad?
 +    /// These are both harder to read, as well as less performant.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// // Bad
 +    /// let x: String = std::iter::repeat('x').take(10).collect();
 +    ///
 +    /// // Good
 +    /// let x: String = "x".repeat(10);
 +    /// ```
 +    #[clippy::version = "1.54.0"]
 +    pub MANUAL_STR_REPEAT,
 +    perf,
 +    "manual implementation of `str::repeat`"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for usages of `str::splitn(2, _)`
 +    ///
 +    /// ### Why is this bad?
 +    /// `split_once` is both clearer in intent and slightly more efficient.
 +    ///
 +    /// ### Example
 +    /// ```rust,ignore
 +    /// // Bad
 +    ///  let (key, value) = _.splitn(2, '=').next_tuple()?;
 +    ///  let value = _.splitn(2, '=').nth(1)?;
 +    ///
 +    /// // Good
 +    /// let (key, value) = _.split_once('=')?;
 +    /// let value = _.split_once('=')?.1;
 +    /// ```
 +    #[clippy::version = "1.57.0"]
 +    pub MANUAL_SPLIT_ONCE,
 +    complexity,
 +    "replace `.splitn(2, pat)` with `.split_once(pat)`"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for usages of `str::splitn` (or `str::rsplitn`) where using `str::split` would be the same.
 +    /// ### Why is this bad?
 +    /// The function `split` is simpler and there is no performance difference in these cases, considering
 +    /// that both functions return a lazy iterator.
 +    /// ### Example
 +    /// ```rust
 +    /// // Bad
 +    /// let str = "key=value=add";
 +    /// let _ = str.splitn(3, '=').next().unwrap();
 +    /// ```
 +    /// Use instead:
 +    /// ```rust
 +    /// // Good
 +    /// let str = "key=value=add";
 +    /// let _ = str.split('=').next().unwrap();
 +    /// ```
 +    #[clippy::version = "1.58.0"]
 +    pub NEEDLESS_SPLITN,
 +    complexity,
 +    "usages of `str::splitn` that can be replaced with `str::split`"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for unnecessary calls to [`ToOwned::to_owned`](https://doc.rust-lang.org/std/borrow/trait.ToOwned.html#tymethod.to_owned)
 +    /// and other `to_owned`-like functions.
 +    ///
 +    /// ### Why is this bad?
 +    /// The unnecessary calls result in useless allocations.
 +    ///
 +    /// ### Known problems
 +    /// `unnecessary_to_owned` can falsely trigger if `IntoIterator::into_iter` is applied to an
 +    /// owned copy of a resource and the resource is later used mutably. See
 +    /// [#8148](https://github.com/rust-lang/rust-clippy/issues/8148).
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// let path = std::path::Path::new("x");
 +    /// foo(&path.to_string_lossy().to_string());
 +    /// fn foo(s: &str) {}
 +    /// ```
 +    /// Use instead:
 +    /// ```rust
 +    /// let path = std::path::Path::new("x");
 +    /// foo(&path.to_string_lossy());
 +    /// fn foo(s: &str) {}
 +    /// ```
 +    #[clippy::version = "1.58.0"]
 +    pub UNNECESSARY_TO_OWNED,
 +    perf,
 +    "unnecessary calls to `to_owned`-like functions"
 +}
 +
 +pub struct Methods {
 +    avoid_breaking_exported_api: bool,
 +    msrv: Option<RustcVersion>,
 +}
 +
 +impl Methods {
 +    #[must_use]
 +    pub fn new(avoid_breaking_exported_api: bool, msrv: Option<RustcVersion>) -> Self {
 +        Self {
 +            avoid_breaking_exported_api,
 +            msrv,
 +        }
 +    }
 +}
 +
 +impl_lint_pass!(Methods => [
 +    UNWRAP_USED,
 +    EXPECT_USED,
 +    SHOULD_IMPLEMENT_TRAIT,
 +    WRONG_SELF_CONVENTION,
 +    OK_EXPECT,
 +    UNWRAP_OR_ELSE_DEFAULT,
 +    MAP_UNWRAP_OR,
 +    RESULT_MAP_OR_INTO_OPTION,
 +    OPTION_MAP_OR_NONE,
 +    BIND_INSTEAD_OF_MAP,
 +    OR_FUN_CALL,
 +    EXPECT_FUN_CALL,
 +    CHARS_NEXT_CMP,
 +    CHARS_LAST_CMP,
 +    CLONE_ON_COPY,
 +    CLONE_ON_REF_PTR,
 +    CLONE_DOUBLE_REF,
 +    ITER_OVEREAGER_CLONED,
 +    CLONED_INSTEAD_OF_COPIED,
 +    FLAT_MAP_OPTION,
 +    INEFFICIENT_TO_STRING,
 +    NEW_RET_NO_SELF,
 +    SINGLE_CHAR_PATTERN,
 +    SINGLE_CHAR_ADD_STR,
 +    SEARCH_IS_SOME,
 +    FILTER_NEXT,
 +    SKIP_WHILE_NEXT,
 +    FILTER_MAP_IDENTITY,
 +    MAP_IDENTITY,
 +    MANUAL_FILTER_MAP,
 +    MANUAL_FIND_MAP,
 +    OPTION_FILTER_MAP,
 +    FILTER_MAP_NEXT,
 +    FLAT_MAP_IDENTITY,
 +    MAP_FLATTEN,
 +    ITERATOR_STEP_BY_ZERO,
 +    ITER_NEXT_SLICE,
 +    ITER_COUNT,
 +    ITER_NTH,
 +    ITER_NTH_ZERO,
 +    BYTES_NTH,
 +    ITER_SKIP_NEXT,
 +    GET_UNWRAP,
 +    STRING_EXTEND_CHARS,
 +    ITER_CLONED_COLLECT,
 +    USELESS_ASREF,
 +    UNNECESSARY_FOLD,
 +    UNNECESSARY_FILTER_MAP,
 +    INTO_ITER_ON_REF,
 +    SUSPICIOUS_MAP,
 +    UNINIT_ASSUMED_INIT,
 +    MANUAL_SATURATING_ARITHMETIC,
 +    ZST_OFFSET,
 +    FILETYPE_IS_FILE,
 +    OPTION_AS_REF_DEREF,
 +    UNNECESSARY_LAZY_EVALUATIONS,
 +    MAP_COLLECT_RESULT_UNIT,
 +    FROM_ITER_INSTEAD_OF_COLLECT,
 +    INSPECT_FOR_EACH,
 +    IMPLICIT_CLONE,
 +    SUSPICIOUS_SPLITN,
 +    MANUAL_STR_REPEAT,
 +    EXTEND_WITH_DRAIN,
 +    MANUAL_SPLIT_ONCE,
 +    NEEDLESS_SPLITN,
 +    UNNECESSARY_TO_OWNED,
 +]);
 +
 +/// Extracts a method call name, args, and `Span` of the method name.
 +fn method_call<'tcx>(recv: &'tcx hir::Expr<'tcx>) -> Option<(&'tcx str, &'tcx [hir::Expr<'tcx>], Span)> {
 +    if let ExprKind::MethodCall(path, args, _) = recv.kind {
 +        if !args.iter().any(|e| e.span.from_expansion()) {
 +            let name = path.ident.name.as_str();
 +            return Some((name, args, path.ident.span));
 +        }
 +    }
 +    None
 +}
 +
 +impl<'tcx> LateLintPass<'tcx> for Methods {
 +    fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>) {
 +        if expr.span.from_expansion() {
 +            return;
 +        }
 +
 +        check_methods(cx, expr, self.msrv.as_ref());
 +
 +        match expr.kind {
 +            hir::ExprKind::Call(func, args) => {
 +                from_iter_instead_of_collect::check(cx, expr, args, func);
 +            },
 +            hir::ExprKind::MethodCall(method_call, args, _) => {
 +                let method_span = method_call.ident.span;
 +                or_fun_call::check(cx, expr, method_span, method_call.ident.as_str(), args);
 +                expect_fun_call::check(cx, expr, method_span, method_call.ident.as_str(), args);
 +                clone_on_copy::check(cx, expr, method_call.ident.name, args);
 +                clone_on_ref_ptr::check(cx, expr, method_call.ident.name, args);
 +                inefficient_to_string::check(cx, expr, method_call.ident.name, args);
 +                single_char_add_str::check(cx, expr, args);
 +                into_iter_on_ref::check(cx, expr, method_span, method_call.ident.name, args);
 +                single_char_pattern::check(cx, expr, method_call.ident.name, args);
 +                unnecessary_to_owned::check(cx, expr, method_call.ident.name, args);
 +            },
 +            hir::ExprKind::Binary(op, lhs, rhs) if op.node == hir::BinOpKind::Eq || op.node == hir::BinOpKind::Ne => {
 +                let mut info = BinaryExprInfo {
 +                    expr,
 +                    chain: lhs,
 +                    other: rhs,
 +                    eq: op.node == hir::BinOpKind::Eq,
 +                };
 +                lint_binary_expr_with_method_call(cx, &mut info);
 +            },
 +            _ => (),
 +        }
 +    }
 +
 +    #[allow(clippy::too_many_lines)]
 +    fn check_impl_item(&mut self, cx: &LateContext<'tcx>, impl_item: &'tcx hir::ImplItem<'_>) {
 +        if in_external_macro(cx.sess(), impl_item.span) {
 +            return;
 +        }
 +        let name = impl_item.ident.name.as_str();
 +        let parent = cx.tcx.hir().get_parent_item(impl_item.hir_id());
 +        let item = cx.tcx.hir().expect_item(parent);
 +        let self_ty = cx.tcx.type_of(item.def_id);
 +
 +        let implements_trait = matches!(item.kind, hir::ItemKind::Impl(hir::Impl { of_trait: Some(_), .. }));
 +        if_chain! {
 +            if let hir::ImplItemKind::Fn(ref sig, id) = impl_item.kind;
 +            if let Some(first_arg) = iter_input_pats(sig.decl, cx.tcx.hir().body(id)).next();
 +
 +            let method_sig = cx.tcx.fn_sig(impl_item.def_id);
 +            let method_sig = cx.tcx.erase_late_bound_regions(method_sig);
 +
 +            let first_arg_ty = &method_sig.inputs().iter().next();
 +
 +            // check conventions w.r.t. conversion method names and predicates
 +            if let Some(first_arg_ty) = first_arg_ty;
 +
 +            then {
 +                // if this impl block implements a trait, lint in trait definition instead
 +                if !implements_trait && cx.access_levels.is_exported(impl_item.def_id) {
 +                    // check missing trait implementations
 +                    for method_config in &TRAIT_METHODS {
 +                        if name == method_config.method_name &&
 +                            sig.decl.inputs.len() == method_config.param_count &&
 +                            method_config.output_type.matches(&sig.decl.output) &&
 +                            method_config.self_kind.matches(cx, self_ty, first_arg_ty) &&
 +                            fn_header_equals(method_config.fn_header, sig.header) &&
 +                            method_config.lifetime_param_cond(impl_item)
 +                        {
 +                            span_lint_and_help(
 +                                cx,
 +                                SHOULD_IMPLEMENT_TRAIT,
 +                                impl_item.span,
 +                                &format!(
 +                                    "method `{}` can be confused for the standard trait method `{}::{}`",
 +                                    method_config.method_name,
 +                                    method_config.trait_name,
 +                                    method_config.method_name
 +                                ),
 +                                None,
 +                                &format!(
 +                                    "consider implementing the trait `{}` or choosing a less ambiguous method name",
 +                                    method_config.trait_name
 +                                )
 +                            );
 +                        }
 +                    }
 +                }
 +
 +                if sig.decl.implicit_self.has_implicit_self()
 +                    && !(self.avoid_breaking_exported_api
 +                        && cx.access_levels.is_exported(impl_item.def_id))
 +                {
 +                    wrong_self_convention::check(
 +                        cx,
 +                        name,
 +                        self_ty,
 +                        first_arg_ty,
 +                        first_arg.pat.span,
 +                        implements_trait,
 +                        false
 +                    );
 +                }
 +            }
 +        }
 +
 +        // if this impl block implements a trait, lint in trait definition instead
 +        if implements_trait {
 +            return;
 +        }
 +
 +        if let hir::ImplItemKind::Fn(_, _) = impl_item.kind {
 +            let ret_ty = return_ty(cx, impl_item.hir_id());
 +
 +            // walk the return type and check for Self (this does not check associated types)
 +            if let Some(self_adt) = self_ty.ty_adt_def() {
 +                if contains_adt_constructor(ret_ty, self_adt) {
 +                    return;
 +                }
 +            } else if contains_ty(ret_ty, self_ty) {
 +                return;
 +            }
 +
 +            // if return type is impl trait, check the associated types
 +            if let ty::Opaque(def_id, _) = *ret_ty.kind() {
 +                // one of the associated types must be Self
 +                for &(predicate, _span) in cx.tcx.explicit_item_bounds(def_id) {
 +                    if let ty::PredicateKind::Projection(projection_predicate) = predicate.kind().skip_binder() {
 +                        let assoc_ty = match projection_predicate.term {
++                            ty::Term::Ty(ty) => ty,
++                            ty::Term::Const(_c) => continue,
 +                        };
 +                        // walk the associated type and check for Self
 +                        if let Some(self_adt) = self_ty.ty_adt_def() {
 +                            if contains_adt_constructor(assoc_ty, self_adt) {
 +                                return;
 +                            }
 +                        } else if contains_ty(assoc_ty, self_ty) {
 +                            return;
 +                        }
 +                    }
 +                }
 +            }
 +
 +            if name == "new" && !TyS::same_type(ret_ty, self_ty) {
 +                span_lint(
 +                    cx,
 +                    NEW_RET_NO_SELF,
 +                    impl_item.span,
 +                    "methods called `new` usually return `Self`",
 +                );
 +            }
 +        }
 +    }
 +
 +    fn check_trait_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx TraitItem<'_>) {
 +        if in_external_macro(cx.tcx.sess, item.span) {
 +            return;
 +        }
 +
 +        if_chain! {
 +            if let TraitItemKind::Fn(ref sig, _) = item.kind;
 +            if sig.decl.implicit_self.has_implicit_self();
 +            if let Some(first_arg_ty) = sig.decl.inputs.iter().next();
 +
 +            then {
 +                let first_arg_span = first_arg_ty.span;
 +                let first_arg_ty = hir_ty_to_ty(cx.tcx, first_arg_ty);
 +                let self_ty = TraitRef::identity(cx.tcx, item.def_id.to_def_id()).self_ty().skip_binder();
 +                wrong_self_convention::check(
 +                    cx,
 +                    item.ident.name.as_str(),
 +                    self_ty,
 +                    first_arg_ty,
 +                    first_arg_span,
 +                    false,
 +                    true
 +                );
 +            }
 +        }
 +
 +        if_chain! {
 +            if item.ident.name == sym::new;
 +            if let TraitItemKind::Fn(_, _) = item.kind;
 +            let ret_ty = return_ty(cx, item.hir_id());
 +            let self_ty = TraitRef::identity(cx.tcx, item.def_id.to_def_id()).self_ty().skip_binder();
 +            if !contains_ty(ret_ty, self_ty);
 +
 +            then {
 +                span_lint(
 +                    cx,
 +                    NEW_RET_NO_SELF,
 +                    item.span,
 +                    "methods called `new` usually return `Self`",
 +                );
 +            }
 +        }
 +    }
 +
 +    extract_msrv_attr!(LateContext);
 +}
 +
 +#[allow(clippy::too_many_lines)]
 +fn check_methods<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, msrv: Option<&RustcVersion>) {
 +    if let Some((name, [recv, args @ ..], span)) = method_call(expr) {
 +        match (name, args) {
 +            ("add" | "offset" | "sub" | "wrapping_offset" | "wrapping_add" | "wrapping_sub", [_arg]) => {
 +                zst_offset::check(cx, expr, recv);
 +            },
 +            ("and_then", [arg]) => {
 +                let biom_option_linted = bind_instead_of_map::OptionAndThenSome::check(cx, expr, recv, arg);
 +                let biom_result_linted = bind_instead_of_map::ResultAndThenOk::check(cx, expr, recv, arg);
 +                if !biom_option_linted && !biom_result_linted {
 +                    unnecessary_lazy_eval::check(cx, expr, recv, arg, "and");
 +                }
 +            },
 +            ("as_mut", []) => useless_asref::check(cx, expr, "as_mut", recv),
 +            ("as_ref", []) => useless_asref::check(cx, expr, "as_ref", recv),
 +            ("assume_init", []) => uninit_assumed_init::check(cx, expr, recv),
 +            ("cloned", []) => cloned_instead_of_copied::check(cx, expr, recv, span, msrv),
 +            ("collect", []) => match method_call(recv) {
 +                Some((name @ ("cloned" | "copied"), [recv2], _)) => {
 +                    iter_cloned_collect::check(cx, name, expr, recv2);
 +                },
 +                Some(("map", [m_recv, m_arg], _)) => {
 +                    map_collect_result_unit::check(cx, expr, m_recv, m_arg, recv);
 +                },
 +                Some(("take", [take_self_arg, take_arg], _)) => {
 +                    if meets_msrv(msrv, &msrvs::STR_REPEAT) {
 +                        manual_str_repeat::check(cx, expr, recv, take_self_arg, take_arg);
 +                    }
 +                },
 +                _ => {},
 +            },
 +            (name @ "count", args @ []) => match method_call(recv) {
 +                Some(("cloned", [recv2], _)) => iter_overeager_cloned::check(cx, expr, recv2, name, args),
 +                Some((name2 @ ("into_iter" | "iter" | "iter_mut"), [recv2], _)) => {
 +                    iter_count::check(cx, expr, recv2, name2);
 +                },
 +                Some(("map", [_, arg], _)) => suspicious_map::check(cx, expr, recv, arg),
 +                _ => {},
 +            },
 +            ("expect", [_]) => match method_call(recv) {
 +                Some(("ok", [recv], _)) => ok_expect::check(cx, expr, recv),
 +                _ => expect_used::check(cx, expr, recv),
 +            },
 +            ("extend", [arg]) => {
 +                string_extend_chars::check(cx, expr, recv, arg);
 +                extend_with_drain::check(cx, expr, recv, arg);
 +            },
 +            ("filter_map", [arg]) => {
 +                unnecessary_filter_map::check(cx, expr, arg);
 +                filter_map_identity::check(cx, expr, arg, span);
 +            },
 +            ("flat_map", [arg]) => {
 +                flat_map_identity::check(cx, expr, arg, span);
 +                flat_map_option::check(cx, expr, arg, span);
 +            },
 +            (name @ "flatten", args @ []) => match method_call(recv) {
 +                Some(("map", [recv, map_arg], _)) => map_flatten::check(cx, expr, recv, map_arg),
 +                Some(("cloned", [recv2], _)) => iter_overeager_cloned::check(cx, expr, recv2, name, args),
 +                _ => {},
 +            },
 +            ("fold", [init, acc]) => unnecessary_fold::check(cx, expr, init, acc, span),
 +            ("for_each", [_]) => {
 +                if let Some(("inspect", [_, _], span2)) = method_call(recv) {
 +                    inspect_for_each::check(cx, expr, span2);
 +                }
 +            },
 +            ("get_or_insert_with", [arg]) => unnecessary_lazy_eval::check(cx, expr, recv, arg, "get_or_insert"),
 +            ("is_file", []) => filetype_is_file::check(cx, expr, recv),
 +            ("is_none", []) => check_is_some_is_none(cx, expr, recv, false),
 +            ("is_some", []) => check_is_some_is_none(cx, expr, recv, true),
 +            ("last", args @ []) | ("skip", args @ [_]) => {
 +                if let Some((name2, [recv2, args2 @ ..], _span2)) = method_call(recv) {
 +                    if let ("cloned", []) = (name2, args2) {
 +                        iter_overeager_cloned::check(cx, expr, recv2, name, args);
 +                    }
 +                }
 +            },
 +            ("map", [m_arg]) => {
 +                if let Some((name, [recv2, args @ ..], span2)) = method_call(recv) {
 +                    match (name, args) {
 +                        ("as_mut", []) => option_as_ref_deref::check(cx, expr, recv2, m_arg, true, msrv),
 +                        ("as_ref", []) => option_as_ref_deref::check(cx, expr, recv2, m_arg, false, msrv),
 +                        ("filter", [f_arg]) => {
 +                            filter_map::check(cx, expr, recv2, f_arg, span2, recv, m_arg, span, false);
 +                        },
 +                        ("find", [f_arg]) => filter_map::check(cx, expr, recv2, f_arg, span2, recv, m_arg, span, true),
 +                        _ => {},
 +                    }
 +                }
 +                map_identity::check(cx, expr, recv, m_arg, span);
 +            },
 +            ("map_or", [def, map]) => option_map_or_none::check(cx, expr, recv, def, map),
 +            (name @ "next", args @ []) => {
 +                if let Some((name2, [recv2, args2 @ ..], _)) = method_call(recv) {
 +                    match (name2, args2) {
 +                        ("cloned", []) => iter_overeager_cloned::check(cx, expr, recv2, name, args),
 +                        ("filter", [arg]) => filter_next::check(cx, expr, recv2, arg),
 +                        ("filter_map", [arg]) => filter_map_next::check(cx, expr, recv2, arg, msrv),
 +                        ("iter", []) => iter_next_slice::check(cx, expr, recv2),
 +                        ("skip", [arg]) => iter_skip_next::check(cx, expr, recv2, arg),
 +                        ("skip_while", [_]) => skip_while_next::check(cx, expr),
 +                        _ => {},
 +                    }
 +                }
 +            },
 +            ("nth", args @ [n_arg]) => match method_call(recv) {
 +                Some(("bytes", [recv2], _)) => bytes_nth::check(cx, expr, recv2, n_arg),
 +                Some(("cloned", [recv2], _)) => iter_overeager_cloned::check(cx, expr, recv2, name, args),
 +                Some(("iter", [recv2], _)) => iter_nth::check(cx, expr, recv2, recv, n_arg, false),
 +                Some(("iter_mut", [recv2], _)) => iter_nth::check(cx, expr, recv2, recv, n_arg, true),
 +                _ => iter_nth_zero::check(cx, expr, recv, n_arg),
 +            },
 +            ("ok_or_else", [arg]) => unnecessary_lazy_eval::check(cx, expr, recv, arg, "ok_or"),
 +            ("or_else", [arg]) => {
 +                if !bind_instead_of_map::ResultOrElseErrInfo::check(cx, expr, recv, arg) {
 +                    unnecessary_lazy_eval::check(cx, expr, recv, arg, "or");
 +                }
 +            },
 +            ("splitn" | "rsplitn", [count_arg, pat_arg]) => {
 +                if let Some((Constant::Int(count), _)) = constant(cx, cx.typeck_results(), count_arg) {
 +                    suspicious_splitn::check(cx, name, expr, recv, count);
 +                    if count == 2 && meets_msrv(msrv, &msrvs::STR_SPLIT_ONCE) {
 +                        str_splitn::check_manual_split_once(cx, name, expr, recv, pat_arg);
 +                    }
 +                    if count >= 2 {
 +                        str_splitn::check_needless_splitn(cx, name, expr, recv, pat_arg, count);
 +                    }
 +                }
 +            },
 +            ("splitn_mut" | "rsplitn_mut", [count_arg, _]) => {
 +                if let Some((Constant::Int(count), _)) = constant(cx, cx.typeck_results(), count_arg) {
 +                    suspicious_splitn::check(cx, name, expr, recv, count);
 +                }
 +            },
 +            ("step_by", [arg]) => iterator_step_by_zero::check(cx, expr, arg),
 +            ("take", args @ [_arg]) => {
 +                if let Some((name2, [recv2, args2 @ ..], _span2)) = method_call(recv) {
 +                    if let ("cloned", []) = (name2, args2) {
 +                        iter_overeager_cloned::check(cx, expr, recv2, name, args);
 +                    }
 +                }
 +            },
 +            ("to_os_string" | "to_owned" | "to_path_buf" | "to_vec", []) => {
 +                implicit_clone::check(cx, name, expr, recv);
 +            },
 +            ("unwrap", []) => match method_call(recv) {
 +                Some(("get", [recv, get_arg], _)) => get_unwrap::check(cx, expr, recv, get_arg, false),
 +                Some(("get_mut", [recv, get_arg], _)) => get_unwrap::check(cx, expr, recv, get_arg, true),
 +                _ => unwrap_used::check(cx, expr, recv),
 +            },
 +            ("unwrap_or", [u_arg]) => match method_call(recv) {
 +                Some((arith @ ("checked_add" | "checked_sub" | "checked_mul"), [lhs, rhs], _)) => {
 +                    manual_saturating_arithmetic::check(cx, expr, lhs, rhs, u_arg, &arith["checked_".len()..]);
 +                },
 +                Some(("map", [m_recv, m_arg], span)) => {
 +                    option_map_unwrap_or::check(cx, expr, m_recv, m_arg, recv, u_arg, span);
 +                },
 +                _ => {},
 +            },
 +            ("unwrap_or_else", [u_arg]) => match method_call(recv) {
 +                Some(("map", [recv, map_arg], _)) if map_unwrap_or::check(cx, expr, recv, map_arg, u_arg, msrv) => {},
 +                _ => {
 +                    unwrap_or_else_default::check(cx, expr, recv, u_arg);
 +                    unnecessary_lazy_eval::check(cx, expr, recv, u_arg, "unwrap_or");
 +                },
 +            },
 +            _ => {},
 +        }
 +    }
 +}
 +
 +fn check_is_some_is_none(cx: &LateContext<'_>, expr: &Expr<'_>, recv: &Expr<'_>, is_some: bool) {
 +    if let Some((name @ ("find" | "position" | "rposition"), [f_recv, arg], span)) = method_call(recv) {
 +        search_is_some::check(cx, expr, name, is_some, f_recv, arg, recv, span);
 +    }
 +}
 +
 +/// Used for `lint_binary_expr_with_method_call`.
 +#[derive(Copy, Clone)]
 +struct BinaryExprInfo<'a> {
 +    expr: &'a hir::Expr<'a>,
 +    chain: &'a hir::Expr<'a>,
 +    other: &'a hir::Expr<'a>,
 +    eq: bool,
 +}
 +
 +/// Checks for the `CHARS_NEXT_CMP` and `CHARS_LAST_CMP` lints.
 +fn lint_binary_expr_with_method_call(cx: &LateContext<'_>, info: &mut BinaryExprInfo<'_>) {
 +    macro_rules! lint_with_both_lhs_and_rhs {
 +        ($func:expr, $cx:expr, $info:ident) => {
 +            if !$func($cx, $info) {
 +                ::std::mem::swap(&mut $info.chain, &mut $info.other);
 +                if $func($cx, $info) {
 +                    return;
 +                }
 +            }
 +        };
 +    }
 +
 +    lint_with_both_lhs_and_rhs!(chars_next_cmp::check, cx, info);
 +    lint_with_both_lhs_and_rhs!(chars_last_cmp::check, cx, info);
 +    lint_with_both_lhs_and_rhs!(chars_next_cmp_with_unwrap::check, cx, info);
 +    lint_with_both_lhs_and_rhs!(chars_last_cmp_with_unwrap::check, cx, info);
 +}
 +
 +const FN_HEADER: hir::FnHeader = hir::FnHeader {
 +    unsafety: hir::Unsafety::Normal,
 +    constness: hir::Constness::NotConst,
 +    asyncness: hir::IsAsync::NotAsync,
 +    abi: rustc_target::spec::abi::Abi::Rust,
 +};
 +
 +struct ShouldImplTraitCase {
 +    trait_name: &'static str,
 +    method_name: &'static str,
 +    param_count: usize,
 +    fn_header: hir::FnHeader,
 +    // implicit self kind expected (none, self, &self, ...)
 +    self_kind: SelfKind,
 +    // checks against the output type
 +    output_type: OutType,
 +    // certain methods with explicit lifetimes can't implement the equivalent trait method
 +    lint_explicit_lifetime: bool,
 +}
 +impl ShouldImplTraitCase {
 +    const fn new(
 +        trait_name: &'static str,
 +        method_name: &'static str,
 +        param_count: usize,
 +        fn_header: hir::FnHeader,
 +        self_kind: SelfKind,
 +        output_type: OutType,
 +        lint_explicit_lifetime: bool,
 +    ) -> ShouldImplTraitCase {
 +        ShouldImplTraitCase {
 +            trait_name,
 +            method_name,
 +            param_count,
 +            fn_header,
 +            self_kind,
 +            output_type,
 +            lint_explicit_lifetime,
 +        }
 +    }
 +
 +    fn lifetime_param_cond(&self, impl_item: &hir::ImplItem<'_>) -> bool {
 +        self.lint_explicit_lifetime
 +            || !impl_item.generics.params.iter().any(|p| {
 +                matches!(
 +                    p.kind,
 +                    hir::GenericParamKind::Lifetime {
 +                        kind: hir::LifetimeParamKind::Explicit
 +                    }
 +                )
 +            })
 +    }
 +}
 +
 +#[rustfmt::skip]
 +const TRAIT_METHODS: [ShouldImplTraitCase; 30] = [
 +    ShouldImplTraitCase::new("std::ops::Add", "add",  2,  FN_HEADER,  SelfKind::Value,  OutType::Any, true),
 +    ShouldImplTraitCase::new("std::convert::AsMut", "as_mut",  1,  FN_HEADER,  SelfKind::RefMut,  OutType::Ref, true),
 +    ShouldImplTraitCase::new("std::convert::AsRef", "as_ref",  1,  FN_HEADER,  SelfKind::Ref,  OutType::Ref, true),
 +    ShouldImplTraitCase::new("std::ops::BitAnd", "bitand",  2,  FN_HEADER,  SelfKind::Value,  OutType::Any, true),
 +    ShouldImplTraitCase::new("std::ops::BitOr", "bitor",  2,  FN_HEADER,  SelfKind::Value,  OutType::Any, true),
 +    ShouldImplTraitCase::new("std::ops::BitXor", "bitxor",  2,  FN_HEADER,  SelfKind::Value,  OutType::Any, true),
 +    ShouldImplTraitCase::new("std::borrow::Borrow", "borrow",  1,  FN_HEADER,  SelfKind::Ref,  OutType::Ref, true),
 +    ShouldImplTraitCase::new("std::borrow::BorrowMut", "borrow_mut",  1,  FN_HEADER,  SelfKind::RefMut,  OutType::Ref, true),
 +    ShouldImplTraitCase::new("std::clone::Clone", "clone",  1,  FN_HEADER,  SelfKind::Ref,  OutType::Any, true),
 +    ShouldImplTraitCase::new("std::cmp::Ord", "cmp",  2,  FN_HEADER,  SelfKind::Ref,  OutType::Any, true),
 +    // FIXME: default doesn't work
 +    ShouldImplTraitCase::new("std::default::Default", "default",  0,  FN_HEADER,  SelfKind::No,  OutType::Any, true),
 +    ShouldImplTraitCase::new("std::ops::Deref", "deref",  1,  FN_HEADER,  SelfKind::Ref,  OutType::Ref, true),
 +    ShouldImplTraitCase::new("std::ops::DerefMut", "deref_mut",  1,  FN_HEADER,  SelfKind::RefMut,  OutType::Ref, true),
 +    ShouldImplTraitCase::new("std::ops::Div", "div",  2,  FN_HEADER,  SelfKind::Value,  OutType::Any, true),
 +    ShouldImplTraitCase::new("std::ops::Drop", "drop",  1,  FN_HEADER,  SelfKind::RefMut,  OutType::Unit, true),
 +    ShouldImplTraitCase::new("std::cmp::PartialEq", "eq",  2,  FN_HEADER,  SelfKind::Ref,  OutType::Bool, true),
 +    ShouldImplTraitCase::new("std::iter::FromIterator", "from_iter",  1,  FN_HEADER,  SelfKind::No,  OutType::Any, true),
 +    ShouldImplTraitCase::new("std::str::FromStr", "from_str",  1,  FN_HEADER,  SelfKind::No,  OutType::Any, true),
 +    ShouldImplTraitCase::new("std::hash::Hash", "hash",  2,  FN_HEADER,  SelfKind::Ref,  OutType::Unit, true),
 +    ShouldImplTraitCase::new("std::ops::Index", "index",  2,  FN_HEADER,  SelfKind::Ref,  OutType::Ref, true),
 +    ShouldImplTraitCase::new("std::ops::IndexMut", "index_mut",  2,  FN_HEADER,  SelfKind::RefMut,  OutType::Ref, true),
 +    ShouldImplTraitCase::new("std::iter::IntoIterator", "into_iter",  1,  FN_HEADER,  SelfKind::Value,  OutType::Any, true),
 +    ShouldImplTraitCase::new("std::ops::Mul", "mul",  2,  FN_HEADER,  SelfKind::Value,  OutType::Any, true),
 +    ShouldImplTraitCase::new("std::ops::Neg", "neg",  1,  FN_HEADER,  SelfKind::Value,  OutType::Any, true),
 +    ShouldImplTraitCase::new("std::iter::Iterator", "next",  1,  FN_HEADER,  SelfKind::RefMut,  OutType::Any, false),
 +    ShouldImplTraitCase::new("std::ops::Not", "not",  1,  FN_HEADER,  SelfKind::Value,  OutType::Any, true),
 +    ShouldImplTraitCase::new("std::ops::Rem", "rem",  2,  FN_HEADER,  SelfKind::Value,  OutType::Any, true),
 +    ShouldImplTraitCase::new("std::ops::Shl", "shl",  2,  FN_HEADER,  SelfKind::Value,  OutType::Any, true),
 +    ShouldImplTraitCase::new("std::ops::Shr", "shr",  2,  FN_HEADER,  SelfKind::Value,  OutType::Any, true),
 +    ShouldImplTraitCase::new("std::ops::Sub", "sub",  2,  FN_HEADER,  SelfKind::Value,  OutType::Any, true),
 +];
 +
 +#[derive(Clone, Copy, PartialEq, Debug)]
 +enum SelfKind {
 +    Value,
 +    Ref,
 +    RefMut,
 +    No,
 +}
 +
 +impl SelfKind {
 +    fn matches<'a>(self, cx: &LateContext<'a>, parent_ty: Ty<'a>, ty: Ty<'a>) -> bool {
 +        fn matches_value<'a>(cx: &LateContext<'a>, parent_ty: Ty<'_>, ty: Ty<'_>) -> bool {
 +            if ty == parent_ty {
 +                true
 +            } else if ty.is_box() {
 +                ty.boxed_ty() == parent_ty
 +            } else if is_type_diagnostic_item(cx, ty, sym::Rc) || is_type_diagnostic_item(cx, ty, sym::Arc) {
 +                if let ty::Adt(_, substs) = ty.kind() {
 +                    substs.types().next().map_or(false, |t| t == parent_ty)
 +                } else {
 +                    false
 +                }
 +            } else {
 +                false
 +            }
 +        }
 +
 +        fn matches_ref<'a>(cx: &LateContext<'a>, mutability: hir::Mutability, parent_ty: Ty<'a>, ty: Ty<'a>) -> bool {
 +            if let ty::Ref(_, t, m) = *ty.kind() {
 +                return m == mutability && t == parent_ty;
 +            }
 +
 +            let trait_path = match mutability {
 +                hir::Mutability::Not => &paths::ASREF_TRAIT,
 +                hir::Mutability::Mut => &paths::ASMUT_TRAIT,
 +            };
 +
 +            let trait_def_id = match get_trait_def_id(cx, trait_path) {
 +                Some(did) => did,
 +                None => return false,
 +            };
 +            implements_trait(cx, ty, trait_def_id, &[parent_ty.into()])
 +        }
 +
 +        fn matches_none<'a>(cx: &LateContext<'a>, parent_ty: Ty<'a>, ty: Ty<'a>) -> bool {
 +            !matches_value(cx, parent_ty, ty)
 +                && !matches_ref(cx, hir::Mutability::Not, parent_ty, ty)
 +                && !matches_ref(cx, hir::Mutability::Mut, parent_ty, ty)
 +        }
 +
 +        match self {
 +            Self::Value => matches_value(cx, parent_ty, ty),
 +            Self::Ref => matches_ref(cx, hir::Mutability::Not, parent_ty, ty) || ty == parent_ty && is_copy(cx, ty),
 +            Self::RefMut => matches_ref(cx, hir::Mutability::Mut, parent_ty, ty),
 +            Self::No => matches_none(cx, parent_ty, ty),
 +        }
 +    }
 +
 +    #[must_use]
 +    fn description(self) -> &'static str {
 +        match self {
 +            Self::Value => "`self` by value",
 +            Self::Ref => "`self` by reference",
 +            Self::RefMut => "`self` by mutable reference",
 +            Self::No => "no `self`",
 +        }
 +    }
 +}
 +
 +#[derive(Clone, Copy)]
 +enum OutType {
 +    Unit,
 +    Bool,
 +    Any,
 +    Ref,
 +}
 +
 +impl OutType {
 +    fn matches(self, ty: &hir::FnRetTy<'_>) -> bool {
 +        let is_unit = |ty: &hir::Ty<'_>| matches!(ty.kind, hir::TyKind::Tup(&[]));
 +        match (self, ty) {
 +            (Self::Unit, &hir::FnRetTy::DefaultReturn(_)) => true,
 +            (Self::Unit, &hir::FnRetTy::Return(ty)) if is_unit(ty) => true,
 +            (Self::Bool, &hir::FnRetTy::Return(ty)) if is_bool(ty) => true,
 +            (Self::Any, &hir::FnRetTy::Return(ty)) if !is_unit(ty) => true,
 +            (Self::Ref, &hir::FnRetTy::Return(ty)) => matches!(ty.kind, hir::TyKind::Rptr(_, _)),
 +            _ => false,
 +        }
 +    }
 +}
 +
 +fn is_bool(ty: &hir::Ty<'_>) -> bool {
 +    if let hir::TyKind::Path(QPath::Resolved(_, path)) = ty.kind {
 +        matches!(path.res, Res::PrimTy(PrimTy::Bool))
 +    } else {
 +        false
 +    }
 +}
 +
 +fn fn_header_equals(expected: hir::FnHeader, actual: hir::FnHeader) -> bool {
 +    expected.constness == actual.constness
 +        && expected.unsafety == actual.unsafety
 +        && expected.asyncness == actual.asyncness
 +}
index 0e7ae43ce2dd53df347a380c4321f24b50f6cd51,0000000000000000000000000000000000000000..d4c823d1c1ab77324efb77f0076831ff8131eb0e
mode 100644,000000..100644
--- /dev/null
@@@ -1,125 -1,0 +1,144 @@@
- use rustc_hir::{Body, Expr, ExprKind, LangItem, MatchSource, QPath};
 +use clippy_utils::diagnostics::span_lint_and_sugg;
 +use clippy_utils::is_lang_ctor;
 +use clippy_utils::source::snippet;
 +use if_chain::if_chain;
 +use rustc_errors::Applicability;
 +use rustc_hir::LangItem::{OptionSome, ResultOk};
-         check(cx, body.value.peel_blocks());
++use rustc_hir::{AsyncGeneratorKind, Block, Body, Expr, ExprKind, GeneratorKind, LangItem, MatchSource, QPath};
 +use rustc_lint::{LateContext, LateLintPass};
 +use rustc_middle::ty::TyS;
 +use rustc_session::{declare_lint_pass, declare_tool_lint};
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Suggests alternatives for useless applications of `?` in terminating expressions
 +    ///
 +    /// ### Why is this bad?
 +    /// There's no reason to use `?` to short-circuit when execution of the body will end there anyway.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// struct TO {
 +    ///     magic: Option<usize>,
 +    /// }
 +    ///
 +    /// fn f(to: TO) -> Option<usize> {
 +    ///     Some(to.magic?)
 +    /// }
 +    ///
 +    /// struct TR {
 +    ///     magic: Result<usize, bool>,
 +    /// }
 +    ///
 +    /// fn g(tr: Result<TR, bool>) -> Result<usize, bool> {
 +    ///     tr.and_then(|t| Ok(t.magic?))
 +    /// }
 +    ///
 +    /// ```
 +    /// Use instead:
 +    /// ```rust
 +    /// struct TO {
 +    ///     magic: Option<usize>,
 +    /// }
 +    ///
 +    /// fn f(to: TO) -> Option<usize> {
 +    ///    to.magic
 +    /// }
 +    ///
 +    /// struct TR {
 +    ///     magic: Result<usize, bool>,
 +    /// }
 +    ///
 +    /// fn g(tr: Result<TR, bool>) -> Result<usize, bool> {
 +    ///     tr.and_then(|t| t.magic)
 +    /// }
 +    /// ```
 +    #[clippy::version = "1.51.0"]
 +    pub NEEDLESS_QUESTION_MARK,
 +    complexity,
 +    "Suggest `value.inner_option` instead of `Some(value.inner_option?)`. The same goes for `Result<T, E>`."
 +}
 +
 +declare_lint_pass!(NeedlessQuestionMark => [NEEDLESS_QUESTION_MARK]);
 +
 +impl LateLintPass<'_> for NeedlessQuestionMark {
 +    /*
 +     * The question mark operator is compatible with both Result<T, E> and Option<T>,
 +     * from Rust 1.13 and 1.22 respectively.
 +     */
 +
 +    /*
 +     * What do we match:
 +     * Expressions that look like this:
 +     * Some(option?), Ok(result?)
 +     *
 +     * Where do we match:
 +     *      Last expression of a body
 +     *      Return statement
 +     *      A body's value (single line closure)
 +     *
 +     * What do we not match:
 +     *      Implicit calls to `from(..)` on the error value
 +     */
 +
 +    fn check_expr(&mut self, cx: &LateContext<'_>, expr: &'_ Expr<'_>) {
 +        if let ExprKind::Ret(Some(e)) = expr.kind {
 +            check(cx, e);
 +        }
 +    }
 +
 +    fn check_body(&mut self, cx: &LateContext<'_>, body: &'_ Body<'_>) {
++        if let Some(GeneratorKind::Async(AsyncGeneratorKind::Fn)) = body.generator_kind {
++            if let ExprKind::Block(
++                Block {
++                    expr:
++                        Some(Expr {
++                            kind: ExprKind::DropTemps(async_body),
++                            ..
++                        }),
++                    ..
++                },
++                _,
++            ) = body.value.kind
++            {
++                if let ExprKind::Block(Block { expr: Some(expr), .. }, ..) = async_body.kind {
++                    check(cx, expr);
++                }
++            }
++        } else {
++            check(cx, body.value.peel_blocks());
++        }
 +    }
 +}
 +
 +fn check(cx: &LateContext<'_>, expr: &Expr<'_>) {
 +    if_chain! {
 +        if let ExprKind::Call(path, [arg]) = &expr.kind;
 +        if let ExprKind::Path(ref qpath) = &path.kind;
 +        let sugg_remove = if is_lang_ctor(cx, qpath, OptionSome) {
 +            "Some()"
 +        } else if is_lang_ctor(cx, qpath, ResultOk) {
 +            "Ok()"
 +        } else {
 +            return;
 +        };
 +        if let ExprKind::Match(inner_expr_with_q, _, MatchSource::TryDesugar) = &arg.kind;
 +        if let ExprKind::Call(called, [inner_expr]) = &inner_expr_with_q.kind;
 +        if let ExprKind::Path(QPath::LangItem(LangItem::TryTraitBranch, ..)) = &called.kind;
 +        if expr.span.ctxt() == inner_expr.span.ctxt();
 +        let expr_ty = cx.typeck_results().expr_ty(expr);
 +        let inner_ty = cx.typeck_results().expr_ty(inner_expr);
 +        if TyS::same_type(expr_ty, inner_ty);
 +        then {
 +            span_lint_and_sugg(
 +                cx,
 +                NEEDLESS_QUESTION_MARK,
 +                expr.span,
 +                "question mark operator is useless here",
 +                &format!("try removing question mark and `{}`", sugg_remove),
 +                format!("{}", snippet(cx, inner_expr.span, r#""...""#)),
 +                Applicability::MachineApplicable,
 +            );
 +        }
 +    }
 +}
index d81481ade044d255d843fab0262669ca48c19ea1,0000000000000000000000000000000000000000..c19cea661042d4c81a34572ec178f25aed6839d3
mode 100644,000000..100644
--- /dev/null
@@@ -1,150 -1,0 +1,150 @@@
-             write!(&mut suggest_1, "\\x{:02x}", n).unwrap();
 +use clippy_utils::diagnostics::span_lint_and_then;
 +use rustc_ast::ast::{Expr, ExprKind};
 +use rustc_ast::token::{Lit, LitKind};
 +use rustc_errors::Applicability;
 +use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
 +use rustc_middle::lint::in_external_macro;
 +use rustc_session::{declare_lint_pass, declare_tool_lint};
 +use rustc_span::Span;
 +use std::fmt::Write;
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for `\0` escapes in string and byte literals that look like octal
 +    /// character escapes in C.
 +    ///
 +    /// ### Why is this bad?
 +    ///
 +    /// C and other languages support octal character escapes in strings, where
 +    /// a backslash is followed by up to three octal digits. For example, `\033`
 +    /// stands for the ASCII character 27 (ESC). Rust does not support this
 +    /// notation, but has the escape code `\0` which stands for a null
 +    /// byte/character, and any following digits do not form part of the escape
 +    /// sequence. Therefore, `\033` is not a compiler error but the result may
 +    /// be surprising.
 +    ///
 +    /// ### Known problems
 +    /// The actual meaning can be the intended one. `\x00` can be used in these
 +    /// cases to be unambigious.
 +    ///
 +    /// The lint does not trigger for format strings in `print!()`, `write!()`
 +    /// and friends since the string is already preprocessed when Clippy lints
 +    /// can see it.
 +    ///
 +    /// # Example
 +    /// ```rust
 +    /// // Bad
 +    /// let one = "\033[1m Bold? \033[0m";  // \033 intended as escape
 +    /// let two = "\033\0";                 // \033 intended as null-3-3
 +    ///
 +    /// // Good
 +    /// let one = "\x1b[1mWill this be bold?\x1b[0m";
 +    /// let two = "\x0033\x00";
 +    /// ```
 +    #[clippy::version = "1.58.0"]
 +    pub OCTAL_ESCAPES,
 +    suspicious,
 +    "string escape sequences looking like octal characters"
 +}
 +
 +declare_lint_pass!(OctalEscapes => [OCTAL_ESCAPES]);
 +
 +impl EarlyLintPass for OctalEscapes {
 +    fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) {
 +        if in_external_macro(cx.sess(), expr.span) {
 +            return;
 +        }
 +
 +        if let ExprKind::Lit(lit) = &expr.kind {
 +            if matches!(lit.token.kind, LitKind::Str) {
 +                check_lit(cx, &lit.token, lit.span, true);
 +            } else if matches!(lit.token.kind, LitKind::ByteStr) {
 +                check_lit(cx, &lit.token, lit.span, false);
 +            }
 +        }
 +    }
 +}
 +
 +fn check_lit(cx: &EarlyContext<'_>, lit: &Lit, span: Span, is_string: bool) {
 +    let contents = lit.symbol.as_str();
 +    let mut iter = contents.char_indices().peekable();
 +    let mut found = vec![];
 +
 +    // go through the string, looking for \0[0-7][0-7]?
 +    while let Some((from, ch)) = iter.next() {
 +        if ch == '\\' {
 +            if let Some((_, '0')) = iter.next() {
 +                // collect up to two further octal digits
 +                if let Some((mut to, '0'..='7')) = iter.next() {
 +                    if let Some((_, '0'..='7')) = iter.peek() {
 +                        to += 1;
 +                    }
 +                    found.push((from, to + 1));
 +                }
 +            }
 +        }
 +    }
 +
 +    if found.is_empty() {
 +        return;
 +    }
 +
 +    // construct two suggestion strings, one with \x escapes with octal meaning
 +    // as in C, and one with \x00 for null bytes.
 +    let mut suggest_1 = if is_string { "\"" } else { "b\"" }.to_string();
 +    let mut suggest_2 = suggest_1.clone();
 +    let mut index = 0;
 +    for (from, to) in found {
 +        suggest_1.push_str(&contents[index..from]);
 +        suggest_2.push_str(&contents[index..from]);
 +
 +        // construct a replacement escape
 +        // the maximum value is \077, or \x3f, so u8 is sufficient here
 +        if let Ok(n) = u8::from_str_radix(&contents[from + 1..to], 8) {
++            write!(suggest_1, "\\x{:02x}", n).unwrap();
 +        }
 +
 +        // append the null byte as \x00 and the following digits literally
 +        suggest_2.push_str("\\x00");
 +        suggest_2.push_str(&contents[from + 2..to]);
 +
 +        index = to;
 +    }
 +    suggest_1.push_str(&contents[index..]);
 +    suggest_1.push('"');
 +    suggest_2.push_str(&contents[index..]);
 +    suggest_2.push('"');
 +
 +    span_lint_and_then(
 +        cx,
 +        OCTAL_ESCAPES,
 +        span,
 +        &format!(
 +            "octal-looking escape in {} literal",
 +            if is_string { "string" } else { "byte string" }
 +        ),
 +        |diag| {
 +            diag.help(&format!(
 +                "octal escapes are not supported, `\\0` is always a null {}",
 +                if is_string { "character" } else { "byte" }
 +            ));
 +            // suggestion 1: equivalent hex escape
 +            diag.span_suggestion(
 +                span,
 +                "if an octal escape was intended, use the hexadecimal representation instead",
 +                suggest_1,
 +                Applicability::MaybeIncorrect,
 +            );
 +            // suggestion 2: unambiguous null byte
 +            diag.span_suggestion(
 +                span,
 +                &format!(
 +                    "if the null {} is intended, disambiguate using",
 +                    if is_string { "character" } else { "byte" }
 +                ),
 +                suggest_2,
 +                Applicability::MaybeIncorrect,
 +            );
 +        },
 +    );
 +}
index 63de117a6f1dec08737ffb022427062517570395,0000000000000000000000000000000000000000..b5d65542de0bf1c068279149bb67df8615006a81
mode 100644,000000..100644
--- /dev/null
@@@ -1,449 -1,0 +1,674 @@@
- use clippy_utils::ptr::get_spans;
 +//! Checks for usage of  `&Vec[_]` and `&String`.
 +
 +use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg, span_lint_and_then};
- use clippy_utils::ty::walk_ptrs_hir_ty;
- use clippy_utils::{expr_path_res, is_lint_allowed, match_any_diagnostic_items, paths};
 +use clippy_utils::source::snippet_opt;
- use rustc_hir::def::Res;
++use clippy_utils::ty::expr_sig;
++use clippy_utils::{
++    expr_path_res, get_expr_use_or_unification_node, is_lint_allowed, match_any_diagnostic_items, path_to_local, paths,
++};
 +use if_chain::if_chain;
 +use rustc_errors::Applicability;
-     BinOpKind, BodyId, Expr, ExprKind, FnDecl, FnRetTy, GenericArg, Impl, ImplItem, ImplItemKind, Item, ItemKind,
-     Lifetime, MutTy, Mutability, Node, PathSegment, QPath, TraitFn, TraitItem, TraitItemKind, Ty, TyKind,
++use rustc_hir::def_id::DefId;
++use rustc_hir::hir_id::HirIdMap;
++use rustc_hir::intravisit::{walk_expr, Visitor};
 +use rustc_hir::{
- use std::borrow::Cow;
++    self as hir, AnonConst, BinOpKind, BindingAnnotation, Body, Expr, ExprKind, FnDecl, FnRetTy, GenericArg,
++    ImplItemKind, ItemKind, Lifetime, LifetimeName, Mutability, Node, Param, ParamName, PatKind, QPath, TraitFn,
++    TraitItem, TraitItemKind, TyKind,
 +};
 +use rustc_lint::{LateContext, LateLintPass};
++use rustc_middle::hir::nested_filter;
++use rustc_middle::ty::{self, AssocItems, AssocKind, Ty};
 +use rustc_session::{declare_lint_pass, declare_tool_lint};
 +use rustc_span::source_map::Span;
 +use rustc_span::symbol::Symbol;
 +use rustc_span::{sym, MultiSpan};
-     /// This lint checks for function arguments of type `&String`
-     /// or `&Vec` unless the references are mutable. It will also suggest you
-     /// replace `.clone()` calls with the appropriate `.to_owned()`/`to_string()`
-     /// calls.
++use std::fmt;
++use std::iter;
 +
 +declare_clippy_lint! {
 +    /// ### What it does
-     /// The lint does not follow data. So if you have an
-     /// argument `x` and write `let y = x; y.clone()` the lint will not suggest
-     /// changing that `.clone()` to `.to_owned()`.
-     ///
-     /// Other functions called from this function taking a `&String` or `&Vec`
-     /// argument may also fail to compile if you change the argument. Applying
-     /// this lint on them will fix the problem, but they may be in other crates.
-     ///
-     /// One notable example of a function that may cause issues, and which cannot
-     /// easily be changed due to being in the standard library is `Vec::contains`.
-     /// when called on a `Vec<Vec<T>>`. If a `&Vec` is passed to that method then
-     /// it will compile, but if a `&[T]` is passed then it will not compile.
-     ///
-     /// ```ignore
-     /// fn cannot_take_a_slice(v: &Vec<u8>) -> bool {
-     ///     let vec_of_vecs: Vec<Vec<u8>> = some_other_fn();
-     ///
-     ///     vec_of_vecs.contains(v)
-     /// }
-     /// ```
-     ///
-     /// Also there may be `fn(&Vec)`-typed references pointing to your function.
++    /// This lint checks for function arguments of type `&String`, `&Vec`,
++    /// `&PathBuf`, and `Cow<_>`. It will also suggest you replace `.clone()` calls
++    /// with the appropriate `.to_owned()`/`to_string()` calls.
 +    ///
 +    /// ### Why is this bad?
 +    /// Requiring the argument to be of the specific size
 +    /// makes the function less useful for no benefit; slices in the form of `&[T]`
 +    /// or `&str` usually suffice and can be obtained from other types, too.
 +    ///
 +    /// ### Known problems
-     fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
-         if let ItemKind::Fn(ref sig, _, body_id) = item.kind {
-             check_fn(cx, sig.decl, Some(body_id));
-         }
-     }
++    /// There may be `fn(&Vec)`-typed references pointing to your function.
 +    /// If you have them, you will get a compiler error after applying this lint's
 +    /// suggestions. You then have the choice to undo your changes or change the
 +    /// type of the reference.
 +    ///
 +    /// Note that if the function is part of your public interface, there may be
 +    /// other crates referencing it, of which you may not be aware. Carefully
 +    /// deprecate the function before applying the lint suggestions in this case.
 +    ///
 +    /// ### Example
 +    /// ```ignore
 +    /// // Bad
 +    /// fn foo(&Vec<u32>) { .. }
 +    ///
 +    /// // Good
 +    /// fn foo(&[u32]) { .. }
 +    /// ```
 +    #[clippy::version = "pre 1.29.0"]
 +    pub PTR_ARG,
 +    style,
 +    "fn arguments of the type `&Vec<...>` or `&String`, suggesting to use `&[...]` or `&str` instead, respectively"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// This lint checks for equality comparisons with `ptr::null`
 +    ///
 +    /// ### Why is this bad?
 +    /// It's easier and more readable to use the inherent
 +    /// `.is_null()`
 +    /// method instead
 +    ///
 +    /// ### Example
 +    /// ```ignore
 +    /// // Bad
 +    /// if x == ptr::null {
 +    ///     ..
 +    /// }
 +    ///
 +    /// // Good
 +    /// if x.is_null() {
 +    ///     ..
 +    /// }
 +    /// ```
 +    #[clippy::version = "pre 1.29.0"]
 +    pub CMP_NULL,
 +    style,
 +    "comparing a pointer to a null pointer, suggesting to use `.is_null()` instead"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// This lint checks for functions that take immutable
 +    /// references and return mutable ones.
 +    ///
 +    /// ### Why is this bad?
 +    /// This is trivially unsound, as one can create two
 +    /// mutable references from the same (immutable!) source.
 +    /// This [error](https://github.com/rust-lang/rust/issues/39465)
 +    /// actually lead to an interim Rust release 1.15.1.
 +    ///
 +    /// ### Known problems
 +    /// To be on the conservative side, if there's at least one
 +    /// mutable reference with the output lifetime, this lint will not trigger.
 +    /// In practice, this case is unlikely anyway.
 +    ///
 +    /// ### Example
 +    /// ```ignore
 +    /// fn foo(&Foo) -> &mut Bar { .. }
 +    /// ```
 +    #[clippy::version = "pre 1.29.0"]
 +    pub MUT_FROM_REF,
 +    correctness,
 +    "fns that create mutable refs from immutable ref args"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// This lint checks for invalid usages of `ptr::null`.
 +    ///
 +    /// ### Why is this bad?
 +    /// This causes undefined behavior.
 +    ///
 +    /// ### Example
 +    /// ```ignore
 +    /// // Bad. Undefined behavior
 +    /// unsafe { std::slice::from_raw_parts(ptr::null(), 0); }
 +    /// ```
 +    ///
 +    /// ```ignore
 +    /// // Good
 +    /// unsafe { std::slice::from_raw_parts(NonNull::dangling().as_ptr(), 0); }
 +    /// ```
 +    #[clippy::version = "1.53.0"]
 +    pub INVALID_NULL_PTR_USAGE,
 +    correctness,
 +    "invalid usage of a null pointer, suggesting `NonNull::dangling()` instead"
 +}
 +
 +declare_lint_pass!(Ptr => [PTR_ARG, CMP_NULL, MUT_FROM_REF, INVALID_NULL_PTR_USAGE]);
 +
 +impl<'tcx> LateLintPass<'tcx> for Ptr {
-     fn check_impl_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx ImplItem<'_>) {
-         if let ImplItemKind::Fn(ref sig, body_id) = item.kind {
-             let parent_item = cx.tcx.hir().get_parent_item(item.hir_id());
-             if let Some(Node::Item(it)) = cx.tcx.hir().find_by_def_id(parent_item) {
-                 if let ItemKind::Impl(Impl { of_trait: Some(_), .. }) = it.kind {
-                     return; // ignore trait impls
-                 }
++    fn check_trait_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx TraitItem<'_>) {
++        if let TraitItemKind::Fn(sig, trait_method) = &item.kind {
++            if matches!(trait_method, TraitFn::Provided(_)) {
++                // Handled by check body.
++                return;
++            }
 +
-             check_fn(cx, sig.decl, Some(body_id));
++            check_mut_from_ref(cx, sig.decl);
++            for arg in check_fn_args(
++                cx,
++                cx.tcx.fn_sig(item.def_id).skip_binder().inputs(),
++                sig.decl.inputs,
++                &[],
++            ) {
++                span_lint_and_sugg(
++                    cx,
++                    PTR_ARG,
++                    arg.span,
++                    &arg.build_msg(),
++                    "change this to",
++                    format!("{}{}", arg.ref_prefix, arg.deref_ty.display(cx)),
++                    Applicability::Unspecified,
++                );
 +            }
-     fn check_trait_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx TraitItem<'_>) {
-         if let TraitItemKind::Fn(ref sig, ref trait_method) = item.kind {
-             let body_id = if let TraitFn::Provided(b) = *trait_method {
-                 Some(b)
-             } else {
-                 None
-             };
-             check_fn(cx, sig.decl, body_id);
 +        }
 +    }
 +
- #[allow(clippy::too_many_lines)]
- fn check_fn(cx: &LateContext<'_>, decl: &FnDecl<'_>, opt_body_id: Option<BodyId>) {
-     let body = opt_body_id.map(|id| cx.tcx.hir().body(id));
-     for (idx, arg) in decl.inputs.iter().enumerate() {
-         // Honor the allow attribute on parameters. See issue 5644.
-         if let Some(body) = &body {
-             if is_lint_allowed(cx, PTR_ARG, body.params[idx].hir_id) {
-                 continue;
-             }
-         }
++    fn check_body(&mut self, cx: &LateContext<'tcx>, body: &'tcx Body<'_>) {
++        let hir = cx.tcx.hir();
++        let mut parents = hir.parent_iter(body.value.hir_id);
++        let (item_id, decl) = match parents.next() {
++            Some((_, Node::Item(i))) => {
++                if let ItemKind::Fn(sig, ..) = &i.kind {
++                    (i.def_id, sig.decl)
++                } else {
++                    return;
++                }
++            },
++            Some((_, Node::ImplItem(i))) => {
++                if !matches!(parents.next(),
++                    Some((_, Node::Item(i))) if matches!(&i.kind, ItemKind::Impl(i) if i.of_trait.is_none())
++                ) {
++                    return;
++                }
++                if let ImplItemKind::Fn(sig, _) = &i.kind {
++                    (i.def_id, sig.decl)
++                } else {
++                    return;
++                }
++            },
++            Some((_, Node::TraitItem(i))) => {
++                if let TraitItemKind::Fn(sig, _) = &i.kind {
++                    (i.def_id, sig.decl)
++                } else {
++                    return;
++                }
++            },
++            _ => return,
++        };
++
++        check_mut_from_ref(cx, decl);
++        let sig = cx.tcx.fn_sig(item_id).skip_binder();
++        let lint_args: Vec<_> = check_fn_args(cx, sig.inputs(), decl.inputs, body.params).collect();
++        let results = check_ptr_arg_usage(cx, body, &lint_args);
++
++        for (result, args) in results.iter().zip(lint_args.iter()).filter(|(r, _)| !r.skip) {
++            span_lint_and_then(cx, PTR_ARG, args.span, &args.build_msg(), |diag| {
++                diag.multipart_suggestion(
++                    "change this to",
++                    iter::once((args.span, format!("{}{}", args.ref_prefix, args.deref_ty.display(cx))))
++                        .chain(result.replacements.iter().map(|r| {
++                            (
++                                r.expr_span,
++                                format!("{}{}", snippet_opt(cx, r.self_span).unwrap(), r.replacement),
++                            )
++                        }))
++                        .collect(),
++                    Applicability::Unspecified,
++                );
++            });
 +        }
 +    }
 +
 +    fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
 +        if let ExprKind::Binary(ref op, l, r) = expr.kind {
 +            if (op.node == BinOpKind::Eq || op.node == BinOpKind::Ne) && (is_null_path(cx, l) || is_null_path(cx, r)) {
 +                span_lint(
 +                    cx,
 +                    CMP_NULL,
 +                    expr.span,
 +                    "comparing with null is better expressed by the `.is_null()` method",
 +                );
 +            }
 +        } else {
 +            check_invalid_ptr_usage(cx, expr);
 +        }
 +    }
 +}
 +
 +fn check_invalid_ptr_usage<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
 +    // (fn_path, arg_indices) - `arg_indices` are the `arg` positions where null would cause U.B.
 +    const INVALID_NULL_PTR_USAGE_TABLE: [(&[&str], &[usize]); 16] = [
 +        (&paths::SLICE_FROM_RAW_PARTS, &[0]),
 +        (&paths::SLICE_FROM_RAW_PARTS_MUT, &[0]),
 +        (&paths::PTR_COPY, &[0, 1]),
 +        (&paths::PTR_COPY_NONOVERLAPPING, &[0, 1]),
 +        (&paths::PTR_READ, &[0]),
 +        (&paths::PTR_READ_UNALIGNED, &[0]),
 +        (&paths::PTR_READ_VOLATILE, &[0]),
 +        (&paths::PTR_REPLACE, &[0]),
 +        (&paths::PTR_SLICE_FROM_RAW_PARTS, &[0]),
 +        (&paths::PTR_SLICE_FROM_RAW_PARTS_MUT, &[0]),
 +        (&paths::PTR_SWAP, &[0, 1]),
 +        (&paths::PTR_SWAP_NONOVERLAPPING, &[0, 1]),
 +        (&paths::PTR_WRITE, &[0]),
 +        (&paths::PTR_WRITE_UNALIGNED, &[0]),
 +        (&paths::PTR_WRITE_VOLATILE, &[0]),
 +        (&paths::PTR_WRITE_BYTES, &[0]),
 +    ];
 +
 +    if_chain! {
 +        if let ExprKind::Call(fun, args) = expr.kind;
 +        if let ExprKind::Path(ref qpath) = fun.kind;
 +        if let Some(fun_def_id) = cx.qpath_res(qpath, fun.hir_id).opt_def_id();
 +        let fun_def_path = cx.get_def_path(fun_def_id).into_iter().map(Symbol::to_ident_string).collect::<Vec<_>>();
 +        if let Some(&(_, arg_indices)) = INVALID_NULL_PTR_USAGE_TABLE
 +            .iter()
 +            .find(|&&(fn_path, _)| fn_path == fun_def_path);
 +        then {
 +            for &arg_idx in arg_indices {
 +                if let Some(arg) = args.get(arg_idx).filter(|arg| is_null_path(cx, arg)) {
 +                    span_lint_and_sugg(
 +                        cx,
 +                        INVALID_NULL_PTR_USAGE,
 +                        arg.span,
 +                        "pointer must be non-null",
 +                        "change this to",
 +                        "core::ptr::NonNull::dangling().as_ptr()".to_string(),
 +                        Applicability::MachineApplicable,
 +                    );
 +                }
 +            }
 +        }
 +    }
 +}
 +
-         let (item_name, path) = if_chain! {
-             if let TyKind::Rptr(_, MutTy { ty, mutbl: Mutability::Not }) = arg.kind;
-             if let TyKind::Path(QPath::Resolved(_, path)) = ty.kind;
-             if let Res::Def(_, did) = path.res;
-             if let Some(item_name) = cx.tcx.get_diagnostic_name(did);
-             then {
-                 (item_name, path)
-             } else {
-                 continue
-             }
-         };
++#[derive(Default)]
++struct PtrArgResult {
++    skip: bool,
++    replacements: Vec<PtrArgReplacement>,
++}
 +
-         match item_name {
-             sym::Vec => {
-                 if let Some(spans) = get_spans(cx, opt_body_id, idx, &[("clone", ".to_owned()")]) {
-                     span_lint_and_then(
-                         cx,
-                         PTR_ARG,
-                         arg.span,
-                         "writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used \
-                          with non-Vec-based slices",
-                         |diag| {
-                             if let Some(ref snippet) = get_only_generic_arg_snippet(cx, arg) {
-                                 diag.span_suggestion(
-                                     arg.span,
-                                     "change this to",
-                                     format!("&[{}]", snippet),
-                                     Applicability::Unspecified,
-                                 );
-                             }
-                             for (clonespan, suggestion) in spans {
-                                 diag.span_suggestion(
-                                     clonespan,
-                                     &snippet_opt(cx, clonespan).map_or("change the call to".into(), |x| {
-                                         Cow::Owned(format!("change `{}` to", x))
-                                     }),
-                                     suggestion.into(),
-                                     Applicability::Unspecified,
-                                 );
-                             }
-                         },
-                     );
-                 }
++struct PtrArgReplacement {
++    expr_span: Span,
++    self_span: Span,
++    replacement: &'static str,
++}
 +
-             sym::String => {
-                 if let Some(spans) = get_spans(cx, opt_body_id, idx, &[("clone", ".to_string()"), ("as_str", "")]) {
-                     span_lint_and_then(
-                         cx,
-                         PTR_ARG,
-                         arg.span,
-                         "writing `&String` instead of `&str` involves a new object where a slice will do",
-                         |diag| {
-                             diag.span_suggestion(arg.span, "change this to", "&str".into(), Applicability::Unspecified);
-                             for (clonespan, suggestion) in spans {
-                                 diag.span_suggestion_short(
-                                     clonespan,
-                                     &snippet_opt(cx, clonespan).map_or("change the call to".into(), |x| {
-                                         Cow::Owned(format!("change `{}` to", x))
-                                     }),
-                                     suggestion.into(),
-                                     Applicability::Unspecified,
-                                 );
-                             }
-                         },
-                     );
++struct PtrArg<'tcx> {
++    idx: usize,
++    span: Span,
++    ty_did: DefId,
++    ty_name: Symbol,
++    method_renames: &'static [(&'static str, &'static str)],
++    ref_prefix: RefPrefix,
++    deref_ty: DerefTy<'tcx>,
++    deref_assoc_items: Option<(DefId, &'tcx AssocItems<'tcx>)>,
++}
++impl PtrArg<'_> {
++    fn build_msg(&self) -> String {
++        format!(
++            "writing `&{}{}` instead of `&{}{}` involves a new object where a slice will do",
++            self.ref_prefix.mutability.prefix_str(),
++            self.ty_name,
++            self.ref_prefix.mutability.prefix_str(),
++            self.deref_ty.argless_str(),
++        )
++    }
++}
++
++struct RefPrefix {
++    lt: LifetimeName,
++    mutability: Mutability,
++}
++impl fmt::Display for RefPrefix {
++    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
++        use fmt::Write;
++        f.write_char('&')?;
++        match self.lt {
++            LifetimeName::Param(ParamName::Plain(name)) => {
++                name.fmt(f)?;
++                f.write_char(' ')?;
 +            },
-             sym::PathBuf => {
-                 if let Some(spans) = get_spans(cx, opt_body_id, idx, &[("clone", ".to_path_buf()"), ("as_path", "")]) {
-                     span_lint_and_then(
-                         cx,
-                         PTR_ARG,
-                         arg.span,
-                         "writing `&PathBuf` instead of `&Path` involves a new object where a slice will do",
-                         |diag| {
-                             diag.span_suggestion(
-                                 arg.span,
++            LifetimeName::Underscore => f.write_str("'_ ")?,
++            LifetimeName::Static => f.write_str("'static ")?,
++            _ => (),
++        }
++        f.write_str(self.mutability.prefix_str())
++    }
++}
++
++struct DerefTyDisplay<'a, 'tcx>(&'a LateContext<'tcx>, &'a DerefTy<'tcx>);
++impl fmt::Display for DerefTyDisplay<'_, '_> {
++    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
++        use std::fmt::Write;
++        match self.1 {
++            DerefTy::Str => f.write_str("str"),
++            DerefTy::Path => f.write_str("Path"),
++            DerefTy::Slice(hir_ty, ty) => {
++                f.write_char('[')?;
++                match hir_ty.and_then(|s| snippet_opt(self.0, s)) {
++                    Some(s) => f.write_str(&s)?,
++                    None => ty.fmt(f)?,
 +                }
++                f.write_char(']')
 +            },
-                                 "&Path".into(),
++        }
++    }
++}
++
++enum DerefTy<'tcx> {
++    Str,
++    Path,
++    Slice(Option<Span>, Ty<'tcx>),
++}
++impl<'tcx> DerefTy<'tcx> {
++    fn argless_str(&self) -> &'static str {
++        match *self {
++            Self::Str => "str",
++            Self::Path => "Path",
++            Self::Slice(..) => "[_]",
++        }
++    }
++
++    fn display<'a>(&'a self, cx: &'a LateContext<'tcx>) -> DerefTyDisplay<'a, 'tcx> {
++        DerefTyDisplay(cx, self)
++    }
++}
++
++fn check_fn_args<'cx, 'tcx: 'cx>(
++    cx: &'cx LateContext<'tcx>,
++    tys: &'tcx [Ty<'_>],
++    hir_tys: &'tcx [hir::Ty<'_>],
++    params: &'tcx [Param<'_>],
++) -> impl Iterator<Item = PtrArg<'tcx>> + 'cx {
++    tys.iter()
++        .zip(hir_tys.iter())
++        .enumerate()
++        .filter_map(|(i, (ty, hir_ty))| {
++            if_chain! {
++                if let ty::Ref(_, ty, mutability) = *ty.kind();
++                if let ty::Adt(adt, substs) = *ty.kind();
++
++                if let TyKind::Rptr(lt, ref ty) = hir_ty.kind;
++                if let TyKind::Path(QPath::Resolved(None, path)) = ty.ty.kind;
++
++                // Check that the name as typed matches the actual name of the type.
++                // e.g. `fn foo(_: &Foo)` shouldn't trigger the lint when `Foo` is an alias for `Vec`
++                if let [.., name] = path.segments;
++                if cx.tcx.item_name(adt.did) == name.ident.name;
++
++                if !is_lint_allowed(cx, PTR_ARG, hir_ty.hir_id);
++                if params.get(i).map_or(true, |p| !is_lint_allowed(cx, PTR_ARG, p.hir_id));
++
++                then {
++                    let (method_renames, deref_ty, deref_impl_id) = match cx.tcx.get_diagnostic_name(adt.did) {
++                        Some(sym::Vec) => (
++                            [("clone", ".to_owned()")].as_slice(),
++                            DerefTy::Slice(
++                                name.args
++                                    .and_then(|args| args.args.first())
++                                    .and_then(|arg| if let GenericArg::Type(ty) = arg {
++                                        Some(ty.span)
++                                    } else {
++                                        None
++                                    }),
++                                substs.type_at(0),
++                            ),
++                            cx.tcx.lang_items().slice_impl()
++                        ),
++                        Some(sym::String) => (
++                            [("clone", ".to_owned()"), ("as_str", "")].as_slice(),
++                            DerefTy::Str,
++                            cx.tcx.lang_items().str_impl()
++                        ),
++                        Some(sym::PathBuf) => (
++                            [("clone", ".to_path_buf()"), ("as_path", "")].as_slice(),
++                            DerefTy::Path,
++                            None,
++                        ),
++                        Some(sym::Cow) => {
++                            let ty_name = name.args
++                                .and_then(|args| {
++                                    args.args.iter().find_map(|a| match a {
++                                        GenericArg::Type(x) => Some(x),
++                                        _ => None,
++                                    })
++                                })
++                                .and_then(|arg| snippet_opt(cx, arg.span))
++                                .unwrap_or_else(|| substs.type_at(1).to_string());
++                            span_lint_and_sugg(
++                                cx,
++                                PTR_ARG,
++                                hir_ty.span,
++                                "using a reference to `Cow` is not recommended",
 +                                "change this to",
-                             for (clonespan, suggestion) in spans {
-                                 diag.span_suggestion_short(
-                                     clonespan,
-                                     &snippet_opt(cx, clonespan).map_or("change the call to".into(), |x| {
-                                         Cow::Owned(format!("change `{}` to", x))
-                                     }),
-                                     suggestion.into(),
-                                     Applicability::Unspecified,
-                                 );
-                             }
++                                format!("&{}{}", mutability.prefix_str(), ty_name),
 +                                Applicability::Unspecified,
 +                            );
-                     );
-                 }
-             },
-             sym::Cow => {
-                 if_chain! {
-                     if let [ref bx] = *path.segments;
-                     if let Some(params) = bx.args;
-                     if !params.parenthesized;
-                     if let Some(inner) = params.args.iter().find_map(|arg| match arg {
-                         GenericArg::Type(ty) => Some(ty),
-                         _ => None,
++                            return None;
 +                        },
-                     let replacement = snippet_opt(cx, inner.span);
-                     if let Some(r) = replacement;
-                     then {
-                         span_lint_and_sugg(
-                             cx,
-                             PTR_ARG,
-                             arg.span,
-                             "using a reference to `Cow` is not recommended",
-                             "change this to",
-                             "&".to_owned() + &r,
-                             Applicability::Unspecified,
-                         );
-                     }
++                        _ => return None,
++                    };
++                    return Some(PtrArg {
++                        idx: i,
++                        span: hir_ty.span,
++                        ty_did: adt.did,
++                        ty_name: name.ident.name,
++                        method_renames,
++                        ref_prefix: RefPrefix {
++                            lt: lt.name,
++                            mutability,
++                        },
++                        deref_ty,
++                        deref_assoc_items: deref_impl_id.map(|id| (id, cx.tcx.associated_items(id))),
 +                    });
-             },
-             _ => {},
-         }
-     }
 +                }
-             for (_, ref mutbl, ref argspan) in decl
++            }
++            None
++        })
++}
 +
++fn check_mut_from_ref(cx: &LateContext<'_>, decl: &FnDecl<'_>) {
 +    if let FnRetTy::Return(ty) = decl.output {
 +        if let Some((out, Mutability::Mut, _)) = get_rptr_lm(ty) {
 +            let mut immutables = vec![];
-                 if *mutbl == Mutability::Mut {
++            for (_, mutbl, argspan) in decl
 +                .inputs
 +                .iter()
 +                .filter_map(get_rptr_lm)
 +                .filter(|&(lt, _, _)| lt.name == out.name)
 +            {
-                 immutables.push(*argspan);
++                if mutbl == Mutability::Mut {
 +                    return;
 +                }
- fn get_only_generic_arg_snippet(cx: &LateContext<'_>, arg: &Ty<'_>) -> Option<String> {
-     if_chain! {
-         if let TyKind::Path(QPath::Resolved(_, path)) = walk_ptrs_hir_ty(arg).kind;
-         if let Some(&PathSegment{args: Some(parameters), ..}) = path.segments.last();
-         let types: Vec<_> = parameters.args.iter().filter_map(|arg| match arg {
-             GenericArg::Type(ty) => Some(ty),
-             _ => None,
-         }).collect();
-         if types.len() == 1;
-         then {
-             snippet_opt(cx, types[0].span)
-         } else {
-             None
++                immutables.push(argspan);
 +            }
 +            if immutables.is_empty() {
 +                return;
 +            }
 +            span_lint_and_then(
 +                cx,
 +                MUT_FROM_REF,
 +                ty.span,
 +                "mutable borrow from immutable input(s)",
 +                |diag| {
 +                    let ms = MultiSpan::from_spans(immutables);
 +                    diag.span_note(ms, "immutable borrow here");
 +                },
 +            );
 +        }
 +    }
 +}
 +
- fn get_rptr_lm<'tcx>(ty: &'tcx Ty<'tcx>) -> Option<(&'tcx Lifetime, Mutability, Span)> {
++#[allow(clippy::too_many_lines)]
++fn check_ptr_arg_usage<'tcx>(cx: &LateContext<'tcx>, body: &'tcx Body<'_>, args: &[PtrArg<'tcx>]) -> Vec<PtrArgResult> {
++    struct V<'cx, 'tcx> {
++        cx: &'cx LateContext<'tcx>,
++        /// Map from a local id to which argument it came from (index into `Self::args` and
++        /// `Self::results`)
++        bindings: HirIdMap<usize>,
++        /// The arguments being checked.
++        args: &'cx [PtrArg<'tcx>],
++        /// The results for each argument (len should match args.len)
++        results: Vec<PtrArgResult>,
++        /// The number of arguments which can't be linted. Used to return early.
++        skip_count: usize,
++    }
++    impl<'tcx> Visitor<'tcx> for V<'_, 'tcx> {
++        type NestedFilter = nested_filter::OnlyBodies;
++        fn nested_visit_map(&mut self) -> Self::Map {
++            self.cx.tcx.hir()
++        }
++
++        fn visit_anon_const(&mut self, _: &'tcx AnonConst) {}
++
++        fn visit_expr(&mut self, e: &'tcx Expr<'_>) {
++            if self.skip_count == self.args.len() {
++                return;
++            }
++
++            // Check if this is local we care about
++            let args_idx = match path_to_local(e).and_then(|id| self.bindings.get(&id)) {
++                Some(&i) => i,
++                None => return walk_expr(self, e),
++            };
++            let args = &self.args[args_idx];
++            let result = &mut self.results[args_idx];
++
++            // Helper function to handle early returns.
++            let mut set_skip_flag = || {
++                if result.skip {
++                    self.skip_count += 1;
++                }
++                result.skip = true;
++            };
++
++            match get_expr_use_or_unification_node(self.cx.tcx, e) {
++                Some((Node::Stmt(_), _)) => (),
++                Some((Node::Local(l), _)) => {
++                    // Only trace simple bindings. e.g `let x = y;`
++                    if let PatKind::Binding(BindingAnnotation::Unannotated, id, _, None) = l.pat.kind {
++                        self.bindings.insert(id, args_idx);
++                    } else {
++                        set_skip_flag();
++                    }
++                },
++                Some((Node::Expr(e), child_id)) => match e.kind {
++                    ExprKind::Call(f, expr_args) => {
++                        let i = expr_args.iter().position(|arg| arg.hir_id == child_id).unwrap_or(0);
++                        if expr_sig(self.cx, f)
++                            .map(|sig| sig.input(i).skip_binder().peel_refs())
++                            .map_or(true, |ty| match *ty.kind() {
++                                ty::Param(_) => true,
++                                ty::Adt(def, _) => def.did == args.ty_did,
++                                _ => false,
++                            })
++                        {
++                            // Passed to a function taking the non-dereferenced type.
++                            set_skip_flag();
++                        }
++                    },
++                    ExprKind::MethodCall(name, expr_args @ [self_arg, ..], _) => {
++                        let i = expr_args.iter().position(|arg| arg.hir_id == child_id).unwrap_or(0);
++                        if i == 0 {
++                            // Check if the method can be renamed.
++                            let name = name.ident.as_str();
++                            if let Some((_, replacement)) = args.method_renames.iter().find(|&&(x, _)| x == name) {
++                                result.replacements.push(PtrArgReplacement {
++                                    expr_span: e.span,
++                                    self_span: self_arg.span,
++                                    replacement,
++                                });
++                                return;
++                            }
++                        }
++
++                        let id = if let Some(x) = self.cx.typeck_results().type_dependent_def_id(e.hir_id) {
++                            x
++                        } else {
++                            set_skip_flag();
++                            return;
++                        };
++
++                        match *self.cx.tcx.fn_sig(id).skip_binder().inputs()[i].peel_refs().kind() {
++                            ty::Param(_) => {
++                                set_skip_flag();
++                            },
++                            // If the types match check for methods which exist on both types. e.g. `Vec::len` and
++                            // `slice::len`
++                            ty::Adt(def, _)
++                                if def.did == args.ty_did
++                                    && (i != 0
++                                        || self.cx.tcx.trait_of_item(id).is_some()
++                                        || !args.deref_assoc_items.map_or(false, |(id, items)| {
++                                            items
++                                                .find_by_name_and_kind(self.cx.tcx, name.ident, AssocKind::Fn, id)
++                                                .is_some()
++                                        })) =>
++                            {
++                                set_skip_flag();
++                            },
++                            _ => (),
++                        }
++                    },
++                    // Indexing is fine for currently supported types.
++                    ExprKind::Index(e, _) if e.hir_id == child_id => (),
++                    _ => set_skip_flag(),
++                },
++                _ => set_skip_flag(),
++            }
 +        }
 +    }
++
++    let mut skip_count = 0;
++    let mut results = args.iter().map(|_| PtrArgResult::default()).collect::<Vec<_>>();
++    let mut v = V {
++        cx,
++        bindings: args
++            .iter()
++            .enumerate()
++            .filter_map(|(i, arg)| {
++                let param = &body.params[arg.idx];
++                match param.pat.kind {
++                    PatKind::Binding(BindingAnnotation::Unannotated, id, _, None)
++                        if !is_lint_allowed(cx, PTR_ARG, param.hir_id) =>
++                    {
++                        Some((id, i))
++                    },
++                    _ => {
++                        skip_count += 1;
++                        results[arg.idx].skip = true;
++                        None
++                    },
++                }
++            })
++            .collect(),
++        args,
++        results,
++        skip_count,
++    };
++    v.visit_expr(&body.value);
++    v.results
 +}
 +
++fn get_rptr_lm<'tcx>(ty: &'tcx hir::Ty<'tcx>) -> Option<(&'tcx Lifetime, Mutability, Span)> {
 +    if let TyKind::Rptr(ref lt, ref m) = ty.kind {
 +        Some((lt, m.mutbl, ty.span))
 +    } else {
 +        None
 +    }
 +}
 +
 +fn is_null_path(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
 +    if let ExprKind::Call(pathexp, []) = expr.kind {
 +        expr_path_res(cx, pathexp).opt_def_id().map_or(false, |id| {
 +            match_any_diagnostic_items(cx, id, &[sym::ptr_null, sym::ptr_null_mut]).is_some()
 +        })
 +    } else {
 +        false
 +    }
 +}
index b24483723700c2b031a404dddb0fd70db862ccc1,0000000000000000000000000000000000000000..811a7bb9c153a273e4d9ff5fbee2252555591a10
mode 100644,000000..100644
--- /dev/null
@@@ -1,162 -1,0 +1,105 @@@
- use clippy_utils::sugg::Sugg;
 +use clippy_utils::diagnostics::span_lint_and_sugg;
 +use clippy_utils::source::{snippet_opt, snippet_with_applicability};
- declare_clippy_lint! {
-     /// ### What it does
-     /// Checks for references in expressions that use
-     /// auto dereference.
-     ///
-     /// ### Why is this bad?
-     /// The reference is a no-op and is automatically
-     /// dereferenced by the compiler and makes the code less clear.
-     ///
-     /// ### Example
-     /// ```rust
-     /// struct Point(u32, u32);
-     /// let point = Point(30, 20);
-     /// let x = (&point).0;
-     /// ```
-     /// Use instead:
-     /// ```rust
-     /// # struct Point(u32, u32);
-     /// # let point = Point(30, 20);
-     /// let x = point.0;
-     /// ```
-     #[clippy::version = "pre 1.29.0"]
-     pub REF_IN_DEREF,
-     complexity,
-     "Use of reference in auto dereference expression."
- }
- declare_lint_pass!(RefInDeref => [REF_IN_DEREF]);
- impl EarlyLintPass for RefInDeref {
-     fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &Expr) {
-         if_chain! {
-             if let ExprKind::Field(ref object, _) = e.kind;
-             if let ExprKind::Paren(ref parened) = object.kind;
-             if let ExprKind::AddrOf(_, _, ref inner) = parened.kind;
-             then {
-                 let applicability = if inner.span.from_expansion() {
-                     Applicability::MaybeIncorrect
-                 } else {
-                     Applicability::MachineApplicable
-                 };
-                 let sugg = Sugg::ast(cx, inner, "_").maybe_par();
-                 span_lint_and_sugg(
-                     cx,
-                     REF_IN_DEREF,
-                     object.span,
-                     "creating a reference that is immediately dereferenced",
-                     "try this",
-                     sugg.to_string(),
-                     applicability,
-                 );
-             }
-         }
-     }
- }
 +use if_chain::if_chain;
 +use rustc_ast::ast::{Expr, ExprKind, Mutability, UnOp};
 +use rustc_errors::Applicability;
 +use rustc_lint::{EarlyContext, EarlyLintPass};
 +use rustc_session::{declare_lint_pass, declare_tool_lint};
 +use rustc_span::BytePos;
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for usage of `*&` and `*&mut` in expressions.
 +    ///
 +    /// ### Why is this bad?
 +    /// Immediately dereferencing a reference is no-op and
 +    /// makes the code less clear.
 +    ///
 +    /// ### Known problems
 +    /// Multiple dereference/addrof pairs are not handled so
 +    /// the suggested fix for `x = **&&y` is `x = *&y`, which is still incorrect.
 +    ///
 +    /// ### Example
 +    /// ```rust,ignore
 +    /// // Bad
 +    /// let a = f(*&mut b);
 +    /// let c = *&d;
 +    ///
 +    /// // Good
 +    /// let a = f(b);
 +    /// let c = d;
 +    /// ```
 +    #[clippy::version = "pre 1.29.0"]
 +    pub DEREF_ADDROF,
 +    complexity,
 +    "use of `*&` or `*&mut` in an expression"
 +}
 +
 +declare_lint_pass!(DerefAddrOf => [DEREF_ADDROF]);
 +
 +fn without_parens(mut e: &Expr) -> &Expr {
 +    while let ExprKind::Paren(ref child_e) = e.kind {
 +        e = child_e;
 +    }
 +    e
 +}
 +
 +impl EarlyLintPass for DerefAddrOf {
 +    fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &Expr) {
 +        if_chain! {
 +            if let ExprKind::Unary(UnOp::Deref, ref deref_target) = e.kind;
 +            if let ExprKind::AddrOf(_, ref mutability, ref addrof_target) = without_parens(deref_target).kind;
 +            if deref_target.span.ctxt() == e.span.ctxt();
 +            if !addrof_target.span.from_expansion();
 +            then {
 +                let mut applicability = Applicability::MachineApplicable;
 +                let sugg = if e.span.from_expansion() {
 +                    #[allow(clippy::option_if_let_else)]
 +                    if let Some(macro_source) = snippet_opt(cx, e.span) {
 +                        // Remove leading whitespace from the given span
 +                        // e.g: ` $visitor` turns into `$visitor`
 +                        let trim_leading_whitespaces = |span| {
 +                            snippet_opt(cx, span).and_then(|snip| {
 +                                #[allow(clippy::cast_possible_truncation)]
 +                                snip.find(|c: char| !c.is_whitespace()).map(|pos| {
 +                                    span.lo() + BytePos(pos as u32)
 +                                })
 +                            }).map_or(span, |start_no_whitespace| e.span.with_lo(start_no_whitespace))
 +                        };
 +
 +                        let mut generate_snippet = |pattern: &str| {
 +                            #[allow(clippy::cast_possible_truncation)]
 +                            macro_source.rfind(pattern).map(|pattern_pos| {
 +                                let rpos = pattern_pos + pattern.len();
 +                                let span_after_ref = e.span.with_lo(BytePos(e.span.lo().0 + rpos as u32));
 +                                let span = trim_leading_whitespaces(span_after_ref);
 +                                snippet_with_applicability(cx, span, "_", &mut applicability)
 +                            })
 +                        };
 +
 +                        if *mutability == Mutability::Mut {
 +                            generate_snippet("mut")
 +                        } else {
 +                            generate_snippet("&")
 +                        }
 +                    } else {
 +                        Some(snippet_with_applicability(cx, e.span, "_", &mut applicability))
 +                    }
 +                } else {
 +                    Some(snippet_with_applicability(cx, addrof_target.span, "_", &mut applicability))
 +                };
 +                if let Some(sugg) = sugg {
 +                    span_lint_and_sugg(
 +                        cx,
 +                        DEREF_ADDROF,
 +                        e.span,
 +                        "immediately dereferencing a reference",
 +                        "try this",
 +                        sugg.to_string(),
 +                        applicability,
 +                    );
 +                }
 +            }
 +        }
 +    }
 +}
index 6369aafe3f9734ec605be603f4eb30d700cace9d,0000000000000000000000000000000000000000..5257f5302cd90d87c2ced61cd1f582cb2b4d1dd7
mode 100644,000000..100644
--- /dev/null
@@@ -1,265 -1,0 +1,267 @@@
- use rustc_data_structures::fx::{FxHashMap, FxHashSet};
 +use clippy_utils::diagnostics::span_lint_and_help;
 +use clippy_utils::source::{snippet, snippet_with_applicability};
 +use clippy_utils::{SpanlessEq, SpanlessHash};
 +use core::hash::{Hash, Hasher};
 +use if_chain::if_chain;
-         let mut self_bounds_set = FxHashSet::default();
++use rustc_data_structures::fx::FxHashMap;
 +use rustc_data_structures::unhash::UnhashMap;
 +use rustc_errors::Applicability;
 +use rustc_hir::def::Res;
 +use rustc_hir::{
 +    GenericBound, Generics, Item, ItemKind, Node, ParamName, Path, PathSegment, QPath, TraitItem, Ty, TyKind,
 +    WherePredicate,
 +};
 +use rustc_lint::{LateContext, LateLintPass};
 +use rustc_session::{declare_tool_lint, impl_lint_pass};
 +use rustc_span::Span;
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// This lint warns about unnecessary type repetitions in trait bounds
 +    ///
 +    /// ### Why is this bad?
 +    /// Repeating the type for every bound makes the code
 +    /// less readable than combining the bounds
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// pub fn foo<T>(t: T) where T: Copy, T: Clone {}
 +    /// ```
 +    ///
 +    /// Could be written as:
 +    ///
 +    /// ```rust
 +    /// pub fn foo<T>(t: T) where T: Copy + Clone {}
 +    /// ```
 +    #[clippy::version = "1.38.0"]
 +    pub TYPE_REPETITION_IN_BOUNDS,
 +    pedantic,
 +    "Types are repeated unnecessary in trait bounds use `+` instead of using `T: _, T: _`"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for cases where generics are being used and multiple
 +    /// syntax specifications for trait bounds are used simultaneously.
 +    ///
 +    /// ### Why is this bad?
 +    /// Duplicate bounds makes the code
 +    /// less readable than specifing them only once.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// fn func<T: Clone + Default>(arg: T) where T: Clone + Default {}
 +    /// ```
 +    ///
 +    /// Could be written as:
 +    ///
 +    /// ```rust
 +    /// fn func<T: Clone + Default>(arg: T) {}
 +    /// ```
 +    /// or
 +    ///
 +    /// ```rust
 +    /// fn func<T>(arg: T) where T: Clone + Default {}
 +    /// ```
 +    #[clippy::version = "1.47.0"]
 +    pub TRAIT_DUPLICATION_IN_BOUNDS,
 +    pedantic,
 +    "Check if the same trait bounds are specified twice during a function declaration"
 +}
 +
 +#[derive(Copy, Clone)]
 +pub struct TraitBounds {
 +    max_trait_bounds: u64,
 +}
 +
 +impl TraitBounds {
 +    #[must_use]
 +    pub fn new(max_trait_bounds: u64) -> Self {
 +        Self { max_trait_bounds }
 +    }
 +}
 +
 +impl_lint_pass!(TraitBounds => [TYPE_REPETITION_IN_BOUNDS, TRAIT_DUPLICATION_IN_BOUNDS]);
 +
 +impl<'tcx> LateLintPass<'tcx> for TraitBounds {
 +    fn check_generics(&mut self, cx: &LateContext<'tcx>, gen: &'tcx Generics<'_>) {
 +        self.check_type_repetition(cx, gen);
 +        check_trait_bound_duplication(cx, gen);
 +    }
 +
 +    fn check_trait_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx TraitItem<'tcx>) {
 +        let Generics { where_clause, .. } = &item.generics;
-                     if self_bounds_set.is_empty() {
++        let mut self_bounds_map = FxHashMap::default();
 +
 +        for predicate in where_clause.predicates {
 +            if_chain! {
 +                if let WherePredicate::BoundPredicate(ref bound_predicate) = predicate;
 +                if !bound_predicate.span.from_expansion();
 +                if let TyKind::Path(QPath::Resolved(_, Path { segments, .. })) = bound_predicate.bounded_ty.kind;
 +                if let Some(PathSegment { res: Some(Res::SelfTy(Some(def_id), _)), .. }) = segments.first();
 +
 +                if let Some(
 +                    Node::Item(
 +                        Item {
 +                            kind: ItemKind::Trait(_, _, _, self_bounds, _),
 +                            .. }
 +                        )
 +                    ) = cx.tcx.hir().get_if_local(*def_id);
 +                then {
-                             let Some((self_res, _)) = get_trait_res_span_from_bound(bound) else { continue };
-                             self_bounds_set.insert(self_res);
++                    if self_bounds_map.is_empty() {
 +                        for bound in self_bounds.iter() {
-                         .filter_map(get_trait_res_span_from_bound)
-                         .for_each(|(trait_item_res, span)| {
-                             if self_bounds_set.get(&trait_item_res).is_some() {
-                                 span_lint_and_help(
-                                     cx,
-                                     TRAIT_DUPLICATION_IN_BOUNDS,
-                                     span,
-                                     "this trait bound is already specified in trait declaration",
-                                     None,
-                                     "consider removing this trait bound",
-                                 );
++                            let Some((self_res, self_segments, _)) = get_trait_info_from_bound(bound) else { continue };
++                            self_bounds_map.insert(self_res, self_segments);
 +                        }
 +                    }
 +
 +                    bound_predicate
 +                        .bounds
 +                        .iter()
- fn get_trait_res_span_from_bound(bound: &GenericBound<'_>) -> Option<(Res, Span)> {
-     if let GenericBound::Trait(t, _) = bound {
-         Some((t.trait_ref.path.res, t.span))
-     } else {
-         None
-     }
- }
++                        .filter_map(get_trait_info_from_bound)
++                        .for_each(|(trait_item_res, trait_item_segments, span)| {
++                            if let Some(self_segments) = self_bounds_map.get(&trait_item_res) {
++                                if SpanlessEq::new(cx).eq_path_segments(self_segments, trait_item_segments) {
++                                    span_lint_and_help(
++                                        cx,
++                                        TRAIT_DUPLICATION_IN_BOUNDS,
++                                        span,
++                                        "this trait bound is already specified in trait declaration",
++                                        None,
++                                        "consider removing this trait bound",
++                                    );
++                                }
 +                            }
 +                        });
 +                }
 +            }
 +        }
 +    }
 +}
 +
-                 .filter_map(get_trait_res_span_from_bound)
 +impl TraitBounds {
 +    fn check_type_repetition<'tcx>(self, cx: &LateContext<'tcx>, gen: &'tcx Generics<'_>) {
 +        struct SpanlessTy<'cx, 'tcx> {
 +            ty: &'tcx Ty<'tcx>,
 +            cx: &'cx LateContext<'tcx>,
 +        }
 +        impl PartialEq for SpanlessTy<'_, '_> {
 +            fn eq(&self, other: &Self) -> bool {
 +                let mut eq = SpanlessEq::new(self.cx);
 +                eq.inter_expr().eq_ty(self.ty, other.ty)
 +            }
 +        }
 +        impl Hash for SpanlessTy<'_, '_> {
 +            fn hash<H: Hasher>(&self, h: &mut H) {
 +                let mut t = SpanlessHash::new(self.cx);
 +                t.hash_ty(self.ty);
 +                h.write_u64(t.finish());
 +            }
 +        }
 +        impl Eq for SpanlessTy<'_, '_> {}
 +
 +        if gen.span.from_expansion() {
 +            return;
 +        }
 +        let mut map: UnhashMap<SpanlessTy<'_, '_>, Vec<&GenericBound<'_>>> = UnhashMap::default();
 +        let mut applicability = Applicability::MaybeIncorrect;
 +        for bound in gen.where_clause.predicates {
 +            if_chain! {
 +                if let WherePredicate::BoundPredicate(ref p) = bound;
 +                if p.bounds.len() as u64 <= self.max_trait_bounds;
 +                if !p.span.from_expansion();
 +                if let Some(ref v) = map.insert(
 +                    SpanlessTy { ty: p.bounded_ty, cx },
 +                    p.bounds.iter().collect::<Vec<_>>()
 +                );
 +
 +                then {
 +                    let mut hint_string = format!(
 +                        "consider combining the bounds: `{}:",
 +                        snippet(cx, p.bounded_ty.span, "_")
 +                    );
 +                    for b in v.iter() {
 +                        if let GenericBound::Trait(ref poly_trait_ref, _) = b {
 +                            let path = &poly_trait_ref.trait_ref.path;
 +                            hint_string.push_str(&format!(
 +                                " {} +",
 +                                snippet_with_applicability(cx, path.span, "..", &mut applicability)
 +                            ));
 +                        }
 +                    }
 +                    for b in p.bounds.iter() {
 +                        if let GenericBound::Trait(ref poly_trait_ref, _) = b {
 +                            let path = &poly_trait_ref.trait_ref.path;
 +                            hint_string.push_str(&format!(
 +                                " {} +",
 +                                snippet_with_applicability(cx, path.span, "..", &mut applicability)
 +                            ));
 +                        }
 +                    }
 +                    hint_string.truncate(hint_string.len() - 2);
 +                    hint_string.push('`');
 +                    span_lint_and_help(
 +                        cx,
 +                        TYPE_REPETITION_IN_BOUNDS,
 +                        p.span,
 +                        "this type has already been used as a bound predicate",
 +                        None,
 +                        &hint_string,
 +                    );
 +                }
 +            }
 +        }
 +    }
 +}
 +
 +fn check_trait_bound_duplication(cx: &LateContext<'_>, gen: &'_ Generics<'_>) {
 +    if gen.span.from_expansion() || gen.params.is_empty() || gen.where_clause.predicates.is_empty() {
 +        return;
 +    }
 +
 +    let mut map = FxHashMap::default();
 +    for param in gen.params {
 +        if let ParamName::Plain(ref ident) = param.name {
 +            let res = param
 +                .bounds
 +                .iter()
-                 for (res_where, _) in bound_predicate.bounds.iter().filter_map(get_trait_res_span_from_bound) {
-                     if let Some((_, span_direct)) = trait_resolutions_direct
++                .filter_map(get_trait_info_from_bound)
 +                .collect::<Vec<_>>();
 +            map.insert(*ident, res);
 +        }
 +    }
 +
 +    for predicate in gen.where_clause.predicates {
 +        if_chain! {
 +            if let WherePredicate::BoundPredicate(ref bound_predicate) = predicate;
 +            if !bound_predicate.span.from_expansion();
 +            if let TyKind::Path(QPath::Resolved(_, Path { segments, .. })) = bound_predicate.bounded_ty.kind;
 +            if let Some(segment) = segments.first();
 +            if let Some(trait_resolutions_direct) = map.get(&segment.ident);
 +            then {
-                                                 .find(|(res_direct, _)| *res_direct == res_where) {
++                for (res_where, _,  _) in bound_predicate.bounds.iter().filter_map(get_trait_info_from_bound) {
++                    if let Some((_, _, span_direct)) = trait_resolutions_direct
 +                                                .iter()
++                                                .find(|(res_direct, _, _)| *res_direct == res_where) {
 +                        span_lint_and_help(
 +                            cx,
 +                            TRAIT_DUPLICATION_IN_BOUNDS,
 +                            *span_direct,
 +                            "this trait bound is already specified in the where clause",
 +                            None,
 +                            "consider removing this trait bound",
 +                        );
 +                    }
 +                }
 +            }
 +        }
 +    }
 +}
++
++fn get_trait_info_from_bound<'a>(bound: &'a GenericBound<'_>) -> Option<(Res, &'a [PathSegment<'a>], Span)> {
++    if let GenericBound::Trait(t, _) = bound {
++        Some((t.trait_ref.path.res, t.trait_ref.path.segments, t.span))
++    } else {
++        None
++    }
++}
index 141f260487264026182e39eb2b24ea227cf33364,0000000000000000000000000000000000000000..eee1229e1ef0356745ec361f76929e1570c322bf
mode 100644,000000..100644
--- /dev/null
@@@ -1,182 -1,0 +1,183 @@@
-                             if ord_preds.iter().any(|ord| Some(ord.self_ty()) ==
-                             return_ty_pred.term.ty()) {
 +use clippy_utils::diagnostics::{span_lint, span_lint_and_help};
 +use clippy_utils::{get_trait_def_id, paths};
 +use if_chain::if_chain;
 +use rustc_hir::def_id::DefId;
 +use rustc_hir::{Expr, ExprKind, StmtKind};
 +use rustc_lint::{LateContext, LateLintPass};
 +use rustc_middle::ty;
 +use rustc_middle::ty::{GenericPredicates, PredicateKind, ProjectionPredicate, TraitPredicate};
 +use rustc_session::{declare_lint_pass, declare_tool_lint};
 +use rustc_span::{BytePos, Span};
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for functions that expect closures of type
 +    /// Fn(...) -> Ord where the implemented closure returns the unit type.
 +    /// The lint also suggests to remove the semi-colon at the end of the statement if present.
 +    ///
 +    /// ### Why is this bad?
 +    /// Likely, returning the unit type is unintentional, and
 +    /// could simply be caused by an extra semi-colon. Since () implements Ord
 +    /// it doesn't cause a compilation error.
 +    /// This is the same reasoning behind the unit_cmp lint.
 +    ///
 +    /// ### Known problems
 +    /// If returning unit is intentional, then there is no
 +    /// way of specifying this without triggering needless_return lint
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// let mut twins = vec!((1, 1), (2, 2));
 +    /// twins.sort_by_key(|x| { x.1; });
 +    /// ```
 +    #[clippy::version = "1.47.0"]
 +    pub UNIT_RETURN_EXPECTING_ORD,
 +    correctness,
 +    "fn arguments of type Fn(...) -> Ord returning the unit type ()."
 +}
 +
 +declare_lint_pass!(UnitReturnExpectingOrd => [UNIT_RETURN_EXPECTING_ORD]);
 +
 +fn get_trait_predicates_for_trait_id<'tcx>(
 +    cx: &LateContext<'tcx>,
 +    generics: GenericPredicates<'tcx>,
 +    trait_id: Option<DefId>,
 +) -> Vec<TraitPredicate<'tcx>> {
 +    let mut preds = Vec::new();
 +    for (pred, _) in generics.predicates {
 +        if_chain! {
 +            if let PredicateKind::Trait(poly_trait_pred) = pred.kind().skip_binder();
 +            let trait_pred = cx.tcx.erase_late_bound_regions(pred.kind().rebind(poly_trait_pred));
 +            if let Some(trait_def_id) = trait_id;
 +            if trait_def_id == trait_pred.trait_ref.def_id;
 +            then {
 +                preds.push(trait_pred);
 +            }
 +        }
 +    }
 +    preds
 +}
 +
 +fn get_projection_pred<'tcx>(
 +    cx: &LateContext<'tcx>,
 +    generics: GenericPredicates<'tcx>,
 +    trait_pred: TraitPredicate<'tcx>,
 +) -> Option<ProjectionPredicate<'tcx>> {
 +    generics.predicates.iter().find_map(|(proj_pred, _)| {
 +        if let ty::PredicateKind::Projection(pred) = proj_pred.kind().skip_binder() {
 +            let projection_pred = cx.tcx.erase_late_bound_regions(proj_pred.kind().rebind(pred));
 +            if projection_pred.projection_ty.substs == trait_pred.trait_ref.substs {
 +                return Some(projection_pred);
 +            }
 +        }
 +        None
 +    })
 +}
 +
 +fn get_args_to_check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) -> Vec<(usize, String)> {
 +    let mut args_to_check = Vec::new();
 +    if let Some(def_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id) {
 +        let fn_sig = cx.tcx.fn_sig(def_id);
 +        let generics = cx.tcx.predicates_of(def_id);
 +        let fn_mut_preds = get_trait_predicates_for_trait_id(cx, generics, cx.tcx.lang_items().fn_mut_trait());
 +        let ord_preds = get_trait_predicates_for_trait_id(cx, generics, get_trait_def_id(cx, &paths::ORD));
 +        let partial_ord_preds =
 +            get_trait_predicates_for_trait_id(cx, generics, cx.tcx.lang_items().partial_ord_trait());
 +        // Trying to call erase_late_bound_regions on fn_sig.inputs() gives the following error
 +        // The trait `rustc::ty::TypeFoldable<'_>` is not implemented for `&[&rustc::ty::TyS<'_>]`
 +        let inputs_output = cx.tcx.erase_late_bound_regions(fn_sig.inputs_and_output());
 +        inputs_output
 +            .iter()
 +            .rev()
 +            .skip(1)
 +            .rev()
 +            .enumerate()
 +            .for_each(|(i, inp)| {
 +                for trait_pred in &fn_mut_preds {
 +                    if_chain! {
 +                        if trait_pred.self_ty() == inp;
 +                        if let Some(return_ty_pred) = get_projection_pred(cx, generics, *trait_pred);
 +                        then {
-                             } else if partial_ord_preds.iter().any(|pord| pord.self_ty() == return_ty_pred.term.ty().unwrap()) {
++                            if ord_preds.iter().any(|ord| Some(ord.self_ty()) == return_ty_pred.term.ty()) {
 +                                args_to_check.push((i, "Ord".to_string()));
++                            } else if partial_ord_preds.iter().any(|pord| {
++                                pord.self_ty() == return_ty_pred.term.ty().unwrap()
++                            }) {
 +                                args_to_check.push((i, "PartialOrd".to_string()));
 +                            }
 +                        }
 +                    }
 +                }
 +            });
 +    }
 +    args_to_check
 +}
 +
 +fn check_arg<'tcx>(cx: &LateContext<'tcx>, arg: &'tcx Expr<'tcx>) -> Option<(Span, Option<Span>)> {
 +    if_chain! {
 +        if let ExprKind::Closure(_, _fn_decl, body_id, span, _) = arg.kind;
 +        if let ty::Closure(_def_id, substs) = &cx.typeck_results().node_type(arg.hir_id).kind();
 +        let ret_ty = substs.as_closure().sig().output();
 +        let ty = cx.tcx.erase_late_bound_regions(ret_ty);
 +        if ty.is_unit();
 +        then {
 +            let body = cx.tcx.hir().body(body_id);
 +            if_chain! {
 +                if let ExprKind::Block(block, _) = body.value.kind;
 +                if block.expr.is_none();
 +                if let Some(stmt) = block.stmts.last();
 +                if let StmtKind::Semi(_) = stmt.kind;
 +                then {
 +                    let data = stmt.span.data();
 +                    // Make a span out of the semicolon for the help message
 +                    Some((span, Some(data.with_lo(data.hi-BytePos(1)))))
 +                } else {
 +                    Some((span, None))
 +                }
 +            }
 +        } else {
 +            None
 +        }
 +    }
 +}
 +
 +impl<'tcx> LateLintPass<'tcx> for UnitReturnExpectingOrd {
 +    fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
 +        if let ExprKind::MethodCall(_, args, _) = expr.kind {
 +            let arg_indices = get_args_to_check(cx, expr);
 +            for (i, trait_name) in arg_indices {
 +                if i < args.len() {
 +                    match check_arg(cx, &args[i]) {
 +                        Some((span, None)) => {
 +                            span_lint(
 +                                cx,
 +                                UNIT_RETURN_EXPECTING_ORD,
 +                                span,
 +                                &format!(
 +                                    "this closure returns \
 +                                   the unit type which also implements {}",
 +                                    trait_name
 +                                ),
 +                            );
 +                        },
 +                        Some((span, Some(last_semi))) => {
 +                            span_lint_and_help(
 +                                cx,
 +                                UNIT_RETURN_EXPECTING_ORD,
 +                                span,
 +                                &format!(
 +                                    "this closure returns \
 +                                   the unit type which also implements {}",
 +                                    trait_name
 +                                ),
 +                                Some(last_semi),
 +                                "probably caused by this trailing semicolon",
 +                            );
 +                        },
 +                        None => {},
 +                    }
 +                }
 +            }
 +        }
 +    }
 +}
index 0bd151fed91cc57c50c2b0c8ca3a93dd09dd4880,0000000000000000000000000000000000000000..1d4fe9cfd3cf40a8ac5459cf206f9c0704f711b0
mode 100644,000000..100644
--- /dev/null
@@@ -1,424 -1,0 +1,424 @@@
-     fps1: &mut Vec<ast::PatField>,
 +#![allow(clippy::wildcard_imports, clippy::enum_glob_use)]
 +
 +use clippy_utils::ast_utils::{eq_field_pat, eq_id, eq_maybe_qself, eq_pat, eq_path};
 +use clippy_utils::diagnostics::span_lint_and_then;
 +use clippy_utils::{meets_msrv, msrvs, over};
 +use rustc_ast::mut_visit::*;
 +use rustc_ast::ptr::P;
 +use rustc_ast::{self as ast, Pat, PatKind, PatKind::*, DUMMY_NODE_ID};
 +use rustc_ast_pretty::pprust;
 +use rustc_errors::Applicability;
 +use rustc_lint::{EarlyContext, EarlyLintPass};
 +use rustc_semver::RustcVersion;
 +use rustc_session::{declare_tool_lint, impl_lint_pass};
 +use rustc_span::DUMMY_SP;
 +
 +use std::cell::Cell;
 +use std::mem;
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for unnested or-patterns, e.g., `Some(0) | Some(2)` and
 +    /// suggests replacing the pattern with a nested one, `Some(0 | 2)`.
 +    ///
 +    /// Another way to think of this is that it rewrites patterns in
 +    /// *disjunctive normal form (DNF)* into *conjunctive normal form (CNF)*.
 +    ///
 +    /// ### Why is this bad?
 +    /// In the example above, `Some` is repeated, which unncessarily complicates the pattern.
 +    ///
 +    /// ### Example
 +    /// ```rust
 +    /// fn main() {
 +    ///     if let Some(0) | Some(2) = Some(0) {}
 +    /// }
 +    /// ```
 +    /// Use instead:
 +    /// ```rust
 +    /// fn main() {
 +    ///     if let Some(0 | 2) = Some(0) {}
 +    /// }
 +    /// ```
 +    #[clippy::version = "1.46.0"]
 +    pub UNNESTED_OR_PATTERNS,
 +    pedantic,
 +    "unnested or-patterns, e.g., `Foo(Bar) | Foo(Baz) instead of `Foo(Bar | Baz)`"
 +}
 +
 +#[derive(Clone, Copy)]
 +pub struct UnnestedOrPatterns {
 +    msrv: Option<RustcVersion>,
 +}
 +
 +impl UnnestedOrPatterns {
 +    #[must_use]
 +    pub fn new(msrv: Option<RustcVersion>) -> Self {
 +        Self { msrv }
 +    }
 +}
 +
 +impl_lint_pass!(UnnestedOrPatterns => [UNNESTED_OR_PATTERNS]);
 +
 +impl EarlyLintPass for UnnestedOrPatterns {
 +    fn check_arm(&mut self, cx: &EarlyContext<'_>, a: &ast::Arm) {
 +        if meets_msrv(self.msrv.as_ref(), &msrvs::OR_PATTERNS) {
 +            lint_unnested_or_patterns(cx, &a.pat);
 +        }
 +    }
 +
 +    fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &ast::Expr) {
 +        if meets_msrv(self.msrv.as_ref(), &msrvs::OR_PATTERNS) {
 +            if let ast::ExprKind::Let(pat, _, _) = &e.kind {
 +                lint_unnested_or_patterns(cx, pat);
 +            }
 +        }
 +    }
 +
 +    fn check_param(&mut self, cx: &EarlyContext<'_>, p: &ast::Param) {
 +        if meets_msrv(self.msrv.as_ref(), &msrvs::OR_PATTERNS) {
 +            lint_unnested_or_patterns(cx, &p.pat);
 +        }
 +    }
 +
 +    fn check_local(&mut self, cx: &EarlyContext<'_>, l: &ast::Local) {
 +        if meets_msrv(self.msrv.as_ref(), &msrvs::OR_PATTERNS) {
 +            lint_unnested_or_patterns(cx, &l.pat);
 +        }
 +    }
 +
 +    extract_msrv_attr!(EarlyContext);
 +}
 +
 +fn lint_unnested_or_patterns(cx: &EarlyContext<'_>, pat: &Pat) {
 +    if let Ident(.., None) | Lit(_) | Wild | Path(..) | Range(..) | Rest | MacCall(_) = pat.kind {
 +        // This is a leaf pattern, so cloning is unprofitable.
 +        return;
 +    }
 +
 +    let mut pat = P(pat.clone());
 +
 +    // Nix all the paren patterns everywhere so that they aren't in our way.
 +    remove_all_parens(&mut pat);
 +
 +    // Transform all unnested or-patterns into nested ones, and if there were none, quit.
 +    if !unnest_or_patterns(&mut pat) {
 +        return;
 +    }
 +
 +    span_lint_and_then(cx, UNNESTED_OR_PATTERNS, pat.span, "unnested or-patterns", |db| {
 +        insert_necessary_parens(&mut pat);
 +        db.span_suggestion_verbose(
 +            pat.span,
 +            "nest the patterns",
 +            pprust::pat_to_string(&pat),
 +            Applicability::MachineApplicable,
 +        );
 +    });
 +}
 +
 +/// Remove all `(p)` patterns in `pat`.
 +fn remove_all_parens(pat: &mut P<Pat>) {
 +    struct Visitor;
 +    impl MutVisitor for Visitor {
 +        fn visit_pat(&mut self, pat: &mut P<Pat>) {
 +            noop_visit_pat(pat, self);
 +            let inner = match &mut pat.kind {
 +                Paren(i) => mem::replace(&mut i.kind, Wild),
 +                _ => return,
 +            };
 +            pat.kind = inner;
 +        }
 +    }
 +    Visitor.visit_pat(pat);
 +}
 +
 +/// Insert parens where necessary according to Rust's precedence rules for patterns.
 +fn insert_necessary_parens(pat: &mut P<Pat>) {
 +    struct Visitor;
 +    impl MutVisitor for Visitor {
 +        fn visit_pat(&mut self, pat: &mut P<Pat>) {
 +            use ast::{BindingMode::*, Mutability::*};
 +            noop_visit_pat(pat, self);
 +            let target = match &mut pat.kind {
 +                // `i @ a | b`, `box a | b`, and `& mut? a | b`.
 +                Ident(.., Some(p)) | Box(p) | Ref(p, _) if matches!(&p.kind, Or(ps) if ps.len() > 1) => p,
 +                Ref(p, Not) if matches!(p.kind, Ident(ByValue(Mut), ..)) => p, // `&(mut x)`
 +                _ => return,
 +            };
 +            target.kind = Paren(P(take_pat(target)));
 +        }
 +    }
 +    Visitor.visit_pat(pat);
 +}
 +
 +/// Unnest or-patterns `p0 | ... | p1` in the pattern `pat`.
 +/// For example, this would transform `Some(0) | FOO | Some(2)` into `Some(0 | 2) | FOO`.
 +fn unnest_or_patterns(pat: &mut P<Pat>) -> bool {
 +    struct Visitor {
 +        changed: bool,
 +    }
 +    impl MutVisitor for Visitor {
 +        fn visit_pat(&mut self, p: &mut P<Pat>) {
 +            // This is a bottom up transformation, so recurse first.
 +            noop_visit_pat(p, self);
 +
 +            // Don't have an or-pattern? Just quit early on.
 +            let alternatives = match &mut p.kind {
 +                Or(ps) => ps,
 +                _ => return,
 +            };
 +
 +            // Collapse or-patterns directly nested in or-patterns.
 +            let mut idx = 0;
 +            let mut this_level_changed = false;
 +            while idx < alternatives.len() {
 +                let inner = if let Or(ps) = &mut alternatives[idx].kind {
 +                    mem::take(ps)
 +                } else {
 +                    idx += 1;
 +                    continue;
 +                };
 +                this_level_changed = true;
 +                alternatives.splice(idx..=idx, inner);
 +            }
 +
 +            // Focus on `p_n` and then try to transform all `p_i` where `i > n`.
 +            let mut focus_idx = 0;
 +            while focus_idx < alternatives.len() {
 +                this_level_changed |= transform_with_focus_on_idx(alternatives, focus_idx);
 +                focus_idx += 1;
 +            }
 +            self.changed |= this_level_changed;
 +
 +            // Deal with `Some(Some(0)) | Some(Some(1))`.
 +            if this_level_changed {
 +                noop_visit_pat(p, self);
 +            }
 +        }
 +    }
 +
 +    let mut visitor = Visitor { changed: false };
 +    visitor.visit_pat(pat);
 +    visitor.changed
 +}
 +
 +/// Match `$scrutinee` against `$pat` and extract `$then` from it.
 +/// Panics if there is no match.
 +macro_rules! always_pat {
 +    ($scrutinee:expr, $pat:pat => $then:expr) => {
 +        match $scrutinee {
 +            $pat => $then,
 +            _ => unreachable!(),
 +        }
 +    };
 +}
 +
 +/// Focus on `focus_idx` in `alternatives`,
 +/// attempting to extend it with elements of the same constructor `C`
 +/// in `alternatives[focus_idx + 1..]`.
 +fn transform_with_focus_on_idx(alternatives: &mut Vec<P<Pat>>, focus_idx: usize) -> bool {
 +    // Extract the kind; we'll need to make some changes in it.
 +    let mut focus_kind = mem::replace(&mut alternatives[focus_idx].kind, PatKind::Wild);
 +    // We'll focus on `alternatives[focus_idx]`,
 +    // so we're draining from `alternatives[focus_idx + 1..]`.
 +    let start = focus_idx + 1;
 +
 +    // We're trying to find whatever kind (~"constructor") we found in `alternatives[start..]`.
 +    let changed = match &mut focus_kind {
 +        // These pattern forms are "leafs" and do not have sub-patterns.
 +        // Therefore they are not some form of constructor `C`,
 +        // with which a pattern `C(p_0)` may be formed,
 +        // which we would want to join with other `C(p_j)`s.
 +        Ident(.., None) | Lit(_) | Wild | Path(..) | Range(..) | Rest | MacCall(_)
 +        // Dealt with elsewhere.
 +        | Or(_) | Paren(_) => false,
 +        // Transform `box x | ... | box y` into `box (x | y)`.
 +        //
 +        // The cases below until `Slice(...)` deal with *singleton* products.
 +        // These patterns have the shape `C(p)`, and not e.g., `C(p0, ..., pn)`.
 +        Box(target) => extend_with_matching(
 +            target, start, alternatives,
 +            |k| matches!(k, Box(_)),
 +            |k| always_pat!(k, Box(p) => p),
 +        ),
 +        // Transform `&m x | ... | &m y` into `&m (x | y)`.
 +        Ref(target, m1) => extend_with_matching(
 +            target, start, alternatives,
 +            |k| matches!(k, Ref(_, m2) if m1 == m2), // Mutabilities must match.
 +            |k| always_pat!(k, Ref(p, _) => p),
 +        ),
 +        // Transform `b @ p0 | ... b @ p1` into `b @ (p0 | p1)`.
 +        Ident(b1, i1, Some(target)) => extend_with_matching(
 +            target, start, alternatives,
 +            // Binding names must match.
 +            |k| matches!(k, Ident(b2, i2, Some(_)) if b1 == b2 && eq_id(*i1, *i2)),
 +            |k| always_pat!(k, Ident(_, _, Some(p)) => p),
 +        ),
 +        // Transform `[pre, x, post] | ... | [pre, y, post]` into `[pre, x | y, post]`.
 +        Slice(ps1) => extend_with_matching_product(
 +            ps1, start, alternatives,
 +            |k, ps1, idx| matches!(k, Slice(ps2) if eq_pre_post(ps1, ps2, idx)),
 +            |k| always_pat!(k, Slice(ps) => ps),
 +        ),
 +        // Transform `(pre, x, post) | ... | (pre, y, post)` into `(pre, x | y, post)`.
 +        Tuple(ps1) => extend_with_matching_product(
 +            ps1, start, alternatives,
 +            |k, ps1, idx| matches!(k, Tuple(ps2) if eq_pre_post(ps1, ps2, idx)),
 +            |k| always_pat!(k, Tuple(ps) => ps),
 +        ),
 +        // Transform `S(pre, x, post) | ... | S(pre, y, post)` into `S(pre, x | y, post)`.
 +        TupleStruct(qself1, path1, ps1) => extend_with_matching_product(
 +            ps1, start, alternatives,
 +            |k, ps1, idx| matches!(
 +                k,
 +                TupleStruct(qself2, path2, ps2)
 +                    if eq_maybe_qself(qself1, qself2) && eq_path(path1, path2) && eq_pre_post(ps1, ps2, idx)
 +            ),
 +            |k| always_pat!(k, TupleStruct(_, _, ps) => ps),
 +        ),
 +        // Transform a record pattern `S { fp_0, ..., fp_n }`.
 +        Struct(qself1, path1, fps1, rest1) => extend_with_struct_pat(qself1, path1, fps1, *rest1, start, alternatives),
 +    };
 +
 +    alternatives[focus_idx].kind = focus_kind;
 +    changed
 +}
 +
 +/// Here we focusing on a record pattern `S { fp_0, ..., fp_n }`.
 +/// In particular, for a record pattern, the order in which the field patterns is irrelevant.
 +/// So when we fixate on some `ident_k: pat_k`, we try to find `ident_k` in the other pattern
 +/// and check that all `fp_i` where `i ∈ ((0...n) \ k)` between two patterns are equal.
 +fn extend_with_struct_pat(
 +    qself1: &Option<ast::QSelf>,
 +    path1: &ast::Path,
-     targets: &mut Vec<P<Pat>>,
++    fps1: &mut [ast::PatField],
 +    rest1: bool,
 +    start: usize,
 +    alternatives: &mut Vec<P<Pat>>,
 +) -> bool {
 +    (0..fps1.len()).any(|idx| {
 +        let pos_in_2 = Cell::new(None); // The element `k`.
 +        let tail_or = drain_matching(
 +            start,
 +            alternatives,
 +            |k| {
 +                matches!(k, Struct(qself2, path2, fps2, rest2)
 +                if rest1 == *rest2 // If one struct pattern has `..` so must the other.
 +                && eq_maybe_qself(qself1, qself2)
 +                && eq_path(path1, path2)
 +                && fps1.len() == fps2.len()
 +                && fps1.iter().enumerate().all(|(idx_1, fp1)| {
 +                    if idx_1 == idx {
 +                        // In the case of `k`, we merely require identical field names
 +                        // so that we will transform into `ident_k: p1_k | p2_k`.
 +                        let pos = fps2.iter().position(|fp2| eq_id(fp1.ident, fp2.ident));
 +                        pos_in_2.set(pos);
 +                        pos.is_some()
 +                    } else {
 +                        fps2.iter().any(|fp2| eq_field_pat(fp1, fp2))
 +                    }
 +                }))
 +            },
 +            // Extract `p2_k`.
 +            |k| always_pat!(k, Struct(_, _, mut fps, _) => fps.swap_remove(pos_in_2.take().unwrap()).pat),
 +        );
 +        extend_with_tail_or(&mut fps1[idx].pat, tail_or)
 +    })
 +}
 +
 +/// Like `extend_with_matching` but for products with > 1 factor, e.g., `C(p_0, ..., p_n)`.
 +/// Here, the idea is that we fixate on some `p_k` in `C`,
 +/// allowing it to vary between two `targets` and `ps2` (returned by `extract`),
 +/// while also requiring `ps1[..n] ~ ps2[..n]` (pre) and `ps1[n + 1..] ~ ps2[n + 1..]` (post),
 +/// where `~` denotes semantic equality.
 +fn extend_with_matching_product(
++    targets: &mut [P<Pat>],
 +    start: usize,
 +    alternatives: &mut Vec<P<Pat>>,
 +    predicate: impl Fn(&PatKind, &[P<Pat>], usize) -> bool,
 +    extract: impl Fn(PatKind) -> Vec<P<Pat>>,
 +) -> bool {
 +    (0..targets.len()).any(|idx| {
 +        let tail_or = drain_matching(
 +            start,
 +            alternatives,
 +            |k| predicate(k, targets, idx),
 +            |k| extract(k).swap_remove(idx),
 +        );
 +        extend_with_tail_or(&mut targets[idx], tail_or)
 +    })
 +}
 +
 +/// Extract the pattern from the given one and replace it with `Wild`.
 +/// This is meant for temporarily swapping out the pattern for manipulation.
 +fn take_pat(from: &mut Pat) -> Pat {
 +    let dummy = Pat {
 +        id: DUMMY_NODE_ID,
 +        kind: Wild,
 +        span: DUMMY_SP,
 +        tokens: None,
 +    };
 +    mem::replace(from, dummy)
 +}
 +
 +/// Extend `target` as an or-pattern with the alternatives
 +/// in `tail_or` if there are any and return if there were.
 +fn extend_with_tail_or(target: &mut Pat, tail_or: Vec<P<Pat>>) -> bool {
 +    fn extend(target: &mut Pat, mut tail_or: Vec<P<Pat>>) {
 +        match target {
 +            // On an existing or-pattern in the target, append to it.
 +            Pat { kind: Or(ps), .. } => ps.append(&mut tail_or),
 +            // Otherwise convert the target to an or-pattern.
 +            target => {
 +                let mut init_or = vec![P(take_pat(target))];
 +                init_or.append(&mut tail_or);
 +                target.kind = Or(init_or);
 +            },
 +        }
 +    }
 +
 +    let changed = !tail_or.is_empty();
 +    if changed {
 +        // Extend the target.
 +        extend(target, tail_or);
 +    }
 +    changed
 +}
 +
 +// Extract all inner patterns in `alternatives` matching our `predicate`.
 +// Only elements beginning with `start` are considered for extraction.
 +fn drain_matching(
 +    start: usize,
 +    alternatives: &mut Vec<P<Pat>>,
 +    predicate: impl Fn(&PatKind) -> bool,
 +    extract: impl Fn(PatKind) -> P<Pat>,
 +) -> Vec<P<Pat>> {
 +    let mut tail_or = vec![];
 +    let mut idx = 0;
 +    for pat in alternatives.drain_filter(|p| {
 +        // Check if we should extract, but only if `idx >= start`.
 +        idx += 1;
 +        idx > start && predicate(&p.kind)
 +    }) {
 +        tail_or.push(extract(pat.into_inner().kind));
 +    }
 +    tail_or
 +}
 +
 +fn extend_with_matching(
 +    target: &mut Pat,
 +    start: usize,
 +    alternatives: &mut Vec<P<Pat>>,
 +    predicate: impl Fn(&PatKind) -> bool,
 +    extract: impl Fn(PatKind) -> P<Pat>,
 +) -> bool {
 +    extend_with_tail_or(target, drain_matching(start, alternatives, predicate, extract))
 +}
 +
 +/// Are the patterns in `ps1` and `ps2` equal save for `ps1[idx]` compared to `ps2[idx]`?
 +fn eq_pre_post(ps1: &[P<Pat>], ps2: &[P<Pat>], idx: usize) -> bool {
 +    ps1.len() == ps2.len()
 +        && ps1[idx].is_rest() == ps2[idx].is_rest() // Avoid `[x, ..] | [x, 0]` => `[x, .. | 0]`.
 +        && over(&ps1[..idx], &ps2[..idx], |l, r| eq_pat(l, r))
 +        && over(&ps1[idx + 1..], &ps2[idx + 1..], |l, r| eq_pat(l, r))
 +}
index d6deb50cc907379f7b66b633c8eaf77b298976a4,0000000000000000000000000000000000000000..c9d99617c1e281f8315bfc2669fd71243155a3ad
mode 100644,000000..100644
--- /dev/null
@@@ -1,353 -1,0 +1,353 @@@
-     /// Lint: MANUAL_SPLIT_ONCE, MANUAL_STR_REPEAT, CLONED_INSTEAD_OF_COPIED, REDUNDANT_FIELD_NAMES, REDUNDANT_STATIC_LIFETIMES, FILTER_MAP_NEXT, CHECKED_CONVERSIONS, MANUAL_RANGE_CONTAINS, USE_SELF, MEM_REPLACE_WITH_DEFAULT, MANUAL_NON_EXHAUSTIVE, OPTION_AS_REF_DEREF, MAP_UNWRAP_OR, MATCH_LIKE_MATCHES_MACRO, MANUAL_STRIP, MISSING_CONST_FOR_FN, UNNESTED_OR_PATTERNS, FROM_OVER_INTO, PTR_AS_PTR, IF_THEN_SOME_ELSE_NONE, APPROX_CONSTANT, DEPRECATED_CFG_ATTR, INDEX_REFUTABLE_SLICE.
 +//! Read configurations files.
 +
 +#![allow(clippy::module_name_repetitions)]
 +
 +use serde::de::{Deserializer, IgnoredAny, IntoDeserializer, MapAccess, Visitor};
 +use serde::Deserialize;
 +use std::error::Error;
 +use std::path::{Path, PathBuf};
 +use std::{env, fmt, fs, io};
 +
 +/// Holds information used by `MISSING_ENFORCED_IMPORT_RENAMES` lint.
 +#[derive(Clone, Debug, Deserialize)]
 +pub struct Rename {
 +    pub path: String,
 +    pub rename: String,
 +}
 +
 +/// A single disallowed method, used by the `DISALLOWED_METHODS` lint.
 +#[derive(Clone, Debug, Deserialize)]
 +#[serde(untagged)]
 +pub enum DisallowedMethod {
 +    Simple(String),
 +    WithReason { path: String, reason: Option<String> },
 +}
 +
 +impl DisallowedMethod {
 +    pub fn path(&self) -> &str {
 +        let (Self::Simple(path) | Self::WithReason { path, .. }) = self;
 +
 +        path
 +    }
 +}
 +
 +/// A single disallowed type, used by the `DISALLOWED_TYPES` lint.
 +#[derive(Clone, Debug, Deserialize)]
 +#[serde(untagged)]
 +pub enum DisallowedType {
 +    Simple(String),
 +    WithReason { path: String, reason: Option<String> },
 +}
 +
 +/// Conf with parse errors
 +#[derive(Default)]
 +pub struct TryConf {
 +    pub conf: Conf,
 +    pub errors: Vec<String>,
 +}
 +
 +impl TryConf {
 +    fn from_error(error: impl Error) -> Self {
 +        Self {
 +            conf: Conf::default(),
 +            errors: vec![error.to_string()],
 +        }
 +    }
 +}
 +
 +macro_rules! define_Conf {
 +    ($(
 +        $(#[doc = $doc:literal])+
 +        $(#[conf_deprecated($dep:literal)])?
 +        ($name:ident: $ty:ty = $default:expr),
 +    )*) => {
 +        /// Clippy lint configuration
 +        pub struct Conf {
 +            $($(#[doc = $doc])+ pub $name: $ty,)*
 +        }
 +
 +        mod defaults {
 +            $(pub fn $name() -> $ty { $default })*
 +        }
 +
 +        impl Default for Conf {
 +            fn default() -> Self {
 +                Self { $($name: defaults::$name(),)* }
 +            }
 +        }
 +
 +        impl<'de> Deserialize<'de> for TryConf {
 +            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: Deserializer<'de> {
 +                deserializer.deserialize_map(ConfVisitor)
 +            }
 +        }
 +
 +        #[derive(Deserialize)]
 +        #[serde(field_identifier, rename_all = "kebab-case")]
 +        #[allow(non_camel_case_types)]
 +        enum Field { $($name,)* third_party, }
 +
 +        struct ConfVisitor;
 +
 +        impl<'de> Visitor<'de> for ConfVisitor {
 +            type Value = TryConf;
 +
 +            fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
 +                formatter.write_str("Conf")
 +            }
 +
 +            fn visit_map<V>(self, mut map: V) -> Result<Self::Value, V::Error> where V: MapAccess<'de> {
 +                let mut errors = Vec::new();
 +                $(let mut $name = None;)*
 +                // could get `Field` here directly, but get `str` first for diagnostics
 +                while let Some(name) = map.next_key::<&str>()? {
 +                    match Field::deserialize(name.into_deserializer())? {
 +                        $(Field::$name => {
 +                            $(errors.push(format!("deprecated field `{}`. {}", name, $dep));)?
 +                            match map.next_value() {
 +                                Err(e) => errors.push(e.to_string()),
 +                                Ok(value) => match $name {
 +                                    Some(_) => errors.push(format!("duplicate field `{}`", name)),
 +                                    None => $name = Some(value),
 +                                }
 +                            }
 +                        })*
 +                        // white-listed; ignore
 +                        Field::third_party => drop(map.next_value::<IgnoredAny>())
 +                    }
 +                }
 +                let conf = Conf { $($name: $name.unwrap_or_else(defaults::$name),)* };
 +                Ok(TryConf { conf, errors })
 +            }
 +        }
 +
 +        #[cfg(feature = "internal")]
 +        pub mod metadata {
 +            use crate::utils::internal_lints::metadata_collector::ClippyConfiguration;
 +
 +            macro_rules! wrap_option {
 +                () => (None);
 +                ($x:literal) => (Some($x));
 +            }
 +
 +            pub(crate) fn get_configuration_metadata() -> Vec<ClippyConfiguration> {
 +                vec![
 +                    $(
 +                        {
 +                            let deprecation_reason = wrap_option!($($dep)?);
 +
 +                            ClippyConfiguration::new(
 +                                stringify!($name),
 +                                stringify!($ty),
 +                                format!("{:?}", super::defaults::$name()),
 +                                concat!($($doc, '\n',)*),
 +                                deprecation_reason,
 +                            )
 +                        },
 +                    )+
 +                ]
 +            }
 +        }
 +    };
 +}
 +
 +define_Conf! {
 +    /// Lint: ENUM_VARIANT_NAMES, LARGE_TYPES_PASSED_BY_VALUE, TRIVIALLY_COPY_PASS_BY_REF, UNNECESSARY_WRAPS, UPPER_CASE_ACRONYMS, WRONG_SELF_CONVENTION, BOX_COLLECTION, REDUNDANT_ALLOCATION, RC_BUFFER, VEC_BOX, OPTION_OPTION, LINKEDLIST, RC_MUTEX.
 +    ///
 +    /// Suppress lints whenever the suggested change would cause breakage for other crates.
 +    (avoid_breaking_exported_api: bool = true),
++    /// Lint: MANUAL_SPLIT_ONCE, MANUAL_STR_REPEAT, CLONED_INSTEAD_OF_COPIED, REDUNDANT_FIELD_NAMES, REDUNDANT_STATIC_LIFETIMES, FILTER_MAP_NEXT, CHECKED_CONVERSIONS, MANUAL_RANGE_CONTAINS, USE_SELF, MEM_REPLACE_WITH_DEFAULT, MANUAL_NON_EXHAUSTIVE, OPTION_AS_REF_DEREF, MAP_UNWRAP_OR, MATCH_LIKE_MATCHES_MACRO, MANUAL_STRIP, MISSING_CONST_FOR_FN, UNNESTED_OR_PATTERNS, FROM_OVER_INTO, PTR_AS_PTR, IF_THEN_SOME_ELSE_NONE, APPROX_CONSTANT, DEPRECATED_CFG_ATTR, INDEX_REFUTABLE_SLICE, MAP_CLONE, BORROW_AS_PTR, MANUAL_BITS.
 +    ///
 +    /// The minimum rust version that the project supports
 +    (msrv: Option<String> = None),
 +    /// Lint: BLACKLISTED_NAME.
 +    ///
 +    /// The list of blacklisted names to lint about. NB: `bar` is not here since it has legitimate uses
 +    (blacklisted_names: Vec<String> = ["foo", "baz", "quux"].iter().map(ToString::to_string).collect()),
 +    /// Lint: COGNITIVE_COMPLEXITY.
 +    ///
 +    /// The maximum cognitive complexity a function can have
 +    (cognitive_complexity_threshold: u64 = 25),
 +    /// DEPRECATED LINT: CYCLOMATIC_COMPLEXITY.
 +    ///
 +    /// Use the Cognitive Complexity lint instead.
 +    #[conf_deprecated("Please use `cognitive-complexity-threshold` instead")]
 +    (cyclomatic_complexity_threshold: Option<u64> = None),
 +    /// Lint: DOC_MARKDOWN.
 +    ///
 +    /// The list of words this lint should not consider as identifiers needing ticks
 +    (doc_valid_idents: Vec<String> = [
 +        "KiB", "MiB", "GiB", "TiB", "PiB", "EiB",
 +        "DirectX",
 +        "ECMAScript",
 +        "GPLv2", "GPLv3",
 +        "GitHub", "GitLab",
 +        "IPv4", "IPv6",
 +        "ClojureScript", "CoffeeScript", "JavaScript", "PureScript", "TypeScript",
 +        "NaN", "NaNs",
 +        "OAuth", "GraphQL",
 +        "OCaml",
 +        "OpenGL", "OpenMP", "OpenSSH", "OpenSSL", "OpenStreetMap", "OpenDNS",
 +        "WebGL",
 +        "TensorFlow",
 +        "TrueType",
 +        "iOS", "macOS", "FreeBSD",
 +        "TeX", "LaTeX", "BibTeX", "BibLaTeX",
 +        "MinGW",
 +        "CamelCase",
 +    ].iter().map(ToString::to_string).collect()),
 +    /// Lint: TOO_MANY_ARGUMENTS.
 +    ///
 +    /// The maximum number of argument a function or method can have
 +    (too_many_arguments_threshold: u64 = 7),
 +    /// Lint: TYPE_COMPLEXITY.
 +    ///
 +    /// The maximum complexity a type can have
 +    (type_complexity_threshold: u64 = 250),
 +    /// Lint: MANY_SINGLE_CHAR_NAMES.
 +    ///
 +    /// The maximum number of single char bindings a scope may have
 +    (single_char_binding_names_threshold: u64 = 4),
 +    /// Lint: BOXED_LOCAL, USELESS_VEC.
 +    ///
 +    /// The maximum size of objects (in bytes) that will be linted. Larger objects are ok on the heap
 +    (too_large_for_stack: u64 = 200),
 +    /// Lint: ENUM_VARIANT_NAMES.
 +    ///
 +    /// The minimum number of enum variants for the lints about variant names to trigger
 +    (enum_variant_name_threshold: u64 = 3),
 +    /// Lint: LARGE_ENUM_VARIANT.
 +    ///
 +    /// The maximum size of an enum's variant to avoid box suggestion
 +    (enum_variant_size_threshold: u64 = 200),
 +    /// Lint: VERBOSE_BIT_MASK.
 +    ///
 +    /// The maximum allowed size of a bit mask before suggesting to use 'trailing_zeros'
 +    (verbose_bit_mask_threshold: u64 = 1),
 +    /// Lint: DECIMAL_LITERAL_REPRESENTATION.
 +    ///
 +    /// The lower bound for linting decimal literals
 +    (literal_representation_threshold: u64 = 16384),
 +    /// Lint: TRIVIALLY_COPY_PASS_BY_REF.
 +    ///
 +    /// The maximum size (in bytes) to consider a `Copy` type for passing by value instead of by reference.
 +    (trivial_copy_size_limit: Option<u64> = None),
 +    /// Lint: LARGE_TYPE_PASS_BY_MOVE.
 +    ///
 +    /// The minimum size (in bytes) to consider a type for passing by reference instead of by value.
 +    (pass_by_value_size_limit: u64 = 256),
 +    /// Lint: TOO_MANY_LINES.
 +    ///
 +    /// The maximum number of lines a function or method can have
 +    (too_many_lines_threshold: u64 = 100),
 +    /// Lint: LARGE_STACK_ARRAYS, LARGE_CONST_ARRAYS.
 +    ///
 +    /// The maximum allowed size for arrays on the stack
 +    (array_size_threshold: u64 = 512_000),
 +    /// Lint: VEC_BOX.
 +    ///
 +    /// The size of the boxed type in bytes, where boxing in a `Vec` is allowed
 +    (vec_box_size_threshold: u64 = 4096),
 +    /// Lint: TYPE_REPETITION_IN_BOUNDS.
 +    ///
 +    /// The maximum number of bounds a trait can have to be linted
 +    (max_trait_bounds: u64 = 3),
 +    /// Lint: STRUCT_EXCESSIVE_BOOLS.
 +    ///
 +    /// The maximum number of bool fields a struct can have
 +    (max_struct_bools: u64 = 3),
 +    /// Lint: FN_PARAMS_EXCESSIVE_BOOLS.
 +    ///
 +    /// The maximum number of bool parameters a function can have
 +    (max_fn_params_bools: u64 = 3),
 +    /// Lint: WILDCARD_IMPORTS.
 +    ///
 +    /// Whether to allow certain wildcard imports (prelude, super in tests).
 +    (warn_on_all_wildcard_imports: bool = false),
 +    /// Lint: DISALLOWED_METHODS.
 +    ///
 +    /// The list of disallowed methods, written as fully qualified paths.
 +    (disallowed_methods: Vec<crate::utils::conf::DisallowedMethod> = Vec::new()),
 +    /// Lint: DISALLOWED_TYPES.
 +    ///
 +    /// The list of disallowed types, written as fully qualified paths.
 +    (disallowed_types: Vec<crate::utils::conf::DisallowedType> = Vec::new()),
 +    /// Lint: UNREADABLE_LITERAL.
 +    ///
 +    /// Should the fraction of a decimal be linted to include separators.
 +    (unreadable_literal_lint_fractions: bool = true),
 +    /// Lint: UPPER_CASE_ACRONYMS.
 +    ///
 +    /// Enables verbose mode. Triggers if there is more than one uppercase char next to each other
 +    (upper_case_acronyms_aggressive: bool = false),
 +    /// Lint: _CARGO_COMMON_METADATA.
 +    ///
 +    /// For internal testing only, ignores the current `publish` settings in the Cargo manifest.
 +    (cargo_ignore_publish: bool = false),
 +    /// Lint: NONSTANDARD_MACRO_BRACES.
 +    ///
 +    /// Enforce the named macros always use the braces specified.
 +    ///
 +    /// A `MacroMatcher` can be added like so `{ name = "macro_name", brace = "(" }`. If the macro
 +    /// is could be used with a full path two `MacroMatcher`s have to be added one with the full path
 +    /// `crate_name::macro_name` and one with just the macro name.
 +    (standard_macro_braces: Vec<crate::nonstandard_macro_braces::MacroMatcher> = Vec::new()),
 +    /// Lint: MISSING_ENFORCED_IMPORT_RENAMES.
 +    ///
 +    /// The list of imports to always rename, a fully qualified path followed by the rename.
 +    (enforced_import_renames: Vec<crate::utils::conf::Rename> = Vec::new()),
 +    /// Lint: DISALLOWED_SCRIPT_IDENTS.
 +    ///
 +    /// The list of unicode scripts allowed to be used in the scope.
 +    (allowed_scripts: Vec<String> = ["Latin"].iter().map(ToString::to_string).collect()),
 +    /// Lint: NON_SEND_FIELDS_IN_SEND_TY.
 +    ///
 +    /// Whether to apply the raw pointer heuristic to determine if a type is `Send`.
 +    (enable_raw_pointer_heuristic_for_send: bool = true),
 +    /// Lint: INDEX_REFUTABLE_SLICE.
 +    ///
 +    /// When Clippy suggests using a slice pattern, this is the maximum number of elements allowed in
 +    /// the slice pattern that is suggested. If more elements would be necessary, the lint is suppressed.
 +    /// For example, `[_, _, _, e, ..]` is a slice pattern with 4 elements.
 +    (max_suggested_slice_pattern_length: u64 = 3),
 +}
 +
 +/// Search for the configuration file.
 +pub fn lookup_conf_file() -> io::Result<Option<PathBuf>> {
 +    /// Possible filename to search for.
 +    const CONFIG_FILE_NAMES: [&str; 2] = [".clippy.toml", "clippy.toml"];
 +
 +    // Start looking for a config file in CLIPPY_CONF_DIR, or failing that, CARGO_MANIFEST_DIR.
 +    // If neither of those exist, use ".".
 +    let mut current = env::var_os("CLIPPY_CONF_DIR")
 +        .or_else(|| env::var_os("CARGO_MANIFEST_DIR"))
 +        .map_or_else(|| PathBuf::from("."), PathBuf::from);
 +    loop {
 +        for config_file_name in &CONFIG_FILE_NAMES {
 +            if let Ok(config_file) = current.join(config_file_name).canonicalize() {
 +                match fs::metadata(&config_file) {
 +                    Err(e) if e.kind() == io::ErrorKind::NotFound => {},
 +                    Err(e) => return Err(e),
 +                    Ok(md) if md.is_dir() => {},
 +                    Ok(_) => return Ok(Some(config_file)),
 +                }
 +            }
 +        }
 +
 +        // If the current directory has no parent, we're done searching.
 +        if !current.pop() {
 +            return Ok(None);
 +        }
 +    }
 +}
 +
 +/// Read the `toml` configuration file.
 +///
 +/// In case of error, the function tries to continue as much as possible.
 +pub fn read(path: &Path) -> TryConf {
 +    let content = match fs::read_to_string(path) {
 +        Err(e) => return TryConf::from_error(e),
 +        Ok(content) => content,
 +    };
 +    toml::from_str(&content).unwrap_or_else(TryConf::from_error)
 +}
index ec1b5a499d472a401b6677fbf163f40614812e33,0000000000000000000000000000000000000000..f170ff69154b6532934489e96d089d670beb32dd
mode 100644,000000..100644
--- /dev/null
@@@ -1,1315 -1,0 +1,1316 @@@
 +use clippy_utils::consts::{constant_simple, Constant};
 +use clippy_utils::diagnostics::{span_lint, span_lint_and_help, span_lint_and_sugg, span_lint_and_then};
 +use clippy_utils::macros::root_macro_call_first_node;
 +use clippy_utils::source::snippet;
 +use clippy_utils::ty::match_type;
 +use clippy_utils::{
 +    higher, is_else_clause, is_expn_of, is_expr_path_def_path, is_lint_allowed, match_def_path, method_calls,
 +    path_to_res, paths, peel_blocks_with_stmt, SpanlessEq,
 +};
 +use if_chain::if_chain;
 +use rustc_ast as ast;
 +use rustc_ast::ast::{Crate, ItemKind, LitKind, ModKind, NodeId};
 +use rustc_ast::visit::FnKind;
 +use rustc_data_structures::fx::{FxHashMap, FxHashSet};
 +use rustc_errors::Applicability;
 +use rustc_hir as hir;
 +use rustc_hir::def::{DefKind, Res};
 +use rustc_hir::def_id::DefId;
 +use rustc_hir::hir_id::CRATE_HIR_ID;
 +use rustc_hir::intravisit::Visitor;
 +use rustc_hir::{
 +    BinOpKind, Block, Expr, ExprKind, HirId, Item, Local, MutTy, Mutability, Node, Path, Stmt, StmtKind, Ty, TyKind,
 +    UnOp,
 +};
 +use rustc_lint::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext};
++use rustc_middle::hir::nested_filter;
 +use rustc_middle::mir::interpret::ConstValue;
 +use rustc_middle::ty;
 +use rustc_semver::RustcVersion;
 +use rustc_session::{declare_lint_pass, declare_tool_lint, impl_lint_pass};
 +use rustc_span::source_map::Spanned;
 +use rustc_span::symbol::Symbol;
 +use rustc_span::{sym, BytePos, Span};
 +use rustc_typeck::hir_ty_to_ty;
 +
 +use std::borrow::{Borrow, Cow};
 +
 +#[cfg(feature = "internal")]
 +pub mod metadata_collector;
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for various things we like to keep tidy in clippy.
 +    ///
 +    /// ### Why is this bad?
 +    /// We like to pretend we're an example of tidy code.
 +    ///
 +    /// ### Example
 +    /// Wrong ordering of the util::paths constants.
 +    pub CLIPPY_LINTS_INTERNAL,
 +    internal,
 +    "various things that will negatively affect your clippy experience"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Ensures every lint is associated to a `LintPass`.
 +    ///
 +    /// ### Why is this bad?
 +    /// The compiler only knows lints via a `LintPass`. Without
 +    /// putting a lint to a `LintPass::get_lints()`'s return, the compiler will not
 +    /// know the name of the lint.
 +    ///
 +    /// ### Known problems
 +    /// Only checks for lints associated using the
 +    /// `declare_lint_pass!`, `impl_lint_pass!`, and `lint_array!` macros.
 +    ///
 +    /// ### Example
 +    /// ```rust,ignore
 +    /// declare_lint! { pub LINT_1, ... }
 +    /// declare_lint! { pub LINT_2, ... }
 +    /// declare_lint! { pub FORGOTTEN_LINT, ... }
 +    /// // ...
 +    /// declare_lint_pass!(Pass => [LINT_1, LINT_2]);
 +    /// // missing FORGOTTEN_LINT
 +    /// ```
 +    pub LINT_WITHOUT_LINT_PASS,
 +    internal,
 +    "declaring a lint without associating it in a LintPass"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for calls to `cx.span_lint*` and suggests to use the `utils::*`
 +    /// variant of the function.
 +    ///
 +    /// ### Why is this bad?
 +    /// The `utils::*` variants also add a link to the Clippy documentation to the
 +    /// warning/error messages.
 +    ///
 +    /// ### Example
 +    /// Bad:
 +    /// ```rust,ignore
 +    /// cx.span_lint(LINT_NAME, "message");
 +    /// ```
 +    ///
 +    /// Good:
 +    /// ```rust,ignore
 +    /// utils::span_lint(cx, LINT_NAME, "message");
 +    /// ```
 +    pub COMPILER_LINT_FUNCTIONS,
 +    internal,
 +    "usage of the lint functions of the compiler instead of the utils::* variant"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for calls to `cx.outer().expn_data()` and suggests to use
 +    /// the `cx.outer_expn_data()`
 +    ///
 +    /// ### Why is this bad?
 +    /// `cx.outer_expn_data()` is faster and more concise.
 +    ///
 +    /// ### Example
 +    /// Bad:
 +    /// ```rust,ignore
 +    /// expr.span.ctxt().outer().expn_data()
 +    /// ```
 +    ///
 +    /// Good:
 +    /// ```rust,ignore
 +    /// expr.span.ctxt().outer_expn_data()
 +    /// ```
 +    pub OUTER_EXPN_EXPN_DATA,
 +    internal,
 +    "using `cx.outer_expn().expn_data()` instead of `cx.outer_expn_data()`"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Not an actual lint. This lint is only meant for testing our customized internal compiler
 +    /// error message by calling `panic`.
 +    ///
 +    /// ### Why is this bad?
 +    /// ICE in large quantities can damage your teeth
 +    ///
 +    /// ### Example
 +    /// Bad:
 +    /// ```rust,ignore
 +    /// 🍦🍦🍦🍦🍦
 +    /// ```
 +    pub PRODUCE_ICE,
 +    internal,
 +    "this message should not appear anywhere as we ICE before and don't emit the lint"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for cases of an auto-generated lint without an updated description,
 +    /// i.e. `default lint description`.
 +    ///
 +    /// ### Why is this bad?
 +    /// Indicates that the lint is not finished.
 +    ///
 +    /// ### Example
 +    /// Bad:
 +    /// ```rust,ignore
 +    /// declare_lint! { pub COOL_LINT, nursery, "default lint description" }
 +    /// ```
 +    ///
 +    /// Good:
 +    /// ```rust,ignore
 +    /// declare_lint! { pub COOL_LINT, nursery, "a great new lint" }
 +    /// ```
 +    pub DEFAULT_LINT,
 +    internal,
 +    "found 'default lint description' in a lint declaration"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Lints `span_lint_and_then` function calls, where the
 +    /// closure argument has only one statement and that statement is a method
 +    /// call to `span_suggestion`, `span_help`, `span_note` (using the same
 +    /// span), `help` or `note`.
 +    ///
 +    /// These usages of `span_lint_and_then` should be replaced with one of the
 +    /// wrapper functions `span_lint_and_sugg`, span_lint_and_help`, or
 +    /// `span_lint_and_note`.
 +    ///
 +    /// ### Why is this bad?
 +    /// Using the wrapper `span_lint_and_*` functions, is more
 +    /// convenient, readable and less error prone.
 +    ///
 +    /// ### Example
 +    /// Bad:
 +    /// ```rust,ignore
 +    /// span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |diag| {
 +    ///     diag.span_suggestion(
 +    ///         expr.span,
 +    ///         help_msg,
 +    ///         sugg.to_string(),
 +    ///         Applicability::MachineApplicable,
 +    ///     );
 +    /// });
 +    /// span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |diag| {
 +    ///     diag.span_help(expr.span, help_msg);
 +    /// });
 +    /// span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |diag| {
 +    ///     diag.help(help_msg);
 +    /// });
 +    /// span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |diag| {
 +    ///     diag.span_note(expr.span, note_msg);
 +    /// });
 +    /// span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |diag| {
 +    ///     diag.note(note_msg);
 +    /// });
 +    /// ```
 +    ///
 +    /// Good:
 +    /// ```rust,ignore
 +    /// span_lint_and_sugg(
 +    ///     cx,
 +    ///     TEST_LINT,
 +    ///     expr.span,
 +    ///     lint_msg,
 +    ///     help_msg,
 +    ///     sugg.to_string(),
 +    ///     Applicability::MachineApplicable,
 +    /// );
 +    /// span_lint_and_help(cx, TEST_LINT, expr.span, lint_msg, Some(expr.span), help_msg);
 +    /// span_lint_and_help(cx, TEST_LINT, expr.span, lint_msg, None, help_msg);
 +    /// span_lint_and_note(cx, TEST_LINT, expr.span, lint_msg, Some(expr.span), note_msg);
 +    /// span_lint_and_note(cx, TEST_LINT, expr.span, lint_msg, None, note_msg);
 +    /// ```
 +    pub COLLAPSIBLE_SPAN_LINT_CALLS,
 +    internal,
 +    "found collapsible `span_lint_and_then` calls"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for calls to `utils::match_type()` on a type diagnostic item
 +    /// and suggests to use `utils::is_type_diagnostic_item()` instead.
 +    ///
 +    /// ### Why is this bad?
 +    /// `utils::is_type_diagnostic_item()` does not require hardcoded paths.
 +    ///
 +    /// ### Example
 +    /// Bad:
 +    /// ```rust,ignore
 +    /// utils::match_type(cx, ty, &paths::VEC)
 +    /// ```
 +    ///
 +    /// Good:
 +    /// ```rust,ignore
 +    /// utils::is_type_diagnostic_item(cx, ty, sym::Vec)
 +    /// ```
 +    pub MATCH_TYPE_ON_DIAGNOSTIC_ITEM,
 +    internal,
 +    "using `utils::match_type()` instead of `utils::is_type_diagnostic_item()`"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks the paths module for invalid paths.
 +    ///
 +    /// ### Why is this bad?
 +    /// It indicates a bug in the code.
 +    ///
 +    /// ### Example
 +    /// None.
 +    pub INVALID_PATHS,
 +    internal,
 +    "invalid path"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for interning symbols that have already been pre-interned and defined as constants.
 +    ///
 +    /// ### Why is this bad?
 +    /// It's faster and easier to use the symbol constant.
 +    ///
 +    /// ### Example
 +    /// Bad:
 +    /// ```rust,ignore
 +    /// let _ = sym!(f32);
 +    /// ```
 +    ///
 +    /// Good:
 +    /// ```rust,ignore
 +    /// let _ = sym::f32;
 +    /// ```
 +    pub INTERNING_DEFINED_SYMBOL,
 +    internal,
 +    "interning a symbol that is pre-interned and defined as a constant"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for unnecessary conversion from Symbol to a string.
 +    ///
 +    /// ### Why is this bad?
 +    /// It's faster use symbols directly intead of strings.
 +    ///
 +    /// ### Example
 +    /// Bad:
 +    /// ```rust,ignore
 +    /// symbol.as_str() == "clippy";
 +    /// ```
 +    ///
 +    /// Good:
 +    /// ```rust,ignore
 +    /// symbol == sym::clippy;
 +    /// ```
 +    pub UNNECESSARY_SYMBOL_STR,
 +    internal,
 +    "unnecessary conversion between Symbol and string"
 +}
 +
 +declare_clippy_lint! {
 +    /// Finds unidiomatic usage of `if_chain!`
 +    pub IF_CHAIN_STYLE,
 +    internal,
 +    "non-idiomatic `if_chain!` usage"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for invalid `clippy::version` attributes.
 +    ///
 +    /// Valid values are:
 +    /// * "pre 1.29.0"
 +    /// * any valid semantic version
 +    pub INVALID_CLIPPY_VERSION_ATTRIBUTE,
 +    internal,
 +    "found an invalid `clippy::version` attribute"
 +}
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Checks for declared clippy lints without the `clippy::version` attribute.
 +    ///
 +    pub MISSING_CLIPPY_VERSION_ATTRIBUTE,
 +    internal,
 +    "found clippy lint without `clippy::version` attribute"
 +}
 +
 +declare_lint_pass!(ClippyLintsInternal => [CLIPPY_LINTS_INTERNAL]);
 +
 +impl EarlyLintPass for ClippyLintsInternal {
 +    fn check_crate(&mut self, cx: &EarlyContext<'_>, krate: &Crate) {
 +        if let Some(utils) = krate.items.iter().find(|item| item.ident.name.as_str() == "utils") {
 +            if let ItemKind::Mod(_, ModKind::Loaded(ref items, ..)) = utils.kind {
 +                if let Some(paths) = items.iter().find(|item| item.ident.name.as_str() == "paths") {
 +                    if let ItemKind::Mod(_, ModKind::Loaded(ref items, ..)) = paths.kind {
 +                        let mut last_name: Option<&str> = None;
 +                        for item in items {
 +                            let name = item.ident.as_str();
 +                            if let Some(last_name) = last_name {
 +                                if *last_name > *name {
 +                                    span_lint(
 +                                        cx,
 +                                        CLIPPY_LINTS_INTERNAL,
 +                                        item.span,
 +                                        "this constant should be before the previous constant due to lexical \
 +                                         ordering",
 +                                    );
 +                                }
 +                            }
 +                            last_name = Some(name);
 +                        }
 +                    }
 +                }
 +            }
 +        }
 +    }
 +}
 +
 +#[derive(Clone, Debug, Default)]
 +pub struct LintWithoutLintPass {
 +    declared_lints: FxHashMap<Symbol, Span>,
 +    registered_lints: FxHashSet<Symbol>,
 +}
 +
 +impl_lint_pass!(LintWithoutLintPass => [DEFAULT_LINT, LINT_WITHOUT_LINT_PASS, INVALID_CLIPPY_VERSION_ATTRIBUTE, MISSING_CLIPPY_VERSION_ATTRIBUTE]);
 +
 +impl<'tcx> LateLintPass<'tcx> for LintWithoutLintPass {
 +    fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
 +        if is_lint_allowed(cx, DEFAULT_LINT, item.hir_id()) {
 +            return;
 +        }
 +
 +        if let hir::ItemKind::Static(ty, Mutability::Not, body_id) = item.kind {
 +            if is_lint_ref_type(cx, ty) {
 +                check_invalid_clippy_version_attribute(cx, item);
 +
 +                let expr = &cx.tcx.hir().body(body_id).value;
 +                if_chain! {
 +                    if let ExprKind::AddrOf(_, _, inner_exp) = expr.kind;
 +                    if let ExprKind::Struct(_, fields, _) = inner_exp.kind;
 +                    let field = fields
 +                        .iter()
 +                        .find(|f| f.ident.as_str() == "desc")
 +                        .expect("lints must have a description field");
 +                    if let ExprKind::Lit(Spanned {
 +                        node: LitKind::Str(ref sym, _),
 +                        ..
 +                    }) = field.expr.kind;
 +                    if sym.as_str() == "default lint description";
 +
 +                    then {
 +                        span_lint(
 +                            cx,
 +                            DEFAULT_LINT,
 +                            item.span,
 +                            &format!("the lint `{}` has the default lint description", item.ident.name),
 +                        );
 +                    }
 +                }
 +                self.declared_lints.insert(item.ident.name, item.span);
 +            }
 +        } else if let Some(macro_call) = root_macro_call_first_node(cx, item) {
 +            if !matches!(
 +                &*cx.tcx.item_name(macro_call.def_id).as_str(),
 +                "impl_lint_pass" | "declare_lint_pass"
 +            ) {
 +                return;
 +            }
 +            if let hir::ItemKind::Impl(hir::Impl {
 +                of_trait: None,
 +                items: impl_item_refs,
 +                ..
 +            }) = item.kind
 +            {
 +                let mut collector = LintCollector {
 +                    output: &mut self.registered_lints,
 +                    cx,
 +                };
 +                let body_id = cx.tcx.hir().body_owned_by(
 +                    impl_item_refs
 +                        .iter()
 +                        .find(|iiref| iiref.ident.as_str() == "get_lints")
 +                        .expect("LintPass needs to implement get_lints")
 +                        .id
 +                        .hir_id(),
 +                );
 +                collector.visit_expr(&cx.tcx.hir().body(body_id).value);
 +            }
 +        }
 +    }
 +
 +    fn check_crate_post(&mut self, cx: &LateContext<'tcx>) {
 +        if is_lint_allowed(cx, LINT_WITHOUT_LINT_PASS, CRATE_HIR_ID) {
 +            return;
 +        }
 +
 +        for (lint_name, &lint_span) in &self.declared_lints {
 +            // When using the `declare_tool_lint!` macro, the original `lint_span`'s
 +            // file points to "<rustc macros>".
 +            // `compiletest-rs` thinks that's an error in a different file and
 +            // just ignores it. This causes the test in compile-fail/lint_pass
 +            // not able to capture the error.
 +            // Therefore, we need to climb the macro expansion tree and find the
 +            // actual span that invoked `declare_tool_lint!`:
 +            let lint_span = lint_span.ctxt().outer_expn_data().call_site;
 +
 +            if !self.registered_lints.contains(lint_name) {
 +                span_lint(
 +                    cx,
 +                    LINT_WITHOUT_LINT_PASS,
 +                    lint_span,
 +                    &format!("the lint `{}` is not added to any `LintPass`", lint_name),
 +                );
 +            }
 +        }
 +    }
 +}
 +
 +fn is_lint_ref_type<'tcx>(cx: &LateContext<'tcx>, ty: &Ty<'_>) -> bool {
 +    if let TyKind::Rptr(
 +        _,
 +        MutTy {
 +            ty: inner,
 +            mutbl: Mutability::Not,
 +        },
 +    ) = ty.kind
 +    {
 +        if let TyKind::Path(ref path) = inner.kind {
 +            if let Res::Def(DefKind::Struct, def_id) = cx.qpath_res(path, inner.hir_id) {
 +                return match_def_path(cx, def_id, &paths::LINT);
 +            }
 +        }
 +    }
 +
 +    false
 +}
 +
 +fn check_invalid_clippy_version_attribute(cx: &LateContext<'_>, item: &'_ Item<'_>) {
 +    if let Some(value) = extract_clippy_version_value(cx, item) {
 +        // The `sym!` macro doesn't work as it only expects a single token.
 +        // It's better to keep it this way and have a direct `Symbol::intern` call here.
 +        if value == Symbol::intern("pre 1.29.0") {
 +            return;
 +        }
 +
 +        if RustcVersion::parse(&*value.as_str()).is_err() {
 +            span_lint_and_help(
 +                cx,
 +                INVALID_CLIPPY_VERSION_ATTRIBUTE,
 +                item.span,
 +                "this item has an invalid `clippy::version` attribute",
 +                None,
 +                "please use a valid sematic version, see `doc/adding_lints.md`",
 +            );
 +        }
 +    } else {
 +        span_lint_and_help(
 +            cx,
 +            MISSING_CLIPPY_VERSION_ATTRIBUTE,
 +            item.span,
 +            "this lint is missing the `clippy::version` attribute or version value",
 +            None,
 +            "please use a `clippy::version` attribute, see `doc/adding_lints.md`",
 +        );
 +    }
 +}
 +
 +/// This function extracts the version value of a `clippy::version` attribute if the given value has
 +/// one
 +fn extract_clippy_version_value(cx: &LateContext<'_>, item: &'_ Item<'_>) -> Option<Symbol> {
 +    let attrs = cx.tcx.hir().attrs(item.hir_id());
 +    attrs.iter().find_map(|attr| {
 +        if_chain! {
 +            // Identify attribute
 +            if let ast::AttrKind::Normal(ref attr_kind, _) = &attr.kind;
 +            if let [tool_name, attr_name] = &attr_kind.path.segments[..];
 +            if tool_name.ident.name == sym::clippy;
 +            if attr_name.ident.name == sym::version;
 +            if let Some(version) = attr.value_str();
 +            then {
 +                Some(version)
 +            } else {
 +                None
 +            }
 +        }
 +    })
 +}
 +
 +struct LintCollector<'a, 'tcx> {
 +    output: &'a mut FxHashSet<Symbol>,
 +    cx: &'a LateContext<'tcx>,
 +}
 +
 +impl<'a, 'tcx> Visitor<'tcx> for LintCollector<'a, 'tcx> {
 +    type NestedFilter = nested_filter::All;
 +
 +    fn visit_path(&mut self, path: &'tcx Path<'_>, _: HirId) {
 +        if path.segments.len() == 1 {
 +            self.output.insert(path.segments[0].ident.name);
 +        }
 +    }
 +
 +    fn nested_visit_map(&mut self) -> Self::Map {
 +        self.cx.tcx.hir()
 +    }
 +}
 +
 +#[derive(Clone, Default)]
 +pub struct CompilerLintFunctions {
 +    map: FxHashMap<&'static str, &'static str>,
 +}
 +
 +impl CompilerLintFunctions {
 +    #[must_use]
 +    pub fn new() -> Self {
 +        let mut map = FxHashMap::default();
 +        map.insert("span_lint", "utils::span_lint");
 +        map.insert("struct_span_lint", "utils::span_lint");
 +        map.insert("lint", "utils::span_lint");
 +        map.insert("span_lint_note", "utils::span_lint_and_note");
 +        map.insert("span_lint_help", "utils::span_lint_and_help");
 +        Self { map }
 +    }
 +}
 +
 +impl_lint_pass!(CompilerLintFunctions => [COMPILER_LINT_FUNCTIONS]);
 +
 +impl<'tcx> LateLintPass<'tcx> for CompilerLintFunctions {
 +    fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
 +        if is_lint_allowed(cx, COMPILER_LINT_FUNCTIONS, expr.hir_id) {
 +            return;
 +        }
 +
 +        if_chain! {
 +            if let ExprKind::MethodCall(path, [self_arg, ..], _) = &expr.kind;
 +            let fn_name = path.ident;
 +            if let Some(sugg) = self.map.get(&*fn_name.as_str());
 +            let ty = cx.typeck_results().expr_ty(self_arg).peel_refs();
 +            if match_type(cx, ty, &paths::EARLY_CONTEXT)
 +                || match_type(cx, ty, &paths::LATE_CONTEXT);
 +            then {
 +                span_lint_and_help(
 +                    cx,
 +                    COMPILER_LINT_FUNCTIONS,
 +                    path.ident.span,
 +                    "usage of a compiler lint function",
 +                    None,
 +                    &format!("please use the Clippy variant of this function: `{}`", sugg),
 +                );
 +            }
 +        }
 +    }
 +}
 +
 +declare_lint_pass!(OuterExpnDataPass => [OUTER_EXPN_EXPN_DATA]);
 +
 +impl<'tcx> LateLintPass<'tcx> for OuterExpnDataPass {
 +    fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>) {
 +        if is_lint_allowed(cx, OUTER_EXPN_EXPN_DATA, expr.hir_id) {
 +            return;
 +        }
 +
 +        let (method_names, arg_lists, spans) = method_calls(expr, 2);
 +        let method_names: Vec<&str> = method_names.iter().map(Symbol::as_str).collect();
 +        if_chain! {
 +            if let ["expn_data", "outer_expn"] = method_names.as_slice();
 +            let args = arg_lists[1];
 +            if args.len() == 1;
 +            let self_arg = &args[0];
 +            let self_ty = cx.typeck_results().expr_ty(self_arg).peel_refs();
 +            if match_type(cx, self_ty, &paths::SYNTAX_CONTEXT);
 +            then {
 +                span_lint_and_sugg(
 +                    cx,
 +                    OUTER_EXPN_EXPN_DATA,
 +                    spans[1].with_hi(expr.span.hi()),
 +                    "usage of `outer_expn().expn_data()`",
 +                    "try",
 +                    "outer_expn_data()".to_string(),
 +                    Applicability::MachineApplicable,
 +                );
 +            }
 +        }
 +    }
 +}
 +
 +declare_lint_pass!(ProduceIce => [PRODUCE_ICE]);
 +
 +impl EarlyLintPass for ProduceIce {
 +    fn check_fn(&mut self, _: &EarlyContext<'_>, fn_kind: FnKind<'_>, _: Span, _: NodeId) {
 +        assert!(!is_trigger_fn(fn_kind), "Would you like some help with that?");
 +    }
 +}
 +
 +fn is_trigger_fn(fn_kind: FnKind<'_>) -> bool {
 +    match fn_kind {
 +        FnKind::Fn(_, ident, ..) => ident.name.as_str() == "it_looks_like_you_are_trying_to_kill_clippy",
 +        FnKind::Closure(..) => false,
 +    }
 +}
 +
 +declare_lint_pass!(CollapsibleCalls => [COLLAPSIBLE_SPAN_LINT_CALLS]);
 +
 +impl<'tcx> LateLintPass<'tcx> for CollapsibleCalls {
 +    fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>) {
 +        if is_lint_allowed(cx, COLLAPSIBLE_SPAN_LINT_CALLS, expr.hir_id) {
 +            return;
 +        }
 +
 +        if_chain! {
 +            if let ExprKind::Call(func, and_then_args) = expr.kind;
 +            if is_expr_path_def_path(cx, func, &["clippy_utils", "diagnostics", "span_lint_and_then"]);
 +            if and_then_args.len() == 5;
 +            if let ExprKind::Closure(_, _, body_id, _, _) = &and_then_args[4].kind;
 +            let body = cx.tcx.hir().body(*body_id);
 +            let only_expr = peel_blocks_with_stmt(&body.value);
 +            if let ExprKind::MethodCall(ps, span_call_args, _) = &only_expr.kind;
 +            then {
 +                let and_then_snippets = get_and_then_snippets(cx, and_then_args);
 +                let mut sle = SpanlessEq::new(cx).deny_side_effects();
 +                match &*ps.ident.as_str() {
 +                    "span_suggestion" if sle.eq_expr(&and_then_args[2], &span_call_args[1]) => {
 +                        suggest_suggestion(cx, expr, &and_then_snippets, &span_suggestion_snippets(cx, span_call_args));
 +                    },
 +                    "span_help" if sle.eq_expr(&and_then_args[2], &span_call_args[1]) => {
 +                        let help_snippet = snippet(cx, span_call_args[2].span, r#""...""#);
 +                        suggest_help(cx, expr, &and_then_snippets, help_snippet.borrow(), true);
 +                    },
 +                    "span_note" if sle.eq_expr(&and_then_args[2], &span_call_args[1]) => {
 +                        let note_snippet = snippet(cx, span_call_args[2].span, r#""...""#);
 +                        suggest_note(cx, expr, &and_then_snippets, note_snippet.borrow(), true);
 +                    },
 +                    "help" => {
 +                        let help_snippet = snippet(cx, span_call_args[1].span, r#""...""#);
 +                        suggest_help(cx, expr, &and_then_snippets, help_snippet.borrow(), false);
 +                    }
 +                    "note" => {
 +                        let note_snippet = snippet(cx, span_call_args[1].span, r#""...""#);
 +                        suggest_note(cx, expr, &and_then_snippets, note_snippet.borrow(), false);
 +                    }
 +                    _  => (),
 +                }
 +            }
 +        }
 +    }
 +}
 +
 +struct AndThenSnippets<'a> {
 +    cx: Cow<'a, str>,
 +    lint: Cow<'a, str>,
 +    span: Cow<'a, str>,
 +    msg: Cow<'a, str>,
 +}
 +
 +fn get_and_then_snippets<'a, 'hir>(cx: &LateContext<'_>, and_then_snippets: &'hir [Expr<'hir>]) -> AndThenSnippets<'a> {
 +    let cx_snippet = snippet(cx, and_then_snippets[0].span, "cx");
 +    let lint_snippet = snippet(cx, and_then_snippets[1].span, "..");
 +    let span_snippet = snippet(cx, and_then_snippets[2].span, "span");
 +    let msg_snippet = snippet(cx, and_then_snippets[3].span, r#""...""#);
 +
 +    AndThenSnippets {
 +        cx: cx_snippet,
 +        lint: lint_snippet,
 +        span: span_snippet,
 +        msg: msg_snippet,
 +    }
 +}
 +
 +struct SpanSuggestionSnippets<'a> {
 +    help: Cow<'a, str>,
 +    sugg: Cow<'a, str>,
 +    applicability: Cow<'a, str>,
 +}
 +
 +fn span_suggestion_snippets<'a, 'hir>(
 +    cx: &LateContext<'_>,
 +    span_call_args: &'hir [Expr<'hir>],
 +) -> SpanSuggestionSnippets<'a> {
 +    let help_snippet = snippet(cx, span_call_args[2].span, r#""...""#);
 +    let sugg_snippet = snippet(cx, span_call_args[3].span, "..");
 +    let applicability_snippet = snippet(cx, span_call_args[4].span, "Applicability::MachineApplicable");
 +
 +    SpanSuggestionSnippets {
 +        help: help_snippet,
 +        sugg: sugg_snippet,
 +        applicability: applicability_snippet,
 +    }
 +}
 +
 +fn suggest_suggestion(
 +    cx: &LateContext<'_>,
 +    expr: &Expr<'_>,
 +    and_then_snippets: &AndThenSnippets<'_>,
 +    span_suggestion_snippets: &SpanSuggestionSnippets<'_>,
 +) {
 +    span_lint_and_sugg(
 +        cx,
 +        COLLAPSIBLE_SPAN_LINT_CALLS,
 +        expr.span,
 +        "this call is collapsible",
 +        "collapse into",
 +        format!(
 +            "span_lint_and_sugg({}, {}, {}, {}, {}, {}, {})",
 +            and_then_snippets.cx,
 +            and_then_snippets.lint,
 +            and_then_snippets.span,
 +            and_then_snippets.msg,
 +            span_suggestion_snippets.help,
 +            span_suggestion_snippets.sugg,
 +            span_suggestion_snippets.applicability
 +        ),
 +        Applicability::MachineApplicable,
 +    );
 +}
 +
 +fn suggest_help(
 +    cx: &LateContext<'_>,
 +    expr: &Expr<'_>,
 +    and_then_snippets: &AndThenSnippets<'_>,
 +    help: &str,
 +    with_span: bool,
 +) {
 +    let option_span = if with_span {
 +        format!("Some({})", and_then_snippets.span)
 +    } else {
 +        "None".to_string()
 +    };
 +
 +    span_lint_and_sugg(
 +        cx,
 +        COLLAPSIBLE_SPAN_LINT_CALLS,
 +        expr.span,
 +        "this call is collapsible",
 +        "collapse into",
 +        format!(
 +            "span_lint_and_help({}, {}, {}, {}, {}, {})",
 +            and_then_snippets.cx,
 +            and_then_snippets.lint,
 +            and_then_snippets.span,
 +            and_then_snippets.msg,
 +            &option_span,
 +            help
 +        ),
 +        Applicability::MachineApplicable,
 +    );
 +}
 +
 +fn suggest_note(
 +    cx: &LateContext<'_>,
 +    expr: &Expr<'_>,
 +    and_then_snippets: &AndThenSnippets<'_>,
 +    note: &str,
 +    with_span: bool,
 +) {
 +    let note_span = if with_span {
 +        format!("Some({})", and_then_snippets.span)
 +    } else {
 +        "None".to_string()
 +    };
 +
 +    span_lint_and_sugg(
 +        cx,
 +        COLLAPSIBLE_SPAN_LINT_CALLS,
 +        expr.span,
 +        "this call is collspible",
 +        "collapse into",
 +        format!(
 +            "span_lint_and_note({}, {}, {}, {}, {}, {})",
 +            and_then_snippets.cx,
 +            and_then_snippets.lint,
 +            and_then_snippets.span,
 +            and_then_snippets.msg,
 +            note_span,
 +            note
 +        ),
 +        Applicability::MachineApplicable,
 +    );
 +}
 +
 +declare_lint_pass!(MatchTypeOnDiagItem => [MATCH_TYPE_ON_DIAGNOSTIC_ITEM]);
 +
 +impl<'tcx> LateLintPass<'tcx> for MatchTypeOnDiagItem {
 +    fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>) {
 +        if is_lint_allowed(cx, MATCH_TYPE_ON_DIAGNOSTIC_ITEM, expr.hir_id) {
 +            return;
 +        }
 +
 +        if_chain! {
 +            // Check if this is a call to utils::match_type()
 +            if let ExprKind::Call(fn_path, [context, ty, ty_path]) = expr.kind;
 +            if is_expr_path_def_path(cx, fn_path, &["clippy_utils", "ty", "match_type"]);
 +            // Extract the path to the matched type
 +            if let Some(segments) = path_to_matched_type(cx, ty_path);
 +            let segments: Vec<&str> = segments.iter().map(Symbol::as_str).collect();
 +            if let Some(ty_did) = path_to_res(cx, &segments[..]).opt_def_id();
 +            // Check if the matched type is a diagnostic item
 +            if let Some(item_name) = cx.tcx.get_diagnostic_name(ty_did);
 +            then {
 +                // TODO: check paths constants from external crates.
 +                let cx_snippet = snippet(cx, context.span, "_");
 +                let ty_snippet = snippet(cx, ty.span, "_");
 +
 +                span_lint_and_sugg(
 +                    cx,
 +                    MATCH_TYPE_ON_DIAGNOSTIC_ITEM,
 +                    expr.span,
 +                    "usage of `clippy_utils::ty::match_type()` on a type diagnostic item",
 +                    "try",
 +                    format!("clippy_utils::ty::is_type_diagnostic_item({}, {}, sym::{})", cx_snippet, ty_snippet, item_name),
 +                    Applicability::MaybeIncorrect,
 +                );
 +            }
 +        }
 +    }
 +}
 +
 +fn path_to_matched_type(cx: &LateContext<'_>, expr: &hir::Expr<'_>) -> Option<Vec<Symbol>> {
 +    use rustc_hir::ItemKind;
 +
 +    match &expr.kind {
 +        ExprKind::AddrOf(.., expr) => return path_to_matched_type(cx, expr),
 +        ExprKind::Path(qpath) => match cx.qpath_res(qpath, expr.hir_id) {
 +            Res::Local(hir_id) => {
 +                let parent_id = cx.tcx.hir().get_parent_node(hir_id);
 +                if let Some(Node::Local(local)) = cx.tcx.hir().find(parent_id) {
 +                    if let Some(init) = local.init {
 +                        return path_to_matched_type(cx, init);
 +                    }
 +                }
 +            },
 +            Res::Def(DefKind::Const | DefKind::Static, def_id) => {
 +                if let Some(Node::Item(item)) = cx.tcx.hir().get_if_local(def_id) {
 +                    if let ItemKind::Const(.., body_id) | ItemKind::Static(.., body_id) = item.kind {
 +                        let body = cx.tcx.hir().body(body_id);
 +                        return path_to_matched_type(cx, &body.value);
 +                    }
 +                }
 +            },
 +            _ => {},
 +        },
 +        ExprKind::Array(exprs) => {
 +            let segments: Vec<Symbol> = exprs
 +                .iter()
 +                .filter_map(|expr| {
 +                    if let ExprKind::Lit(lit) = &expr.kind {
 +                        if let LitKind::Str(sym, _) = lit.node {
 +                            return Some(sym);
 +                        }
 +                    }
 +
 +                    None
 +                })
 +                .collect();
 +
 +            if segments.len() == exprs.len() {
 +                return Some(segments);
 +            }
 +        },
 +        _ => {},
 +    }
 +
 +    None
 +}
 +
 +// This is not a complete resolver for paths. It works on all the paths currently used in the paths
 +// module.  That's all it does and all it needs to do.
 +pub fn check_path(cx: &LateContext<'_>, path: &[&str]) -> bool {
 +    if path_to_res(cx, path) != Res::Err {
 +        return true;
 +    }
 +
 +    // Some implementations can't be found by `path_to_res`, particularly inherent
 +    // implementations of native types. Check lang items.
 +    let path_syms: Vec<_> = path.iter().map(|p| Symbol::intern(p)).collect();
 +    let lang_items = cx.tcx.lang_items();
 +    for item_def_id in lang_items.items().iter().flatten() {
 +        let lang_item_path = cx.get_def_path(*item_def_id);
 +        if path_syms.starts_with(&lang_item_path) {
 +            if let [item] = &path_syms[lang_item_path.len()..] {
 +                if matches!(
 +                    cx.tcx.def_kind(*item_def_id),
 +                    DefKind::Mod | DefKind::Enum | DefKind::Trait
 +                ) {
 +                    for child in cx.tcx.module_children(*item_def_id) {
 +                        if child.ident.name == *item {
 +                            return true;
 +                        }
 +                    }
 +                } else {
 +                    for child in cx.tcx.associated_item_def_ids(*item_def_id) {
 +                        if cx.tcx.item_name(*child) == *item {
 +                            return true;
 +                        }
 +                    }
 +                }
 +            }
 +        }
 +    }
 +
 +    false
 +}
 +
 +declare_lint_pass!(InvalidPaths => [INVALID_PATHS]);
 +
 +impl<'tcx> LateLintPass<'tcx> for InvalidPaths {
 +    fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
 +        let local_def_id = &cx.tcx.parent_module(item.hir_id());
 +        let mod_name = &cx.tcx.item_name(local_def_id.to_def_id());
 +        if_chain! {
 +            if mod_name.as_str() == "paths";
 +            if let hir::ItemKind::Const(ty, body_id) = item.kind;
 +            let ty = hir_ty_to_ty(cx.tcx, ty);
 +            if let ty::Array(el_ty, _) = &ty.kind();
 +            if let ty::Ref(_, el_ty, _) = &el_ty.kind();
 +            if el_ty.is_str();
 +            let body = cx.tcx.hir().body(body_id);
 +            let typeck_results = cx.tcx.typeck_body(body_id);
 +            if let Some(Constant::Vec(path)) = constant_simple(cx, typeck_results, &body.value);
 +            let path: Vec<&str> = path.iter().map(|x| {
 +                    if let Constant::Str(s) = x {
 +                        s.as_str()
 +                    } else {
 +                        // We checked the type of the constant above
 +                        unreachable!()
 +                    }
 +                }).collect();
 +            if !check_path(cx, &path[..]);
 +            then {
 +                span_lint(cx, INVALID_PATHS, item.span, "invalid path");
 +            }
 +        }
 +    }
 +}
 +
 +#[derive(Default)]
 +pub struct InterningDefinedSymbol {
 +    // Maps the symbol value to the constant DefId.
 +    symbol_map: FxHashMap<u32, DefId>,
 +}
 +
 +impl_lint_pass!(InterningDefinedSymbol => [INTERNING_DEFINED_SYMBOL, UNNECESSARY_SYMBOL_STR]);
 +
 +impl<'tcx> LateLintPass<'tcx> for InterningDefinedSymbol {
 +    fn check_crate(&mut self, cx: &LateContext<'_>) {
 +        if !self.symbol_map.is_empty() {
 +            return;
 +        }
 +
 +        for &module in &[&paths::KW_MODULE, &paths::SYM_MODULE] {
 +            if let Some(def_id) = path_to_res(cx, module).opt_def_id() {
 +                for item in cx.tcx.module_children(def_id).iter() {
 +                    if_chain! {
 +                        if let Res::Def(DefKind::Const, item_def_id) = item.res;
 +                        let ty = cx.tcx.type_of(item_def_id);
 +                        if match_type(cx, ty, &paths::SYMBOL);
 +                        if let Ok(ConstValue::Scalar(value)) = cx.tcx.const_eval_poly(item_def_id);
 +                        if let Ok(value) = value.to_u32();
 +                        then {
 +                            self.symbol_map.insert(value, item_def_id);
 +                        }
 +                    }
 +                }
 +            }
 +        }
 +    }
 +
 +    fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
 +        if_chain! {
 +            if let ExprKind::Call(func, [arg]) = &expr.kind;
 +            if let ty::FnDef(def_id, _) = cx.typeck_results().expr_ty(func).kind();
 +            if match_def_path(cx, *def_id, &paths::SYMBOL_INTERN);
 +            if let Some(Constant::Str(arg)) = constant_simple(cx, cx.typeck_results(), arg);
 +            let value = Symbol::intern(&arg).as_u32();
 +            if let Some(&def_id) = self.symbol_map.get(&value);
 +            then {
 +                span_lint_and_sugg(
 +                    cx,
 +                    INTERNING_DEFINED_SYMBOL,
 +                    is_expn_of(expr.span, "sym").unwrap_or(expr.span),
 +                    "interning a defined symbol",
 +                    "try",
 +                    cx.tcx.def_path_str(def_id),
 +                    Applicability::MachineApplicable,
 +                );
 +            }
 +        }
 +        if let ExprKind::Binary(op, left, right) = expr.kind {
 +            if matches!(op.node, BinOpKind::Eq | BinOpKind::Ne) {
 +                let data = [
 +                    (left, self.symbol_str_expr(left, cx)),
 +                    (right, self.symbol_str_expr(right, cx)),
 +                ];
 +                match data {
 +                    // both operands are a symbol string
 +                    [(_, Some(left)), (_, Some(right))] => {
 +                        span_lint_and_sugg(
 +                            cx,
 +                            UNNECESSARY_SYMBOL_STR,
 +                            expr.span,
 +                            "unnecessary `Symbol` to string conversion",
 +                            "try",
 +                            format!(
 +                                "{} {} {}",
 +                                left.as_symbol_snippet(cx),
 +                                op.node.as_str(),
 +                                right.as_symbol_snippet(cx),
 +                            ),
 +                            Applicability::MachineApplicable,
 +                        );
 +                    },
 +                    // one of the operands is a symbol string
 +                    [(expr, Some(symbol)), _] | [_, (expr, Some(symbol))] => {
 +                        // creating an owned string for comparison
 +                        if matches!(symbol, SymbolStrExpr::Expr { is_to_owned: true, .. }) {
 +                            span_lint_and_sugg(
 +                                cx,
 +                                UNNECESSARY_SYMBOL_STR,
 +                                expr.span,
 +                                "unnecessary string allocation",
 +                                "try",
 +                                format!("{}.as_str()", symbol.as_symbol_snippet(cx)),
 +                                Applicability::MachineApplicable,
 +                            );
 +                        }
 +                    },
 +                    // nothing found
 +                    [(_, None), (_, None)] => {},
 +                }
 +            }
 +        }
 +    }
 +}
 +
 +impl InterningDefinedSymbol {
 +    fn symbol_str_expr<'tcx>(&self, expr: &'tcx Expr<'tcx>, cx: &LateContext<'tcx>) -> Option<SymbolStrExpr<'tcx>> {
 +        static IDENT_STR_PATHS: &[&[&str]] = &[&paths::IDENT_AS_STR, &paths::TO_STRING_METHOD];
 +        static SYMBOL_STR_PATHS: &[&[&str]] = &[
 +            &paths::SYMBOL_AS_STR,
 +            &paths::SYMBOL_TO_IDENT_STRING,
 +            &paths::TO_STRING_METHOD,
 +        ];
 +        let call = if_chain! {
 +            if let ExprKind::AddrOf(_, _, e) = expr.kind;
 +            if let ExprKind::Unary(UnOp::Deref, e) = e.kind;
 +            then { e } else { expr }
 +        };
 +        if_chain! {
 +            // is a method call
 +            if let ExprKind::MethodCall(_, [item], _) = call.kind;
 +            if let Some(did) = cx.typeck_results().type_dependent_def_id(call.hir_id);
 +            let ty = cx.typeck_results().expr_ty(item);
 +            // ...on either an Ident or a Symbol
 +            if let Some(is_ident) = if match_type(cx, ty, &paths::SYMBOL) {
 +                Some(false)
 +            } else if match_type(cx, ty, &paths::IDENT) {
 +                Some(true)
 +            } else {
 +                None
 +            };
 +            // ...which converts it to a string
 +            let paths = if is_ident { IDENT_STR_PATHS } else { SYMBOL_STR_PATHS };
 +            if let Some(path) = paths.iter().find(|path| match_def_path(cx, did, path));
 +            then {
 +                let is_to_owned = path.last().unwrap().ends_with("string");
 +                return Some(SymbolStrExpr::Expr {
 +                    item,
 +                    is_ident,
 +                    is_to_owned,
 +                });
 +            }
 +        }
 +        // is a string constant
 +        if let Some(Constant::Str(s)) = constant_simple(cx, cx.typeck_results(), expr) {
 +            let value = Symbol::intern(&s).as_u32();
 +            // ...which matches a symbol constant
 +            if let Some(&def_id) = self.symbol_map.get(&value) {
 +                return Some(SymbolStrExpr::Const(def_id));
 +            }
 +        }
 +        None
 +    }
 +}
 +
 +enum SymbolStrExpr<'tcx> {
 +    /// a string constant with a corresponding symbol constant
 +    Const(DefId),
 +    /// a "symbol to string" expression like `symbol.as_str()`
 +    Expr {
 +        /// part that evaluates to `Symbol` or `Ident`
 +        item: &'tcx Expr<'tcx>,
 +        is_ident: bool,
 +        /// whether an owned `String` is created like `to_ident_string()`
 +        is_to_owned: bool,
 +    },
 +}
 +
 +impl<'tcx> SymbolStrExpr<'tcx> {
 +    /// Returns a snippet that evaluates to a `Symbol` and is const if possible
 +    fn as_symbol_snippet(&self, cx: &LateContext<'_>) -> Cow<'tcx, str> {
 +        match *self {
 +            Self::Const(def_id) => cx.tcx.def_path_str(def_id).into(),
 +            Self::Expr { item, is_ident, .. } => {
 +                let mut snip = snippet(cx, item.span.source_callsite(), "..");
 +                if is_ident {
 +                    // get `Ident.name`
 +                    snip.to_mut().push_str(".name");
 +                }
 +                snip
 +            },
 +        }
 +    }
 +}
 +
 +declare_lint_pass!(IfChainStyle => [IF_CHAIN_STYLE]);
 +
 +impl<'tcx> LateLintPass<'tcx> for IfChainStyle {
 +    fn check_block(&mut self, cx: &LateContext<'tcx>, block: &'tcx hir::Block<'_>) {
 +        let (local, after, if_chain_span) = if_chain! {
 +            if let [Stmt { kind: StmtKind::Local(local), .. }, after @ ..] = block.stmts;
 +            if let Some(if_chain_span) = is_expn_of(block.span, "if_chain");
 +            then { (local, after, if_chain_span) } else { return }
 +        };
 +        if is_first_if_chain_expr(cx, block.hir_id, if_chain_span) {
 +            span_lint(
 +                cx,
 +                IF_CHAIN_STYLE,
 +                if_chain_local_span(cx, local, if_chain_span),
 +                "`let` expression should be above the `if_chain!`",
 +            );
 +        } else if local.span.ctxt() == block.span.ctxt() && is_if_chain_then(after, block.expr, if_chain_span) {
 +            span_lint(
 +                cx,
 +                IF_CHAIN_STYLE,
 +                if_chain_local_span(cx, local, if_chain_span),
 +                "`let` expression should be inside `then { .. }`",
 +            );
 +        }
 +    }
 +
 +    fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>) {
 +        let (cond, then, els) = if let Some(higher::IfOrIfLet { cond, r#else, then }) = higher::IfOrIfLet::hir(expr) {
 +            (cond, then, r#else.is_some())
 +        } else {
 +            return;
 +        };
 +        let then_block = match then.kind {
 +            ExprKind::Block(block, _) => block,
 +            _ => return,
 +        };
 +        let if_chain_span = is_expn_of(expr.span, "if_chain");
 +        if !els {
 +            check_nested_if_chains(cx, expr, then_block, if_chain_span);
 +        }
 +        let if_chain_span = match if_chain_span {
 +            None => return,
 +            Some(span) => span,
 +        };
 +        // check for `if a && b;`
 +        if_chain! {
 +            if let ExprKind::Binary(op, _, _) = cond.kind;
 +            if op.node == BinOpKind::And;
 +            if cx.sess().source_map().is_multiline(cond.span);
 +            then {
 +                span_lint(cx, IF_CHAIN_STYLE, cond.span, "`if a && b;` should be `if a; if b;`");
 +            }
 +        }
 +        if is_first_if_chain_expr(cx, expr.hir_id, if_chain_span)
 +            && is_if_chain_then(then_block.stmts, then_block.expr, if_chain_span)
 +        {
 +            span_lint(cx, IF_CHAIN_STYLE, expr.span, "`if_chain!` only has one `if`");
 +        }
 +    }
 +}
 +
 +fn check_nested_if_chains(
 +    cx: &LateContext<'_>,
 +    if_expr: &Expr<'_>,
 +    then_block: &Block<'_>,
 +    if_chain_span: Option<Span>,
 +) {
 +    #[rustfmt::skip]
 +    let (head, tail) = match *then_block {
 +        Block { stmts, expr: Some(tail), .. } => (stmts, tail),
 +        Block {
 +            stmts: &[
 +                ref head @ ..,
 +                Stmt { kind: StmtKind::Expr(tail) | StmtKind::Semi(tail), .. }
 +            ],
 +            ..
 +        } => (head, tail),
 +        _ => return,
 +    };
 +    if_chain! {
 +        if let Some(higher::IfOrIfLet { r#else: None, .. }) = higher::IfOrIfLet::hir(tail);
 +        let sm = cx.sess().source_map();
 +        if head
 +            .iter()
 +            .all(|stmt| matches!(stmt.kind, StmtKind::Local(..)) && !sm.is_multiline(stmt.span));
 +        if if_chain_span.is_some() || !is_else_clause(cx.tcx, if_expr);
 +        then {} else { return }
 +    }
 +    let (span, msg) = match (if_chain_span, is_expn_of(tail.span, "if_chain")) {
 +        (None, Some(_)) => (if_expr.span, "this `if` can be part of the inner `if_chain!`"),
 +        (Some(_), None) => (tail.span, "this `if` can be part of the outer `if_chain!`"),
 +        (Some(a), Some(b)) if a != b => (b, "this `if_chain!` can be merged with the outer `if_chain!`"),
 +        _ => return,
 +    };
 +    span_lint_and_then(cx, IF_CHAIN_STYLE, span, msg, |diag| {
 +        let (span, msg) = match head {
 +            [] => return,
 +            [stmt] => (stmt.span, "this `let` statement can also be in the `if_chain!`"),
 +            [a, .., b] => (
 +                a.span.to(b.span),
 +                "these `let` statements can also be in the `if_chain!`",
 +            ),
 +        };
 +        diag.span_help(span, msg);
 +    });
 +}
 +
 +fn is_first_if_chain_expr(cx: &LateContext<'_>, hir_id: HirId, if_chain_span: Span) -> bool {
 +    cx.tcx
 +        .hir()
 +        .parent_iter(hir_id)
 +        .find(|(_, node)| {
 +            #[rustfmt::skip]
 +            !matches!(node, Node::Expr(Expr { kind: ExprKind::Block(..), .. }) | Node::Stmt(_))
 +        })
 +        .map_or(false, |(id, _)| {
 +            is_expn_of(cx.tcx.hir().span(id), "if_chain") != Some(if_chain_span)
 +        })
 +}
 +
 +/// Checks a trailing slice of statements and expression of a `Block` to see if they are part
 +/// of the `then {..}` portion of an `if_chain!`
 +fn is_if_chain_then(stmts: &[Stmt<'_>], expr: Option<&Expr<'_>>, if_chain_span: Span) -> bool {
 +    let span = if let [stmt, ..] = stmts {
 +        stmt.span
 +    } else if let Some(expr) = expr {
 +        expr.span
 +    } else {
 +        // empty `then {}`
 +        return true;
 +    };
 +    is_expn_of(span, "if_chain").map_or(true, |span| span != if_chain_span)
 +}
 +
 +/// Creates a `Span` for `let x = ..;` in an `if_chain!` call.
 +fn if_chain_local_span(cx: &LateContext<'_>, local: &Local<'_>, if_chain_span: Span) -> Span {
 +    let mut span = local.pat.span;
 +    if let Some(init) = local.init {
 +        span = span.to(init.span);
 +    }
 +    span.adjust(if_chain_span.ctxt().outer_expn());
 +    let sm = cx.sess().source_map();
 +    let span = sm.span_extend_to_prev_str(span, "let", false);
 +    let span = sm.span_extend_to_next_char(span, ';', false);
 +    Span::new(
 +        span.lo() - BytePos(3),
 +        span.hi() + BytePos(1),
 +        span.ctxt(),
 +        span.parent(),
 +    )
 +}
index 512c39389c1bd8fbf8d68b12bceda8563e541e31,0000000000000000000000000000000000000000..3547f0b4e0ae05266096e2a214e80fea4e3b85c4
mode 100644,000000..100644
--- /dev/null
@@@ -1,920 -1,0 +1,924 @@@
-     let result = cx
-         .lint_store
-         .check_lint_name(lint_name, Some(sym::clippy), &[]);
 +//! This lint is used to collect metadata about clippy lints. This metadata is exported as a json
 +//! file and then used to generate the [clippy lint list](https://rust-lang.github.io/rust-clippy/master/index.html)
 +//!
 +//! This module and therefore the entire lint is guarded by a feature flag called `internal`
 +//!
 +//! The module transforms all lint names to ascii lowercase to ensure that we don't have mismatches
 +//! during any comparison or mapping. (Please take care of this, it's not fun to spend time on such
 +//! a simple mistake)
 +
 +use crate::utils::internal_lints::{extract_clippy_version_value, is_lint_ref_type};
 +
 +use clippy_utils::diagnostics::span_lint;
 +use clippy_utils::ty::{match_type, walk_ptrs_ty_depth};
 +use clippy_utils::{last_path_segment, match_def_path, match_function_call, match_path, paths};
 +use if_chain::if_chain;
 +use rustc_ast as ast;
 +use rustc_data_structures::fx::FxHashMap;
 +use rustc_hir::{
 +    self as hir, def::DefKind, intravisit, intravisit::Visitor, ExprKind, Item, ItemKind, Mutability, QPath,
 +};
 +use rustc_lint::{CheckLintNameResult, LateContext, LateLintPass, LintContext, LintId};
++use rustc_middle::hir::nested_filter;
 +use rustc_session::{declare_tool_lint, impl_lint_pass};
++use rustc_span::symbol::Ident;
 +use rustc_span::{sym, Loc, Span, Symbol};
 +use serde::{ser::SerializeStruct, Serialize, Serializer};
 +use std::collections::BinaryHeap;
 +use std::fmt;
 +use std::fs::{self, OpenOptions};
 +use std::io::prelude::*;
 +use std::path::Path;
 +
 +/// This is the output file of the lint collector.
 +const OUTPUT_FILE: &str = "../util/gh-pages/lints.json";
 +/// These lints are excluded from the export.
 +const BLACK_LISTED_LINTS: [&str; 3] = ["lint_author", "deep_code_inspection", "internal_metadata_collector"];
 +/// These groups will be ignored by the lint group matcher. This is useful for collections like
 +/// `clippy::all`
 +const IGNORED_LINT_GROUPS: [&str; 1] = ["clippy::all"];
 +/// Lints within this group will be excluded from the collection. These groups
 +/// have to be defined without the `clippy::` prefix.
 +const EXCLUDED_LINT_GROUPS: [&str; 1] = ["internal"];
 +/// Collected deprecated lint will be assigned to this group in the JSON output
 +const DEPRECATED_LINT_GROUP_STR: &str = "deprecated";
 +/// This is the lint level for deprecated lints that will be displayed in the lint list
 +const DEPRECATED_LINT_LEVEL: &str = "none";
 +/// This array holds Clippy's lint groups with their corresponding default lint level. The
 +/// lint level for deprecated lints is set in `DEPRECATED_LINT_LEVEL`.
 +const DEFAULT_LINT_LEVELS: &[(&str, &str)] = &[
 +    ("correctness", "deny"),
 +    ("suspicious", "warn"),
 +    ("restriction", "allow"),
 +    ("style", "warn"),
 +    ("pedantic", "allow"),
 +    ("complexity", "warn"),
 +    ("perf", "warn"),
 +    ("cargo", "allow"),
 +    ("nursery", "allow"),
 +];
 +/// This prefix is in front of the lint groups in the lint store. The prefix will be trimmed
 +/// to only keep the actual lint group in the output.
 +const CLIPPY_LINT_GROUP_PREFIX: &str = "clippy::";
 +
 +/// This template will be used to format the configuration section in the lint documentation.
 +/// The `configurations` parameter will be replaced with one or multiple formatted
 +/// `ClippyConfiguration` instances. See `CONFIGURATION_VALUE_TEMPLATE` for further customizations
 +macro_rules! CONFIGURATION_SECTION_TEMPLATE {
 +    () => {
 +        r#"
 +### Configuration
 +This lint has the following configuration variables:
 +
 +{configurations}
 +"#
 +    };
 +}
 +/// This template will be used to format an individual `ClippyConfiguration` instance in the
 +/// lint documentation.
 +///
 +/// The format function will provide strings for the following parameters: `name`, `ty`, `doc` and
 +/// `default`
 +macro_rules! CONFIGURATION_VALUE_TEMPLATE {
 +    () => {
 +        "* `{name}`: `{ty}`: {doc} (defaults to `{default}`)\n"
 +    };
 +}
 +
 +const LINT_EMISSION_FUNCTIONS: [&[&str]; 7] = [
 +    &["clippy_utils", "diagnostics", "span_lint"],
 +    &["clippy_utils", "diagnostics", "span_lint_and_help"],
 +    &["clippy_utils", "diagnostics", "span_lint_and_note"],
 +    &["clippy_utils", "diagnostics", "span_lint_hir"],
 +    &["clippy_utils", "diagnostics", "span_lint_and_sugg"],
 +    &["clippy_utils", "diagnostics", "span_lint_and_then"],
 +    &["clippy_utils", "diagnostics", "span_lint_hir_and_then"],
 +];
 +const SUGGESTION_DIAGNOSTIC_BUILDER_METHODS: [(&str, bool); 9] = [
 +    ("span_suggestion", false),
 +    ("span_suggestion_short", false),
 +    ("span_suggestion_verbose", false),
 +    ("span_suggestion_hidden", false),
 +    ("tool_only_span_suggestion", false),
 +    ("multipart_suggestion", true),
 +    ("multipart_suggestions", true),
 +    ("tool_only_multipart_suggestion", true),
 +    ("span_suggestions", true),
 +];
 +const SUGGESTION_FUNCTIONS: [&[&str]; 2] = [
 +    &["clippy_utils", "diagnostics", "multispan_sugg"],
 +    &["clippy_utils", "diagnostics", "multispan_sugg_with_applicability"],
 +];
 +const DEPRECATED_LINT_TYPE: [&str; 3] = ["clippy_lints", "deprecated_lints", "ClippyDeprecatedLint"];
 +
 +/// The index of the applicability name of `paths::APPLICABILITY_VALUES`
 +const APPLICABILITY_NAME_INDEX: usize = 2;
 +/// This applicability will be set for unresolved applicability values.
 +const APPLICABILITY_UNRESOLVED_STR: &str = "Unresolved";
 +/// The version that will be displayed if none has been defined
 +const VERION_DEFAULT_STR: &str = "Unknown";
 +
 +declare_clippy_lint! {
 +    /// ### What it does
 +    /// Collects metadata about clippy lints for the website.
 +    ///
 +    /// This lint will be used to report problems of syntax parsing. You should hopefully never
 +    /// see this but never say never I guess ^^
 +    ///
 +    /// ### Why is this bad?
 +    /// This is not a bad thing but definitely a hacky way to do it. See
 +    /// issue [#4310](https://github.com/rust-lang/rust-clippy/issues/4310) for a discussion
 +    /// about the implementation.
 +    ///
 +    /// ### Known problems
 +    /// Hopefully none. It would be pretty uncool to have a problem here :)
 +    ///
 +    /// ### Example output
 +    /// ```json,ignore
 +    /// {
 +    ///     "id": "internal_metadata_collector",
 +    ///     "id_span": {
 +    ///         "path": "clippy_lints/src/utils/internal_lints/metadata_collector.rs",
 +    ///         "line": 1
 +    ///     },
 +    ///     "group": "clippy::internal",
 +    ///     "docs": " ### What it does\nCollects metadata about clippy lints for the website. [...] "
 +    /// }
 +    /// ```
 +    #[clippy::version = "1.56.0"]
 +    pub INTERNAL_METADATA_COLLECTOR,
 +    internal_warn,
 +    "A busy bee collection metadata about lints"
 +}
 +
 +impl_lint_pass!(MetadataCollector => [INTERNAL_METADATA_COLLECTOR]);
 +
 +#[allow(clippy::module_name_repetitions)]
 +#[derive(Debug, Clone)]
 +pub struct MetadataCollector {
 +    /// All collected lints
 +    ///
 +    /// We use a Heap here to have the lints added in alphabetic order in the export
 +    lints: BinaryHeap<LintMetadata>,
 +    applicability_info: FxHashMap<String, ApplicabilityInfo>,
 +    config: Vec<ClippyConfiguration>,
 +}
 +
 +impl MetadataCollector {
 +    pub fn new() -> Self {
 +        Self {
 +            lints: BinaryHeap::<LintMetadata>::default(),
 +            applicability_info: FxHashMap::<String, ApplicabilityInfo>::default(),
 +            config: collect_configs(),
 +        }
 +    }
 +
 +    fn get_lint_configs(&self, lint_name: &str) -> Option<String> {
 +        self.config
 +            .iter()
 +            .filter(|config| config.lints.iter().any(|lint| lint == lint_name))
 +            .map(ToString::to_string)
 +            .reduce(|acc, x| acc + &x)
 +            .map(|configurations| format!(CONFIGURATION_SECTION_TEMPLATE!(), configurations = configurations))
 +    }
 +}
 +
 +impl Drop for MetadataCollector {
 +    /// You might ask: How hacky is this?
 +    /// My answer:     YES
 +    fn drop(&mut self) {
 +        // The metadata collector gets dropped twice, this makes sure that we only write
 +        // when the list is full
 +        if self.lints.is_empty() {
 +            return;
 +        }
 +
 +        let mut applicability_info = std::mem::take(&mut self.applicability_info);
 +
 +        // Mapping the final data
 +        let mut lints = std::mem::take(&mut self.lints).into_sorted_vec();
 +        lints
 +            .iter_mut()
 +            .for_each(|x| x.applicability = Some(applicability_info.remove(&x.id).unwrap_or_default()));
 +
 +        // Outputting
 +        if Path::new(OUTPUT_FILE).exists() {
 +            fs::remove_file(OUTPUT_FILE).unwrap();
 +        }
 +        let mut file = OpenOptions::new().write(true).create(true).open(OUTPUT_FILE).unwrap();
 +        writeln!(file, "{}", serde_json::to_string_pretty(&lints).unwrap()).unwrap();
 +    }
 +}
 +
 +#[derive(Debug, Clone, Serialize, PartialEq, Eq, PartialOrd, Ord)]
 +struct LintMetadata {
 +    id: String,
 +    id_span: SerializableSpan,
 +    group: String,
 +    level: String,
 +    docs: String,
 +    version: String,
 +    /// This field is only used in the output and will only be
 +    /// mapped shortly before the actual output.
 +    applicability: Option<ApplicabilityInfo>,
 +}
 +
 +impl LintMetadata {
 +    fn new(
 +        id: String,
 +        id_span: SerializableSpan,
 +        group: String,
 +        level: &'static str,
 +        version: String,
 +        docs: String,
 +    ) -> Self {
 +        Self {
 +            id,
 +            id_span,
 +            group,
 +            level: level.to_string(),
 +            version,
 +            docs,
 +            applicability: None,
 +        }
 +    }
 +}
 +
 +#[derive(Debug, Clone, Serialize, PartialEq, Eq, PartialOrd, Ord)]
 +struct SerializableSpan {
 +    path: String,
 +    line: usize,
 +}
 +
 +impl std::fmt::Display for SerializableSpan {
 +    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
 +        write!(f, "{}:{}", self.path.rsplit('/').next().unwrap_or_default(), self.line)
 +    }
 +}
 +
 +impl SerializableSpan {
 +    fn from_item(cx: &LateContext<'_>, item: &Item<'_>) -> Self {
 +        Self::from_span(cx, item.ident.span)
 +    }
 +
 +    fn from_span(cx: &LateContext<'_>, span: Span) -> Self {
 +        let loc: Loc = cx.sess().source_map().lookup_char_pos(span.lo());
 +
 +        Self {
 +            path: format!("{}", loc.file.name.prefer_remapped()),
 +            line: loc.line,
 +        }
 +    }
 +}
 +
 +#[derive(Debug, Clone, Default, PartialEq, Eq, PartialOrd, Ord)]
 +struct ApplicabilityInfo {
 +    /// Indicates if any of the lint emissions uses multiple spans. This is related to
 +    /// [rustfix#141](https://github.com/rust-lang/rustfix/issues/141) as such suggestions can
 +    /// currently not be applied automatically.
 +    is_multi_part_suggestion: bool,
 +    applicability: Option<usize>,
 +}
 +
 +impl Serialize for ApplicabilityInfo {
 +    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
 +    where
 +        S: Serializer,
 +    {
 +        let mut s = serializer.serialize_struct("ApplicabilityInfo", 2)?;
 +        s.serialize_field("is_multi_part_suggestion", &self.is_multi_part_suggestion)?;
 +        if let Some(index) = self.applicability {
 +            s.serialize_field(
 +                "applicability",
 +                &paths::APPLICABILITY_VALUES[index][APPLICABILITY_NAME_INDEX],
 +            )?;
 +        } else {
 +            s.serialize_field("applicability", APPLICABILITY_UNRESOLVED_STR)?;
 +        }
 +        s.end()
 +    }
 +}
 +
 +// ==================================================================
 +// Configuration
 +// ==================================================================
 +#[derive(Debug, Clone, Default)]
 +pub struct ClippyConfiguration {
 +    name: String,
 +    config_type: &'static str,
 +    default: String,
 +    lints: Vec<String>,
 +    doc: String,
 +    #[allow(dead_code)]
 +    deprecation_reason: Option<&'static str>,
 +}
 +
 +impl ClippyConfiguration {
 +    pub fn new(
 +        name: &'static str,
 +        config_type: &'static str,
 +        default: String,
 +        doc_comment: &'static str,
 +        deprecation_reason: Option<&'static str>,
 +    ) -> Self {
 +        let (lints, doc) = parse_config_field_doc(doc_comment)
 +            .unwrap_or_else(|| (vec![], "[ERROR] MALFORMED DOC COMMENT".to_string()));
 +
 +        Self {
 +            name: to_kebab(name),
 +            lints,
 +            doc,
 +            config_type,
 +            default,
 +            deprecation_reason,
 +        }
 +    }
 +}
 +
 +fn collect_configs() -> Vec<ClippyConfiguration> {
 +    crate::utils::conf::metadata::get_configuration_metadata()
 +}
 +
 +/// This parses the field documentation of the config struct.
 +///
 +/// ```rust, ignore
 +/// parse_config_field_doc(cx, "Lint: LINT_NAME_1, LINT_NAME_2. Papa penguin, papa penguin")
 +/// ```
 +///
 +/// Would yield:
 +/// ```rust, ignore
 +/// Some(["lint_name_1", "lint_name_2"], "Papa penguin, papa penguin")
 +/// ```
 +fn parse_config_field_doc(doc_comment: &str) -> Option<(Vec<String>, String)> {
 +    const DOC_START: &str = " Lint: ";
 +    if_chain! {
 +        if doc_comment.starts_with(DOC_START);
 +        if let Some(split_pos) = doc_comment.find('.');
 +        then {
 +            let mut doc_comment = doc_comment.to_string();
 +            let mut documentation = doc_comment.split_off(split_pos);
 +
 +            // Extract lints
 +            doc_comment.make_ascii_lowercase();
 +            let lints: Vec<String> = doc_comment.split_off(DOC_START.len()).split(", ").map(str::to_string).collect();
 +
 +            // Format documentation correctly
 +            // split off leading `.` from lint name list and indent for correct formatting
 +            documentation = documentation.trim_start_matches('.').trim().replace("\n ", "\n    ");
 +
 +            Some((lints, documentation))
 +        } else {
 +            None
 +        }
 +    }
 +}
 +
 +/// Transforms a given `snake_case_string` to a tasty `kebab-case-string`
 +fn to_kebab(config_name: &str) -> String {
 +    config_name.replace('_', "-")
 +}
 +
 +impl fmt::Display for ClippyConfiguration {
 +    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> fmt::Result {
 +        write!(
 +            f,
 +            CONFIGURATION_VALUE_TEMPLATE!(),
 +            name = self.name,
 +            ty = self.config_type,
 +            doc = self.doc,
 +            default = self.default
 +        )
 +    }
 +}
 +
 +// ==================================================================
 +// Lint pass
 +// ==================================================================
 +impl<'hir> LateLintPass<'hir> for MetadataCollector {
 +    /// Collecting lint declarations like:
 +    /// ```rust, ignore
 +    /// declare_clippy_lint! {
 +    ///     /// ### What it does
 +    ///     /// Something IDK.
 +    ///     pub SOME_LINT,
 +    ///     internal,
 +    ///     "Who am I?"
 +    /// }
 +    /// ```
 +    fn check_item(&mut self, cx: &LateContext<'hir>, item: &'hir Item<'_>) {
 +        if let ItemKind::Static(ty, Mutability::Not, _) = item.kind {
 +            // Normal lint
 +            if_chain! {
 +                // item validation
 +                if is_lint_ref_type(cx, ty);
 +                // blacklist check
 +                let lint_name = sym_to_string(item.ident.name).to_ascii_lowercase();
 +                if !BLACK_LISTED_LINTS.contains(&lint_name.as_str());
 +                // metadata extraction
 +                if let Some((group, level)) = get_lint_group_and_level_or_lint(cx, &lint_name, item);
 +                if let Some(mut docs) = extract_attr_docs_or_lint(cx, item);
 +                then {
 +                    if let Some(configuration_section) = self.get_lint_configs(&lint_name) {
 +                        docs.push_str(&configuration_section);
 +                    }
 +                    let version = get_lint_version(cx, item);
 +
 +                    self.lints.push(LintMetadata::new(
 +                        lint_name,
 +                        SerializableSpan::from_item(cx, item),
 +                        group,
 +                        level,
 +                        version,
 +                        docs,
 +                    ));
 +                }
 +            }
 +
 +            if_chain! {
 +                if is_deprecated_lint(cx, ty);
 +                // blacklist check
 +                let lint_name = sym_to_string(item.ident.name).to_ascii_lowercase();
 +                if !BLACK_LISTED_LINTS.contains(&lint_name.as_str());
 +                // Metadata the little we can get from a deprecated lint
 +                if let Some(docs) = extract_attr_docs_or_lint(cx, item);
 +                then {
 +                    let version = get_lint_version(cx, item);
 +
 +                    self.lints.push(LintMetadata::new(
 +                        lint_name,
 +                        SerializableSpan::from_item(cx, item),
 +                        DEPRECATED_LINT_GROUP_STR.to_string(),
 +                        DEPRECATED_LINT_LEVEL,
 +                        version,
 +                        docs,
 +                    ));
 +                }
 +            }
 +        }
 +    }
 +
 +    /// Collecting constant applicability from the actual lint emissions
 +    ///
 +    /// Example:
 +    /// ```rust, ignore
 +    /// span_lint_and_sugg(
 +    ///     cx,
 +    ///     SOME_LINT,
 +    ///     item.span,
 +    ///     "Le lint message",
 +    ///     "Here comes help:",
 +    ///     "#![allow(clippy::all)]",
 +    ///     Applicability::MachineApplicable, // <-- Extracts this constant value
 +    /// );
 +    /// ```
 +    fn check_expr(&mut self, cx: &LateContext<'hir>, expr: &'hir hir::Expr<'_>) {
 +        if let Some(args) = match_lint_emission(cx, expr) {
 +            let mut emission_info = extract_emission_info(cx, args);
 +            if emission_info.is_empty() {
 +                // See:
 +                // - src/misc.rs:734:9
 +                // - src/methods/mod.rs:3545:13
 +                // - src/methods/mod.rs:3496:13
 +                // We are basically unable to resolve the lint name itself.
 +                return;
 +            }
 +
 +            for (lint_name, applicability, is_multi_part) in emission_info.drain(..) {
 +                let app_info = self.applicability_info.entry(lint_name).or_default();
 +                app_info.applicability = applicability;
 +                app_info.is_multi_part_suggestion = is_multi_part;
 +            }
 +        }
 +    }
 +}
 +
 +// ==================================================================
 +// Lint definition extraction
 +// ==================================================================
 +fn sym_to_string(sym: Symbol) -> String {
 +    sym.as_str().to_string()
 +}
 +
 +fn extract_attr_docs_or_lint(cx: &LateContext<'_>, item: &Item<'_>) -> Option<String> {
 +    extract_attr_docs(cx, item).or_else(|| {
 +        lint_collection_error_item(cx, item, "could not collect the lint documentation");
 +        None
 +    })
 +}
 +
 +/// This function collects all documentation that has been added to an item using
 +/// `#[doc = r""]` attributes. Several attributes are aggravated using line breaks
 +///
 +/// ```ignore
 +/// #[doc = r"Hello world!"]
 +/// #[doc = r"=^.^="]
 +/// struct SomeItem {}
 +/// ```
 +///
 +/// Would result in `Hello world!\n=^.^=\n`
 +///
 +/// ---
 +///
 +/// This function may modify the doc comment to ensure that the string can be displayed using a
 +/// markdown viewer in Clippy's lint list. The following modifications could be applied:
 +/// * Removal of leading space after a new line. (Important to display tables)
 +/// * Ensures that code blocks only contain language information
 +fn extract_attr_docs(cx: &LateContext<'_>, item: &Item<'_>) -> Option<String> {
 +    let attrs = cx.tcx.hir().attrs(item.hir_id());
 +    let mut lines = attrs.iter().filter_map(ast::Attribute::doc_str);
 +    let mut docs = String::from(&*lines.next()?.as_str());
 +    let mut in_code_block = false;
 +    let mut is_code_block_rust = false;
 +    for line in lines {
 +        let line = line.as_str();
 +        let line = &*line;
 +
 +        // Rustdoc hides code lines starting with `# ` and this removes them from Clippy's lint list :)
 +        if is_code_block_rust && line.trim_start().starts_with("# ") {
 +            continue;
 +        }
 +
 +        // The line should be represented in the lint list, even if it's just an empty line
 +        docs.push('\n');
 +        if let Some(info) = line.trim_start().strip_prefix("```") {
 +            in_code_block = !in_code_block;
 +            is_code_block_rust = false;
 +            if in_code_block {
 +                let lang = info
 +                    .trim()
 +                    .split(',')
 +                    // remove rustdoc directives
 +                    .find(|&s| !matches!(s, "" | "ignore" | "no_run" | "should_panic"))
 +                    // if no language is present, fill in "rust"
 +                    .unwrap_or("rust");
 +                docs.push_str("```");
 +                docs.push_str(lang);
 +
 +                is_code_block_rust = lang == "rust";
 +                continue;
 +            }
 +        }
 +        // This removes the leading space that the macro translation introduces
 +        if let Some(stripped_doc) = line.strip_prefix(' ') {
 +            docs.push_str(stripped_doc);
 +        } else if !line.is_empty() {
 +            docs.push_str(line);
 +        }
 +    }
 +    Some(docs)
 +}
 +
 +fn get_lint_version(cx: &LateContext<'_>, item: &Item<'_>) -> String {
 +    extract_clippy_version_value(cx, item).map_or_else(
 +        || VERION_DEFAULT_STR.to_string(),
 +        |version| version.as_str().to_string(),
 +    )
 +}
 +
 +fn get_lint_group_and_level_or_lint(
 +    cx: &LateContext<'_>,
 +    lint_name: &str,
 +    item: &Item<'_>,
 +) -> Option<(String, &'static str)> {
++    let result = cx.lint_store.check_lint_name(
++        lint_name,
++        Some(sym::clippy),
++        &[Ident::with_dummy_span(sym::clippy)].into_iter().collect(),
++    );
 +    if let CheckLintNameResult::Tool(Ok(lint_lst)) = result {
 +        if let Some(group) = get_lint_group(cx, lint_lst[0]) {
 +            if EXCLUDED_LINT_GROUPS.contains(&group.as_str()) {
 +                return None;
 +            }
 +
 +            if let Some(level) = get_lint_level_from_group(&group) {
 +                Some((group, level))
 +            } else {
 +                lint_collection_error_item(
 +                    cx,
 +                    item,
 +                    &format!("Unable to determine lint level for found group `{}`", group),
 +                );
 +                None
 +            }
 +        } else {
 +            lint_collection_error_item(cx, item, "Unable to determine lint group");
 +            None
 +        }
 +    } else {
 +        lint_collection_error_item(cx, item, "Unable to find lint in lint_store");
 +        None
 +    }
 +}
 +
 +fn get_lint_group(cx: &LateContext<'_>, lint_id: LintId) -> Option<String> {
 +    for (group_name, lints, _) in &cx.lint_store.get_lint_groups() {
 +        if IGNORED_LINT_GROUPS.contains(group_name) {
 +            continue;
 +        }
 +
 +        if lints.iter().any(|group_lint| *group_lint == lint_id) {
 +            let group = group_name.strip_prefix(CLIPPY_LINT_GROUP_PREFIX).unwrap_or(group_name);
 +            return Some((*group).to_string());
 +        }
 +    }
 +
 +    None
 +}
 +
 +fn get_lint_level_from_group(lint_group: &str) -> Option<&'static str> {
 +    DEFAULT_LINT_LEVELS
 +        .iter()
 +        .find_map(|(group_name, group_level)| (*group_name == lint_group).then(|| *group_level))
 +}
 +
 +fn is_deprecated_lint(cx: &LateContext<'_>, ty: &hir::Ty<'_>) -> bool {
 +    if let hir::TyKind::Path(ref path) = ty.kind {
 +        if let hir::def::Res::Def(DefKind::Struct, def_id) = cx.qpath_res(path, ty.hir_id) {
 +            return match_def_path(cx, def_id, &DEPRECATED_LINT_TYPE);
 +        }
 +    }
 +
 +    false
 +}
 +
 +// ==================================================================
 +// Lint emission
 +// ==================================================================
 +fn lint_collection_error_item(cx: &LateContext<'_>, item: &Item<'_>, message: &str) {
 +    span_lint(
 +        cx,
 +        INTERNAL_METADATA_COLLECTOR,
 +        item.ident.span,
 +        &format!("metadata collection error for `{}`: {}", item.ident.name, message),
 +    );
 +}
 +
 +// ==================================================================
 +// Applicability
 +// ==================================================================
 +/// This function checks if a given expression is equal to a simple lint emission function call.
 +/// It will return the function arguments if the emission matched any function.
 +fn match_lint_emission<'hir>(cx: &LateContext<'hir>, expr: &'hir hir::Expr<'_>) -> Option<&'hir [hir::Expr<'hir>]> {
 +    LINT_EMISSION_FUNCTIONS
 +        .iter()
 +        .find_map(|emission_fn| match_function_call(cx, expr, emission_fn))
 +}
 +
 +fn take_higher_applicability(a: Option<usize>, b: Option<usize>) -> Option<usize> {
 +    a.map_or(b, |a| a.max(b.unwrap_or_default()).into())
 +}
 +
 +fn extract_emission_info<'hir>(
 +    cx: &LateContext<'hir>,
 +    args: &'hir [hir::Expr<'hir>],
 +) -> Vec<(String, Option<usize>, bool)> {
 +    let mut lints = Vec::new();
 +    let mut applicability = None;
 +    let mut multi_part = false;
 +
 +    for arg in args {
 +        let (arg_ty, _) = walk_ptrs_ty_depth(cx.typeck_results().expr_ty(arg));
 +
 +        if match_type(cx, arg_ty, &paths::LINT) {
 +            // If we found the lint arg, extract the lint name
 +            let mut resolved_lints = resolve_lints(cx, arg);
 +            lints.append(&mut resolved_lints);
 +        } else if match_type(cx, arg_ty, &paths::APPLICABILITY) {
 +            applicability = resolve_applicability(cx, arg);
 +        } else if arg_ty.is_closure() {
 +            multi_part |= check_is_multi_part(cx, arg);
 +            applicability = applicability.or_else(|| resolve_applicability(cx, arg));
 +        }
 +    }
 +
 +    lints
 +        .drain(..)
 +        .map(|lint_name| (lint_name, applicability, multi_part))
 +        .collect()
 +}
 +
 +/// Resolves the possible lints that this expression could reference
 +fn resolve_lints<'hir>(cx: &LateContext<'hir>, expr: &'hir hir::Expr<'hir>) -> Vec<String> {
 +    let mut resolver = LintResolver::new(cx);
 +    resolver.visit_expr(expr);
 +    resolver.lints
 +}
 +
 +/// This function tries to resolve the linked applicability to the given expression.
 +fn resolve_applicability<'hir>(cx: &LateContext<'hir>, expr: &'hir hir::Expr<'hir>) -> Option<usize> {
 +    let mut resolver = ApplicabilityResolver::new(cx);
 +    resolver.visit_expr(expr);
 +    resolver.complete()
 +}
 +
 +fn check_is_multi_part<'hir>(cx: &LateContext<'hir>, closure_expr: &'hir hir::Expr<'hir>) -> bool {
 +    if let ExprKind::Closure(_, _, body_id, _, _) = closure_expr.kind {
 +        let mut scanner = IsMultiSpanScanner::new(cx);
 +        intravisit::walk_body(&mut scanner, cx.tcx.hir().body(body_id));
 +        return scanner.is_multi_part();
 +    } else if let Some(local) = get_parent_local(cx, closure_expr) {
 +        if let Some(local_init) = local.init {
 +            return check_is_multi_part(cx, local_init);
 +        }
 +    }
 +
 +    false
 +}
 +
 +struct LintResolver<'a, 'hir> {
 +    cx: &'a LateContext<'hir>,
 +    lints: Vec<String>,
 +}
 +
 +impl<'a, 'hir> LintResolver<'a, 'hir> {
 +    fn new(cx: &'a LateContext<'hir>) -> Self {
 +        Self {
 +            cx,
 +            lints: Vec::<String>::default(),
 +        }
 +    }
 +}
 +
 +impl<'a, 'hir> intravisit::Visitor<'hir> for LintResolver<'a, 'hir> {
 +    type NestedFilter = nested_filter::All;
 +
 +    fn nested_visit_map(&mut self) -> Self::Map {
 +        self.cx.tcx.hir()
 +    }
 +
 +    fn visit_expr(&mut self, expr: &'hir hir::Expr<'hir>) {
 +        if_chain! {
 +            if let ExprKind::Path(qpath) = &expr.kind;
 +            if let QPath::Resolved(_, path) = qpath;
 +
 +            let (expr_ty, _) = walk_ptrs_ty_depth(self.cx.typeck_results().expr_ty(expr));
 +            if match_type(self.cx, expr_ty, &paths::LINT);
 +            then {
 +                if let hir::def::Res::Def(DefKind::Static, _) = path.res {
 +                    let lint_name = last_path_segment(qpath).ident.name;
 +                    self.lints.push(sym_to_string(lint_name).to_ascii_lowercase());
 +                } else if let Some(local) = get_parent_local(self.cx, expr) {
 +                    if let Some(local_init) = local.init {
 +                        intravisit::walk_expr(self, local_init);
 +                    }
 +                }
 +            }
 +        }
 +
 +        intravisit::walk_expr(self, expr);
 +    }
 +}
 +
 +/// This visitor finds the highest applicability value in the visited expressions
 +struct ApplicabilityResolver<'a, 'hir> {
 +    cx: &'a LateContext<'hir>,
 +    /// This is the index of hightest `Applicability` for `paths::APPLICABILITY_VALUES`
 +    applicability_index: Option<usize>,
 +}
 +
 +impl<'a, 'hir> ApplicabilityResolver<'a, 'hir> {
 +    fn new(cx: &'a LateContext<'hir>) -> Self {
 +        Self {
 +            cx,
 +            applicability_index: None,
 +        }
 +    }
 +
 +    fn add_new_index(&mut self, new_index: usize) {
 +        self.applicability_index = take_higher_applicability(self.applicability_index, Some(new_index));
 +    }
 +
 +    fn complete(self) -> Option<usize> {
 +        self.applicability_index
 +    }
 +}
 +
 +impl<'a, 'hir> intravisit::Visitor<'hir> for ApplicabilityResolver<'a, 'hir> {
 +    type NestedFilter = nested_filter::All;
 +
 +    fn nested_visit_map(&mut self) -> Self::Map {
 +        self.cx.tcx.hir()
 +    }
 +
 +    fn visit_path(&mut self, path: &'hir hir::Path<'hir>, _id: hir::HirId) {
 +        for (index, enum_value) in paths::APPLICABILITY_VALUES.iter().enumerate() {
 +            if match_path(path, enum_value) {
 +                self.add_new_index(index);
 +                return;
 +            }
 +        }
 +    }
 +
 +    fn visit_expr(&mut self, expr: &'hir hir::Expr<'hir>) {
 +        let (expr_ty, _) = walk_ptrs_ty_depth(self.cx.typeck_results().expr_ty(expr));
 +
 +        if_chain! {
 +            if match_type(self.cx, expr_ty, &paths::APPLICABILITY);
 +            if let Some(local) = get_parent_local(self.cx, expr);
 +            if let Some(local_init) = local.init;
 +            then {
 +                intravisit::walk_expr(self, local_init);
 +            }
 +        };
 +
 +        intravisit::walk_expr(self, expr);
 +    }
 +}
 +
 +/// This returns the parent local node if the expression is a reference one
 +fn get_parent_local<'hir>(cx: &LateContext<'hir>, expr: &'hir hir::Expr<'hir>) -> Option<&'hir hir::Local<'hir>> {
 +    if let ExprKind::Path(QPath::Resolved(_, path)) = expr.kind {
 +        if let hir::def::Res::Local(local_hir) = path.res {
 +            return get_parent_local_hir_id(cx, local_hir);
 +        }
 +    }
 +
 +    None
 +}
 +
 +fn get_parent_local_hir_id<'hir>(cx: &LateContext<'hir>, hir_id: hir::HirId) -> Option<&'hir hir::Local<'hir>> {
 +    let map = cx.tcx.hir();
 +
 +    match map.find(map.get_parent_node(hir_id)) {
 +        Some(hir::Node::Local(local)) => Some(local),
 +        Some(hir::Node::Pat(pattern)) => get_parent_local_hir_id(cx, pattern.hir_id),
 +        _ => None,
 +    }
 +}
 +
 +/// This visitor finds the highest applicability value in the visited expressions
 +struct IsMultiSpanScanner<'a, 'hir> {
 +    cx: &'a LateContext<'hir>,
 +    suggestion_count: usize,
 +}
 +
 +impl<'a, 'hir> IsMultiSpanScanner<'a, 'hir> {
 +    fn new(cx: &'a LateContext<'hir>) -> Self {
 +        Self {
 +            cx,
 +            suggestion_count: 0,
 +        }
 +    }
 +
 +    /// Add a new single expression suggestion to the counter
 +    fn add_single_span_suggestion(&mut self) {
 +        self.suggestion_count += 1;
 +    }
 +
 +    /// Signals that a suggestion with possible multiple spans was found
 +    fn add_multi_part_suggestion(&mut self) {
 +        self.suggestion_count += 2;
 +    }
 +
 +    /// Checks if the suggestions include multiple spanns
 +    fn is_multi_part(&self) -> bool {
 +        self.suggestion_count > 1
 +    }
 +}
 +
 +impl<'a, 'hir> intravisit::Visitor<'hir> for IsMultiSpanScanner<'a, 'hir> {
 +    type NestedFilter = nested_filter::All;
 +
 +    fn nested_visit_map(&mut self) -> Self::Map {
 +        self.cx.tcx.hir()
 +    }
 +
 +    fn visit_expr(&mut self, expr: &'hir hir::Expr<'hir>) {
 +        // Early return if the lint is already multi span
 +        if self.is_multi_part() {
 +            return;
 +        }
 +
 +        match &expr.kind {
 +            ExprKind::Call(fn_expr, _args) => {
 +                let found_function = SUGGESTION_FUNCTIONS
 +                    .iter()
 +                    .any(|func_path| match_function_call(self.cx, fn_expr, func_path).is_some());
 +                if found_function {
 +                    // These functions are all multi part suggestions
 +                    self.add_single_span_suggestion();
 +                }
 +            },
 +            ExprKind::MethodCall(path, arg, _arg_span) => {
 +                let (self_ty, _) = walk_ptrs_ty_depth(self.cx.typeck_results().expr_ty(&arg[0]));
 +                if match_type(self.cx, self_ty, &paths::DIAGNOSTIC_BUILDER) {
 +                    let called_method = path.ident.name.as_str().to_string();
 +                    for (method_name, is_multi_part) in &SUGGESTION_DIAGNOSTIC_BUILDER_METHODS {
 +                        if *method_name == called_method {
 +                            if *is_multi_part {
 +                                self.add_multi_part_suggestion();
 +                            } else {
 +                                self.add_single_span_suggestion();
 +                            }
 +                            break;
 +                        }
 +                    }
 +                }
 +            },
 +            _ => {},
 +        }
 +
 +        intravisit::walk_expr(self, expr);
 +    }
 +}
index 604c95d2bc81f17c4a3fe86ea71337bf8fb158e1,0000000000000000000000000000000000000000..3f4043ad052a034279ec979ea0e67590dde0a19d
mode 100644,000000..100644
--- /dev/null
@@@ -1,688 -1,0 +1,688 @@@
-   match (l, r) {
-     (Term::Ty(l), Term::Ty(r)) => eq_ty(l,r),
-     (Term::Const(l), Term::Const(r)) => eq_anon_const(l,r),
-     _ => false,
-   }
 +//! Utilities for manipulating and extracting information from `rustc_ast::ast`.
 +//!
 +//! - The `eq_foobar` functions test for semantic equality but ignores `NodeId`s and `Span`s.
 +
 +#![allow(clippy::similar_names, clippy::wildcard_imports, clippy::enum_glob_use)]
 +
 +use crate::{both, over};
 +use rustc_ast::ptr::P;
 +use rustc_ast::{self as ast, *};
 +use rustc_span::symbol::Ident;
 +use std::mem;
 +
 +pub mod ident_iter;
 +pub use ident_iter::IdentIter;
 +
 +pub fn is_useless_with_eq_exprs(kind: BinOpKind) -> bool {
 +    use BinOpKind::*;
 +    matches!(
 +        kind,
 +        Sub | Div | Eq | Lt | Le | Gt | Ge | Ne | And | Or | BitXor | BitAnd | BitOr
 +    )
 +}
 +
 +/// Checks if each element in the first slice is contained within the latter as per `eq_fn`.
 +pub fn unordered_over<X>(left: &[X], right: &[X], mut eq_fn: impl FnMut(&X, &X) -> bool) -> bool {
 +    left.len() == right.len() && left.iter().all(|l| right.iter().any(|r| eq_fn(l, r)))
 +}
 +
 +pub fn eq_id(l: Ident, r: Ident) -> bool {
 +    l.name == r.name
 +}
 +
 +pub fn eq_pat(l: &Pat, r: &Pat) -> bool {
 +    use PatKind::*;
 +    match (&l.kind, &r.kind) {
 +        (Paren(l), _) => eq_pat(l, r),
 +        (_, Paren(r)) => eq_pat(l, r),
 +        (Wild, Wild) | (Rest, Rest) => true,
 +        (Lit(l), Lit(r)) => eq_expr(l, r),
 +        (Ident(b1, i1, s1), Ident(b2, i2, s2)) => b1 == b2 && eq_id(*i1, *i2) && both(s1, s2, |l, r| eq_pat(l, r)),
 +        (Range(lf, lt, le), Range(rf, rt, re)) => {
 +            eq_expr_opt(lf, rf) && eq_expr_opt(lt, rt) && eq_range_end(&le.node, &re.node)
 +        },
 +        (Box(l), Box(r))
 +        | (Ref(l, Mutability::Not), Ref(r, Mutability::Not))
 +        | (Ref(l, Mutability::Mut), Ref(r, Mutability::Mut)) => eq_pat(l, r),
 +        (Tuple(l), Tuple(r)) | (Slice(l), Slice(r)) => over(l, r, |l, r| eq_pat(l, r)),
 +        (Path(lq, lp), Path(rq, rp)) => both(lq, rq, eq_qself) && eq_path(lp, rp),
 +        (TupleStruct(lqself, lp, lfs), TupleStruct(rqself, rp, rfs)) => {
 +            eq_maybe_qself(lqself, rqself) && eq_path(lp, rp) && over(lfs, rfs, |l, r| eq_pat(l, r))
 +        },
 +        (Struct(lqself, lp, lfs, lr), Struct(rqself, rp, rfs, rr)) => {
 +            lr == rr && eq_maybe_qself(lqself, rqself) && eq_path(lp, rp) && unordered_over(lfs, rfs, eq_field_pat)
 +        },
 +        (Or(ls), Or(rs)) => unordered_over(ls, rs, |l, r| eq_pat(l, r)),
 +        (MacCall(l), MacCall(r)) => eq_mac_call(l, r),
 +        _ => false,
 +    }
 +}
 +
 +pub fn eq_range_end(l: &RangeEnd, r: &RangeEnd) -> bool {
 +    match (l, r) {
 +        (RangeEnd::Excluded, RangeEnd::Excluded) => true,
 +        (RangeEnd::Included(l), RangeEnd::Included(r)) => {
 +            matches!(l, RangeSyntax::DotDotEq) == matches!(r, RangeSyntax::DotDotEq)
 +        },
 +        _ => false,
 +    }
 +}
 +
 +pub fn eq_field_pat(l: &PatField, r: &PatField) -> bool {
 +    l.is_placeholder == r.is_placeholder
 +        && eq_id(l.ident, r.ident)
 +        && eq_pat(&l.pat, &r.pat)
 +        && over(&l.attrs, &r.attrs, eq_attr)
 +}
 +
 +pub fn eq_qself(l: &QSelf, r: &QSelf) -> bool {
 +    l.position == r.position && eq_ty(&l.ty, &r.ty)
 +}
 +
 +pub fn eq_maybe_qself(l: &Option<QSelf>, r: &Option<QSelf>) -> bool {
 +    match (l, r) {
 +        (Some(l), Some(r)) => eq_qself(l, r),
 +        (None, None) => true,
 +        _ => false,
 +    }
 +}
 +
 +pub fn eq_path(l: &Path, r: &Path) -> bool {
 +    over(&l.segments, &r.segments, eq_path_seg)
 +}
 +
 +pub fn eq_path_seg(l: &PathSegment, r: &PathSegment) -> bool {
 +    eq_id(l.ident, r.ident) && both(&l.args, &r.args, |l, r| eq_generic_args(l, r))
 +}
 +
 +pub fn eq_generic_args(l: &GenericArgs, r: &GenericArgs) -> bool {
 +    match (l, r) {
 +        (GenericArgs::AngleBracketed(l), GenericArgs::AngleBracketed(r)) => over(&l.args, &r.args, eq_angle_arg),
 +        (GenericArgs::Parenthesized(l), GenericArgs::Parenthesized(r)) => {
 +            over(&l.inputs, &r.inputs, |l, r| eq_ty(l, r)) && eq_fn_ret_ty(&l.output, &r.output)
 +        },
 +        _ => false,
 +    }
 +}
 +
 +pub fn eq_angle_arg(l: &AngleBracketedArg, r: &AngleBracketedArg) -> bool {
 +    match (l, r) {
 +        (AngleBracketedArg::Arg(l), AngleBracketedArg::Arg(r)) => eq_generic_arg(l, r),
 +        (AngleBracketedArg::Constraint(l), AngleBracketedArg::Constraint(r)) => eq_assoc_constraint(l, r),
 +        _ => false,
 +    }
 +}
 +
 +pub fn eq_generic_arg(l: &GenericArg, r: &GenericArg) -> bool {
 +    match (l, r) {
 +        (GenericArg::Lifetime(l), GenericArg::Lifetime(r)) => eq_id(l.ident, r.ident),
 +        (GenericArg::Type(l), GenericArg::Type(r)) => eq_ty(l, r),
 +        (GenericArg::Const(l), GenericArg::Const(r)) => eq_expr(&l.value, &r.value),
 +        _ => false,
 +    }
 +}
 +
 +pub fn eq_expr_opt(l: &Option<P<Expr>>, r: &Option<P<Expr>>) -> bool {
 +    both(l, r, |l, r| eq_expr(l, r))
 +}
 +
 +pub fn eq_struct_rest(l: &StructRest, r: &StructRest) -> bool {
 +    match (l, r) {
 +        (StructRest::Base(lb), StructRest::Base(rb)) => eq_expr(lb, rb),
 +        (StructRest::Rest(_), StructRest::Rest(_)) | (StructRest::None, StructRest::None) => true,
 +        _ => false,
 +    }
 +}
 +
 +pub fn eq_expr(l: &Expr, r: &Expr) -> bool {
 +    use ExprKind::*;
 +    if !over(&l.attrs, &r.attrs, eq_attr) {
 +        return false;
 +    }
 +    match (&l.kind, &r.kind) {
 +        (Paren(l), _) => eq_expr(l, r),
 +        (_, Paren(r)) => eq_expr(l, r),
 +        (Err, Err) => true,
 +        (Box(l), Box(r)) | (Try(l), Try(r)) | (Await(l), Await(r)) => eq_expr(l, r),
 +        (Array(l), Array(r)) | (Tup(l), Tup(r)) => over(l, r, |l, r| eq_expr(l, r)),
 +        (Repeat(le, ls), Repeat(re, rs)) => eq_expr(le, re) && eq_expr(&ls.value, &rs.value),
 +        (Call(lc, la), Call(rc, ra)) => eq_expr(lc, rc) && over(la, ra, |l, r| eq_expr(l, r)),
 +        (MethodCall(lc, la, _), MethodCall(rc, ra, _)) => eq_path_seg(lc, rc) && over(la, ra, |l, r| eq_expr(l, r)),
 +        (Binary(lo, ll, lr), Binary(ro, rl, rr)) => lo.node == ro.node && eq_expr(ll, rl) && eq_expr(lr, rr),
 +        (Unary(lo, l), Unary(ro, r)) => mem::discriminant(lo) == mem::discriminant(ro) && eq_expr(l, r),
 +        (Lit(l), Lit(r)) => l.kind == r.kind,
 +        (Cast(l, lt), Cast(r, rt)) | (Type(l, lt), Type(r, rt)) => eq_expr(l, r) && eq_ty(lt, rt),
 +        (Let(lp, le, _), Let(rp, re, _)) => eq_pat(lp, rp) && eq_expr(le, re),
 +        (If(lc, lt, le), If(rc, rt, re)) => eq_expr(lc, rc) && eq_block(lt, rt) && eq_expr_opt(le, re),
 +        (While(lc, lt, ll), While(rc, rt, rl)) => eq_label(ll, rl) && eq_expr(lc, rc) && eq_block(lt, rt),
 +        (ForLoop(lp, li, lt, ll), ForLoop(rp, ri, rt, rl)) => {
 +            eq_label(ll, rl) && eq_pat(lp, rp) && eq_expr(li, ri) && eq_block(lt, rt)
 +        },
 +        (Loop(lt, ll), Loop(rt, rl)) => eq_label(ll, rl) && eq_block(lt, rt),
 +        (Block(lb, ll), Block(rb, rl)) => eq_label(ll, rl) && eq_block(lb, rb),
 +        (TryBlock(l), TryBlock(r)) => eq_block(l, r),
 +        (Yield(l), Yield(r)) | (Ret(l), Ret(r)) => eq_expr_opt(l, r),
 +        (Break(ll, le), Break(rl, re)) => eq_label(ll, rl) && eq_expr_opt(le, re),
 +        (Continue(ll), Continue(rl)) => eq_label(ll, rl),
 +        (Assign(l1, l2, _), Assign(r1, r2, _)) | (Index(l1, l2), Index(r1, r2)) => eq_expr(l1, r1) && eq_expr(l2, r2),
 +        (AssignOp(lo, lp, lv), AssignOp(ro, rp, rv)) => lo.node == ro.node && eq_expr(lp, rp) && eq_expr(lv, rv),
 +        (Field(lp, lf), Field(rp, rf)) => eq_id(*lf, *rf) && eq_expr(lp, rp),
 +        (Match(ls, la), Match(rs, ra)) => eq_expr(ls, rs) && over(la, ra, eq_arm),
 +        (Closure(lc, la, lm, lf, lb, _), Closure(rc, ra, rm, rf, rb, _)) => {
 +            lc == rc && la.is_async() == ra.is_async() && lm == rm && eq_fn_decl(lf, rf) && eq_expr(lb, rb)
 +        },
 +        (Async(lc, _, lb), Async(rc, _, rb)) => lc == rc && eq_block(lb, rb),
 +        (Range(lf, lt, ll), Range(rf, rt, rl)) => ll == rl && eq_expr_opt(lf, rf) && eq_expr_opt(lt, rt),
 +        (AddrOf(lbk, lm, le), AddrOf(rbk, rm, re)) => lbk == rbk && lm == rm && eq_expr(le, re),
 +        (Path(lq, lp), Path(rq, rp)) => both(lq, rq, eq_qself) && eq_path(lp, rp),
 +        (MacCall(l), MacCall(r)) => eq_mac_call(l, r),
 +        (Struct(lse), Struct(rse)) => {
 +            eq_maybe_qself(&lse.qself, &rse.qself)
 +                && eq_path(&lse.path, &rse.path)
 +                && eq_struct_rest(&lse.rest, &rse.rest)
 +                && unordered_over(&lse.fields, &rse.fields, eq_field)
 +        },
 +        _ => false,
 +    }
 +}
 +
 +pub fn eq_field(l: &ExprField, r: &ExprField) -> bool {
 +    l.is_placeholder == r.is_placeholder
 +        && eq_id(l.ident, r.ident)
 +        && eq_expr(&l.expr, &r.expr)
 +        && over(&l.attrs, &r.attrs, eq_attr)
 +}
 +
 +pub fn eq_arm(l: &Arm, r: &Arm) -> bool {
 +    l.is_placeholder == r.is_placeholder
 +        && eq_pat(&l.pat, &r.pat)
 +        && eq_expr(&l.body, &r.body)
 +        && eq_expr_opt(&l.guard, &r.guard)
 +        && over(&l.attrs, &r.attrs, eq_attr)
 +}
 +
 +pub fn eq_label(l: &Option<Label>, r: &Option<Label>) -> bool {
 +    both(l, r, |l, r| eq_id(l.ident, r.ident))
 +}
 +
 +pub fn eq_block(l: &Block, r: &Block) -> bool {
 +    l.rules == r.rules && over(&l.stmts, &r.stmts, eq_stmt)
 +}
 +
 +pub fn eq_stmt(l: &Stmt, r: &Stmt) -> bool {
 +    use StmtKind::*;
 +    match (&l.kind, &r.kind) {
 +        (Local(l), Local(r)) => {
 +            eq_pat(&l.pat, &r.pat)
 +                && both(&l.ty, &r.ty, |l, r| eq_ty(l, r))
 +                && eq_local_kind(&l.kind, &r.kind)
 +                && over(&l.attrs, &r.attrs, eq_attr)
 +        },
 +        (Item(l), Item(r)) => eq_item(l, r, eq_item_kind),
 +        (Expr(l), Expr(r)) | (Semi(l), Semi(r)) => eq_expr(l, r),
 +        (Empty, Empty) => true,
 +        (MacCall(l), MacCall(r)) => {
 +            l.style == r.style && eq_mac_call(&l.mac, &r.mac) && over(&l.attrs, &r.attrs, eq_attr)
 +        },
 +        _ => false,
 +    }
 +}
 +
 +pub fn eq_local_kind(l: &LocalKind, r: &LocalKind) -> bool {
 +    use LocalKind::*;
 +    match (l, r) {
 +        (Decl, Decl) => true,
 +        (Init(l), Init(r)) => eq_expr(l, r),
 +        (InitElse(li, le), InitElse(ri, re)) => eq_expr(li, ri) && eq_block(le, re),
 +        _ => false,
 +    }
 +}
 +
 +pub fn eq_item<K>(l: &Item<K>, r: &Item<K>, mut eq_kind: impl FnMut(&K, &K) -> bool) -> bool {
 +    eq_id(l.ident, r.ident) && over(&l.attrs, &r.attrs, eq_attr) && eq_vis(&l.vis, &r.vis) && eq_kind(&l.kind, &r.kind)
 +}
 +
 +#[allow(clippy::too_many_lines)] // Just a big match statement
 +pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool {
 +    use ItemKind::*;
 +    match (l, r) {
 +        (ExternCrate(l), ExternCrate(r)) => l == r,
 +        (Use(l), Use(r)) => eq_use_tree(l, r),
 +        (Static(lt, lm, le), Static(rt, rm, re)) => lm == rm && eq_ty(lt, rt) && eq_expr_opt(le, re),
 +        (Const(ld, lt, le), Const(rd, rt, re)) => eq_defaultness(*ld, *rd) && eq_ty(lt, rt) && eq_expr_opt(le, re),
 +        (
 +            Fn(box ast::Fn {
 +                defaultness: ld,
 +                sig: lf,
 +                generics: lg,
 +                body: lb,
 +            }),
 +            Fn(box ast::Fn {
 +                defaultness: rd,
 +                sig: rf,
 +                generics: rg,
 +                body: rb,
 +            }),
 +        ) => {
 +            eq_defaultness(*ld, *rd) && eq_fn_sig(lf, rf) && eq_generics(lg, rg) && both(lb, rb, |l, r| eq_block(l, r))
 +        },
 +        (Mod(lu, lmk), Mod(ru, rmk)) => {
 +            lu == ru
 +                && match (lmk, rmk) {
 +                    (ModKind::Loaded(litems, linline, _), ModKind::Loaded(ritems, rinline, _)) => {
 +                        linline == rinline && over(litems, ritems, |l, r| eq_item(l, r, eq_item_kind))
 +                    },
 +                    (ModKind::Unloaded, ModKind::Unloaded) => true,
 +                    _ => false,
 +                }
 +        },
 +        (ForeignMod(l), ForeignMod(r)) => {
 +            both(&l.abi, &r.abi, eq_str_lit) && over(&l.items, &r.items, |l, r| eq_item(l, r, eq_foreign_item_kind))
 +        },
 +        (
 +            TyAlias(box ast::TyAlias {
 +                defaultness: ld,
 +                generics: lg,
 +                bounds: lb,
 +                ty: lt,
 +            }),
 +            TyAlias(box ast::TyAlias {
 +                defaultness: rd,
 +                generics: rg,
 +                bounds: rb,
 +                ty: rt,
 +            }),
 +        ) => {
 +            eq_defaultness(*ld, *rd)
 +                && eq_generics(lg, rg)
 +                && over(lb, rb, eq_generic_bound)
 +                && both(lt, rt, |l, r| eq_ty(l, r))
 +        },
 +        (Enum(le, lg), Enum(re, rg)) => over(&le.variants, &re.variants, eq_variant) && eq_generics(lg, rg),
 +        (Struct(lv, lg), Struct(rv, rg)) | (Union(lv, lg), Union(rv, rg)) => {
 +            eq_variant_data(lv, rv) && eq_generics(lg, rg)
 +        },
 +        (
 +            Trait(box ast::Trait {
 +                is_auto: la,
 +                unsafety: lu,
 +                generics: lg,
 +                bounds: lb,
 +                items: li,
 +            }),
 +            Trait(box ast::Trait {
 +                is_auto: ra,
 +                unsafety: ru,
 +                generics: rg,
 +                bounds: rb,
 +                items: ri,
 +            }),
 +        ) => {
 +            la == ra
 +                && matches!(lu, Unsafe::No) == matches!(ru, Unsafe::No)
 +                && eq_generics(lg, rg)
 +                && over(lb, rb, eq_generic_bound)
 +                && over(li, ri, |l, r| eq_item(l, r, eq_assoc_item_kind))
 +        },
 +        (TraitAlias(lg, lb), TraitAlias(rg, rb)) => eq_generics(lg, rg) && over(lb, rb, eq_generic_bound),
 +        (
 +            Impl(box ast::Impl {
 +                unsafety: lu,
 +                polarity: lp,
 +                defaultness: ld,
 +                constness: lc,
 +                generics: lg,
 +                of_trait: lot,
 +                self_ty: lst,
 +                items: li,
 +            }),
 +            Impl(box ast::Impl {
 +                unsafety: ru,
 +                polarity: rp,
 +                defaultness: rd,
 +                constness: rc,
 +                generics: rg,
 +                of_trait: rot,
 +                self_ty: rst,
 +                items: ri,
 +            }),
 +        ) => {
 +            matches!(lu, Unsafe::No) == matches!(ru, Unsafe::No)
 +                && matches!(lp, ImplPolarity::Positive) == matches!(rp, ImplPolarity::Positive)
 +                && eq_defaultness(*ld, *rd)
 +                && matches!(lc, ast::Const::No) == matches!(rc, ast::Const::No)
 +                && eq_generics(lg, rg)
 +                && both(lot, rot, |l, r| eq_path(&l.path, &r.path))
 +                && eq_ty(lst, rst)
 +                && over(li, ri, |l, r| eq_item(l, r, eq_assoc_item_kind))
 +        },
 +        (MacCall(l), MacCall(r)) => eq_mac_call(l, r),
 +        (MacroDef(l), MacroDef(r)) => l.macro_rules == r.macro_rules && eq_mac_args(&l.body, &r.body),
 +        _ => false,
 +    }
 +}
 +
 +pub fn eq_foreign_item_kind(l: &ForeignItemKind, r: &ForeignItemKind) -> bool {
 +    use ForeignItemKind::*;
 +    match (l, r) {
 +        (Static(lt, lm, le), Static(rt, rm, re)) => lm == rm && eq_ty(lt, rt) && eq_expr_opt(le, re),
 +        (
 +            Fn(box ast::Fn {
 +                defaultness: ld,
 +                sig: lf,
 +                generics: lg,
 +                body: lb,
 +            }),
 +            Fn(box ast::Fn {
 +                defaultness: rd,
 +                sig: rf,
 +                generics: rg,
 +                body: rb,
 +            }),
 +        ) => {
 +            eq_defaultness(*ld, *rd) && eq_fn_sig(lf, rf) && eq_generics(lg, rg) && both(lb, rb, |l, r| eq_block(l, r))
 +        },
 +        (
 +            TyAlias(box ast::TyAlias {
 +                defaultness: ld,
 +                generics: lg,
 +                bounds: lb,
 +                ty: lt,
 +            }),
 +            TyAlias(box ast::TyAlias {
 +                defaultness: rd,
 +                generics: rg,
 +                bounds: rb,
 +                ty: rt,
 +            }),
 +        ) => {
 +            eq_defaultness(*ld, *rd)
 +                && eq_generics(lg, rg)
 +                && over(lb, rb, eq_generic_bound)
 +                && both(lt, rt, |l, r| eq_ty(l, r))
 +        },
 +        (MacCall(l), MacCall(r)) => eq_mac_call(l, r),
 +        _ => false,
 +    }
 +}
 +
 +pub fn eq_assoc_item_kind(l: &AssocItemKind, r: &AssocItemKind) -> bool {
 +    use AssocItemKind::*;
 +    match (l, r) {
 +        (Const(ld, lt, le), Const(rd, rt, re)) => eq_defaultness(*ld, *rd) && eq_ty(lt, rt) && eq_expr_opt(le, re),
 +        (
 +            Fn(box ast::Fn {
 +                defaultness: ld,
 +                sig: lf,
 +                generics: lg,
 +                body: lb,
 +            }),
 +            Fn(box ast::Fn {
 +                defaultness: rd,
 +                sig: rf,
 +                generics: rg,
 +                body: rb,
 +            }),
 +        ) => {
 +            eq_defaultness(*ld, *rd) && eq_fn_sig(lf, rf) && eq_generics(lg, rg) && both(lb, rb, |l, r| eq_block(l, r))
 +        },
 +        (
 +            TyAlias(box ast::TyAlias {
 +                defaultness: ld,
 +                generics: lg,
 +                bounds: lb,
 +                ty: lt,
 +            }),
 +            TyAlias(box ast::TyAlias {
 +                defaultness: rd,
 +                generics: rg,
 +                bounds: rb,
 +                ty: rt,
 +            }),
 +        ) => {
 +            eq_defaultness(*ld, *rd)
 +                && eq_generics(lg, rg)
 +                && over(lb, rb, eq_generic_bound)
 +                && both(lt, rt, |l, r| eq_ty(l, r))
 +        },
 +        (MacCall(l), MacCall(r)) => eq_mac_call(l, r),
 +        _ => false,
 +    }
 +}
 +
 +pub fn eq_variant(l: &Variant, r: &Variant) -> bool {
 +    l.is_placeholder == r.is_placeholder
 +        && over(&l.attrs, &r.attrs, eq_attr)
 +        && eq_vis(&l.vis, &r.vis)
 +        && eq_id(l.ident, r.ident)
 +        && eq_variant_data(&l.data, &r.data)
 +        && both(&l.disr_expr, &r.disr_expr, |l, r| eq_expr(&l.value, &r.value))
 +}
 +
 +pub fn eq_variant_data(l: &VariantData, r: &VariantData) -> bool {
 +    use VariantData::*;
 +    match (l, r) {
 +        (Unit(_), Unit(_)) => true,
 +        (Struct(l, _), Struct(r, _)) | (Tuple(l, _), Tuple(r, _)) => over(l, r, eq_struct_field),
 +        _ => false,
 +    }
 +}
 +
 +pub fn eq_struct_field(l: &FieldDef, r: &FieldDef) -> bool {
 +    l.is_placeholder == r.is_placeholder
 +        && over(&l.attrs, &r.attrs, eq_attr)
 +        && eq_vis(&l.vis, &r.vis)
 +        && both(&l.ident, &r.ident, |l, r| eq_id(*l, *r))
 +        && eq_ty(&l.ty, &r.ty)
 +}
 +
 +pub fn eq_fn_sig(l: &FnSig, r: &FnSig) -> bool {
 +    eq_fn_decl(&l.decl, &r.decl) && eq_fn_header(&l.header, &r.header)
 +}
 +
 +pub fn eq_fn_header(l: &FnHeader, r: &FnHeader) -> bool {
 +    matches!(l.unsafety, Unsafe::No) == matches!(r.unsafety, Unsafe::No)
 +        && l.asyncness.is_async() == r.asyncness.is_async()
 +        && matches!(l.constness, Const::No) == matches!(r.constness, Const::No)
 +        && eq_ext(&l.ext, &r.ext)
 +}
 +
 +pub fn eq_generics(l: &Generics, r: &Generics) -> bool {
 +    over(&l.params, &r.params, eq_generic_param)
 +        && over(&l.where_clause.predicates, &r.where_clause.predicates, |l, r| {
 +            eq_where_predicate(l, r)
 +        })
 +}
 +
 +pub fn eq_where_predicate(l: &WherePredicate, r: &WherePredicate) -> bool {
 +    use WherePredicate::*;
 +    match (l, r) {
 +        (BoundPredicate(l), BoundPredicate(r)) => {
 +            over(&l.bound_generic_params, &r.bound_generic_params, |l, r| {
 +                eq_generic_param(l, r)
 +            }) && eq_ty(&l.bounded_ty, &r.bounded_ty)
 +                && over(&l.bounds, &r.bounds, eq_generic_bound)
 +        },
 +        (RegionPredicate(l), RegionPredicate(r)) => {
 +            eq_id(l.lifetime.ident, r.lifetime.ident) && over(&l.bounds, &r.bounds, eq_generic_bound)
 +        },
 +        (EqPredicate(l), EqPredicate(r)) => eq_ty(&l.lhs_ty, &r.lhs_ty) && eq_ty(&l.rhs_ty, &r.rhs_ty),
 +        _ => false,
 +    }
 +}
 +
 +pub fn eq_use_tree(l: &UseTree, r: &UseTree) -> bool {
 +    eq_path(&l.prefix, &r.prefix) && eq_use_tree_kind(&l.kind, &r.kind)
 +}
 +
 +pub fn eq_anon_const(l: &AnonConst, r: &AnonConst) -> bool {
 +    eq_expr(&l.value, &r.value)
 +}
 +
 +pub fn eq_use_tree_kind(l: &UseTreeKind, r: &UseTreeKind) -> bool {
 +    use UseTreeKind::*;
 +    match (l, r) {
 +        (Glob, Glob) => true,
 +        (Simple(l, _, _), Simple(r, _, _)) => both(l, r, |l, r| eq_id(*l, *r)),
 +        (Nested(l), Nested(r)) => over(l, r, |(l, _), (r, _)| eq_use_tree(l, r)),
 +        _ => false,
 +    }
 +}
 +
 +pub fn eq_defaultness(l: Defaultness, r: Defaultness) -> bool {
 +    matches!(
 +        (l, r),
 +        (Defaultness::Final, Defaultness::Final) | (Defaultness::Default(_), Defaultness::Default(_))
 +    )
 +}
 +
 +pub fn eq_vis(l: &Visibility, r: &Visibility) -> bool {
 +    use VisibilityKind::*;
 +    match (&l.kind, &r.kind) {
 +        (Public, Public) | (Inherited, Inherited) | (Crate(_), Crate(_)) => true,
 +        (Restricted { path: l, .. }, Restricted { path: r, .. }) => eq_path(l, r),
 +        _ => false,
 +    }
 +}
 +
 +pub fn eq_fn_decl(l: &FnDecl, r: &FnDecl) -> bool {
 +    eq_fn_ret_ty(&l.output, &r.output)
 +        && over(&l.inputs, &r.inputs, |l, r| {
 +            l.is_placeholder == r.is_placeholder
 +                && eq_pat(&l.pat, &r.pat)
 +                && eq_ty(&l.ty, &r.ty)
 +                && over(&l.attrs, &r.attrs, eq_attr)
 +        })
 +}
 +
 +pub fn eq_fn_ret_ty(l: &FnRetTy, r: &FnRetTy) -> bool {
 +    match (l, r) {
 +        (FnRetTy::Default(_), FnRetTy::Default(_)) => true,
 +        (FnRetTy::Ty(l), FnRetTy::Ty(r)) => eq_ty(l, r),
 +        _ => false,
 +    }
 +}
 +
 +pub fn eq_ty(l: &Ty, r: &Ty) -> bool {
 +    use TyKind::*;
 +    match (&l.kind, &r.kind) {
 +        (Paren(l), _) => eq_ty(l, r),
 +        (_, Paren(r)) => eq_ty(l, r),
 +        (Never, Never) | (Infer, Infer) | (ImplicitSelf, ImplicitSelf) | (Err, Err) | (CVarArgs, CVarArgs) => true,
 +        (Slice(l), Slice(r)) => eq_ty(l, r),
 +        (Array(le, ls), Array(re, rs)) => eq_ty(le, re) && eq_expr(&ls.value, &rs.value),
 +        (Ptr(l), Ptr(r)) => l.mutbl == r.mutbl && eq_ty(&l.ty, &r.ty),
 +        (Rptr(ll, l), Rptr(rl, r)) => {
 +            both(ll, rl, |l, r| eq_id(l.ident, r.ident)) && l.mutbl == r.mutbl && eq_ty(&l.ty, &r.ty)
 +        },
 +        (BareFn(l), BareFn(r)) => {
 +            l.unsafety == r.unsafety
 +                && eq_ext(&l.ext, &r.ext)
 +                && over(&l.generic_params, &r.generic_params, eq_generic_param)
 +                && eq_fn_decl(&l.decl, &r.decl)
 +        },
 +        (Tup(l), Tup(r)) => over(l, r, |l, r| eq_ty(l, r)),
 +        (Path(lq, lp), Path(rq, rp)) => both(lq, rq, eq_qself) && eq_path(lp, rp),
 +        (TraitObject(lg, ls), TraitObject(rg, rs)) => ls == rs && over(lg, rg, eq_generic_bound),
 +        (ImplTrait(_, lg), ImplTrait(_, rg)) => over(lg, rg, eq_generic_bound),
 +        (Typeof(l), Typeof(r)) => eq_expr(&l.value, &r.value),
 +        (MacCall(l), MacCall(r)) => eq_mac_call(l, r),
 +        _ => false,
 +    }
 +}
 +
 +pub fn eq_ext(l: &Extern, r: &Extern) -> bool {
 +    use Extern::*;
 +    match (l, r) {
 +        (None, None) | (Implicit, Implicit) => true,
 +        (Explicit(l), Explicit(r)) => eq_str_lit(l, r),
 +        _ => false,
 +    }
 +}
 +
 +pub fn eq_str_lit(l: &StrLit, r: &StrLit) -> bool {
 +    l.style == r.style && l.symbol == r.symbol && l.suffix == r.suffix
 +}
 +
 +pub fn eq_poly_ref_trait(l: &PolyTraitRef, r: &PolyTraitRef) -> bool {
 +    eq_path(&l.trait_ref.path, &r.trait_ref.path)
 +        && over(&l.bound_generic_params, &r.bound_generic_params, |l, r| {
 +            eq_generic_param(l, r)
 +        })
 +}
 +
 +pub fn eq_generic_param(l: &GenericParam, r: &GenericParam) -> bool {
 +    use GenericParamKind::*;
 +    l.is_placeholder == r.is_placeholder
 +        && eq_id(l.ident, r.ident)
 +        && over(&l.bounds, &r.bounds, eq_generic_bound)
 +        && match (&l.kind, &r.kind) {
 +            (Lifetime, Lifetime) => true,
 +            (Type { default: l }, Type { default: r }) => both(l, r, |l, r| eq_ty(l, r)),
 +            (
 +                Const {
 +                    ty: lt,
 +                    kw_span: _,
 +                    default: ld,
 +                },
 +                Const {
 +                    ty: rt,
 +                    kw_span: _,
 +                    default: rd,
 +                },
 +            ) => eq_ty(lt, rt) && both(ld, rd, eq_anon_const),
 +            _ => false,
 +        }
 +        && over(&l.attrs, &r.attrs, eq_attr)
 +}
 +
 +pub fn eq_generic_bound(l: &GenericBound, r: &GenericBound) -> bool {
 +    use GenericBound::*;
 +    match (l, r) {
 +        (Trait(ptr1, tbm1), Trait(ptr2, tbm2)) => tbm1 == tbm2 && eq_poly_ref_trait(ptr1, ptr2),
 +        (Outlives(l), Outlives(r)) => eq_id(l.ident, r.ident),
 +        _ => false,
 +    }
 +}
 +
 +fn eq_term(l: &Term, r: &Term) -> bool {
++    match (l, r) {
++        (Term::Ty(l), Term::Ty(r)) => eq_ty(l, r),
++        (Term::Const(l), Term::Const(r)) => eq_anon_const(l, r),
++        _ => false,
++    }
 +}
 +
 +pub fn eq_assoc_constraint(l: &AssocConstraint, r: &AssocConstraint) -> bool {
 +    use AssocConstraintKind::*;
 +    eq_id(l.ident, r.ident)
 +        && match (&l.kind, &r.kind) {
 +            (Equality { term: l }, Equality { term: r }) => eq_term(l, r),
 +            (Bound { bounds: l }, Bound { bounds: r }) => over(l, r, eq_generic_bound),
 +            _ => false,
 +        }
 +}
 +
 +pub fn eq_mac_call(l: &MacCall, r: &MacCall) -> bool {
 +    eq_path(&l.path, &r.path) && eq_mac_args(&l.args, &r.args)
 +}
 +
 +pub fn eq_attr(l: &Attribute, r: &Attribute) -> bool {
 +    use AttrKind::*;
 +    l.style == r.style
 +        && match (&l.kind, &r.kind) {
 +            (DocComment(l1, l2), DocComment(r1, r2)) => l1 == r1 && l2 == r2,
 +            (Normal(l, _), Normal(r, _)) => eq_path(&l.path, &r.path) && eq_mac_args(&l.args, &r.args),
 +            _ => false,
 +        }
 +}
 +
 +pub fn eq_mac_args(l: &MacArgs, r: &MacArgs) -> bool {
 +    use MacArgs::*;
 +    match (l, r) {
 +        (Empty, Empty) => true,
 +        (Delimited(_, ld, lts), Delimited(_, rd, rts)) => ld == rd && lts.eq_unspanned(rts),
 +        (Eq(_, lt), Eq(_, rt)) => lt.kind == rt.kind,
 +        _ => false,
 +    }
 +}
index 9233903e98a0068c6ee1d1170101da2f22f12053,0000000000000000000000000000000000000000..a2f1f4696513e067febb58cc2b688faef4c04c73
mode 100644,000000..100644
--- /dev/null
@@@ -1,2232 -1,0 +1,2236 @@@
- pub fn get_expr_use_or_unification_node<'tcx>(tcx: TyCtxt<'tcx>, expr: &Expr<'_>) -> Option<Node<'tcx>> {
 +#![feature(box_patterns)]
 +#![feature(control_flow_enum)]
 +#![feature(let_else)]
 +#![feature(once_cell)]
 +#![feature(rustc_private)]
 +#![recursion_limit = "512"]
 +#![cfg_attr(feature = "deny-warnings", deny(warnings))]
 +#![allow(clippy::missing_errors_doc, clippy::missing_panics_doc, clippy::must_use_candidate)]
 +// warn on the same lints as `clippy_lints`
 +#![warn(trivial_casts, trivial_numeric_casts)]
 +// warn on lints, that are included in `rust-lang/rust`s bootstrap
 +#![warn(rust_2018_idioms, unused_lifetimes)]
 +// warn on rustc internal lints
 +#![warn(rustc::internal)]
 +
 +// FIXME: switch to something more ergonomic here, once available.
 +// (Currently there is no way to opt into sysroot crates without `extern crate`.)
 +extern crate rustc_ast;
 +extern crate rustc_ast_pretty;
 +extern crate rustc_attr;
 +extern crate rustc_data_structures;
 +extern crate rustc_errors;
 +extern crate rustc_hir;
 +extern crate rustc_infer;
 +extern crate rustc_lexer;
 +extern crate rustc_lint;
 +extern crate rustc_middle;
 +extern crate rustc_session;
 +extern crate rustc_span;
 +extern crate rustc_target;
 +extern crate rustc_trait_selection;
 +extern crate rustc_typeck;
 +
 +#[macro_use]
 +pub mod sym_helper;
 +
 +#[allow(clippy::module_name_repetitions)]
 +pub mod ast_utils;
 +pub mod attrs;
 +pub mod comparisons;
 +pub mod consts;
 +pub mod diagnostics;
 +pub mod eager_or_lazy;
 +pub mod higher;
 +mod hir_utils;
 +pub mod macros;
 +pub mod msrvs;
 +pub mod numeric_literal;
 +pub mod paths;
 +pub mod ptr;
 +pub mod qualify_min_const_fn;
 +pub mod source;
 +pub mod str_utils;
 +pub mod sugg;
 +pub mod ty;
 +pub mod usage;
 +pub mod visitors;
 +
 +pub use self::attrs::*;
 +pub use self::hir_utils::{both, count_eq, eq_expr_value, over, SpanlessEq, SpanlessHash};
 +
 +use std::collections::hash_map::Entry;
 +use std::hash::BuildHasherDefault;
 +use std::lazy::SyncOnceCell;
 +use std::sync::{Mutex, MutexGuard};
 +
 +use if_chain::if_chain;
 +use rustc_ast::ast::{self, Attribute, LitKind};
 +use rustc_data_structures::fx::FxHashMap;
 +use rustc_data_structures::unhash::UnhashMap;
 +use rustc_hir as hir;
 +use rustc_hir::def::{DefKind, Res};
 +use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, CRATE_DEF_ID};
 +use rustc_hir::hir_id::{HirIdMap, HirIdSet};
 +use rustc_hir::intravisit::{walk_expr, FnKind, Visitor};
 +use rustc_hir::itemlikevisit::ItemLikeVisitor;
 +use rustc_hir::LangItem::{OptionNone, ResultErr, ResultOk};
 +use rustc_hir::{
 +    def, lang_items, Arm, ArrayLen, BindingAnnotation, Block, BlockCheckMode, Body, Constness, Destination, Expr,
 +    ExprKind, FnDecl, ForeignItem, GenericArgs, HirId, Impl, ImplItem, ImplItemKind, IsAsync, Item, ItemKind, LangItem,
 +    Local, MatchSource, Mutability, Node, Param, Pat, PatKind, Path, PathSegment, PrimTy, QPath, Stmt, StmtKind,
 +    Target, TraitItem, TraitItemKind, TraitRef, TyKind, UnOp,
 +};
 +use rustc_lint::{LateContext, Level, Lint, LintContext};
 +use rustc_middle::hir::place::PlaceBase;
 +use rustc_middle::ty as rustc_ty;
 +use rustc_middle::ty::adjustment::{Adjust, Adjustment, AutoBorrow};
 +use rustc_middle::ty::binding::BindingMode;
 +use rustc_middle::ty::{layout::IntegerExt, BorrowKind, DefIdTree, Ty, TyCtxt, TypeAndMut, TypeFoldable, UpvarCapture};
 +use rustc_semver::RustcVersion;
 +use rustc_session::Session;
 +use rustc_span::hygiene::{ExpnKind, MacroKind};
 +use rustc_span::source_map::original_sp;
 +use rustc_span::sym;
 +use rustc_span::symbol::{kw, Symbol};
 +use rustc_span::{Span, DUMMY_SP};
 +use rustc_target::abi::Integer;
 +
 +use crate::consts::{constant, Constant};
 +use crate::ty::{can_partially_move_ty, is_copy, is_recursively_primitive_type};
 +use crate::visitors::expr_visitor_no_bodies;
 +
 +pub fn parse_msrv(msrv: &str, sess: Option<&Session>, span: Option<Span>) -> Option<RustcVersion> {
 +    if let Ok(version) = RustcVersion::parse(msrv) {
 +        return Some(version);
 +    } else if let Some(sess) = sess {
 +        if let Some(span) = span {
 +            sess.span_err(span, &format!("`{}` is not a valid Rust version", msrv));
 +        }
 +    }
 +    None
 +}
 +
 +pub fn meets_msrv(msrv: Option<&RustcVersion>, lint_msrv: &RustcVersion) -> bool {
 +    msrv.map_or(true, |msrv| msrv.meets(*lint_msrv))
 +}
 +
 +#[macro_export]
 +macro_rules! extract_msrv_attr {
 +    ($context:ident) => {
 +        fn enter_lint_attrs(&mut self, cx: &rustc_lint::$context<'_>, attrs: &[rustc_ast::ast::Attribute]) {
 +            let sess = rustc_lint::LintContext::sess(cx);
 +            match $crate::get_unique_inner_attr(sess, attrs, "msrv") {
 +                Some(msrv_attr) => {
 +                    if let Some(msrv) = msrv_attr.value_str() {
 +                        self.msrv = $crate::parse_msrv(&msrv.to_string(), Some(sess), Some(msrv_attr.span));
 +                    } else {
 +                        sess.span_err(msrv_attr.span, "bad clippy attribute");
 +                    }
 +                },
 +                _ => (),
 +            }
 +        }
 +    };
 +}
 +
 +/// Returns `true` if the two spans come from differing expansions (i.e., one is
 +/// from a macro and one isn't).
 +#[must_use]
 +pub fn differing_macro_contexts(lhs: Span, rhs: Span) -> bool {
 +    rhs.ctxt() != lhs.ctxt()
 +}
 +
 +/// If the given expression is a local binding, find the initializer expression.
 +/// If that initializer expression is another local binding, find its initializer again.
 +/// This process repeats as long as possible (but usually no more than once). Initializer
 +/// expressions with adjustments are ignored. If this is not desired, use [`find_binding_init`]
 +/// instead.
 +///
 +/// Examples:
 +/// ```
 +/// let abc = 1;
 +/// //        ^ output
 +/// let def = abc;
 +/// dbg!(def);
 +/// //   ^^^ input
 +///
 +/// // or...
 +/// let abc = 1;
 +/// let def = abc + 2;
 +/// //        ^^^^^^^ output
 +/// dbg!(def);
 +/// //   ^^^ input
 +/// ```
 +pub fn expr_or_init<'a, 'b, 'tcx: 'b>(cx: &LateContext<'tcx>, mut expr: &'a Expr<'b>) -> &'a Expr<'b> {
 +    while let Some(init) = path_to_local(expr)
 +        .and_then(|id| find_binding_init(cx, id))
 +        .filter(|init| cx.typeck_results().expr_adjustments(init).is_empty())
 +    {
 +        expr = init;
 +    }
 +    expr
 +}
 +
 +/// Finds the initializer expression for a local binding. Returns `None` if the binding is mutable.
 +/// By only considering immutable bindings, we guarantee that the returned expression represents the
 +/// value of the binding wherever it is referenced.
 +///
 +/// Example: For `let x = 1`, if the `HirId` of `x` is provided, the `Expr` `1` is returned.
 +/// Note: If you have an expression that references a binding `x`, use `path_to_local` to get the
 +/// canonical binding `HirId`.
 +pub fn find_binding_init<'tcx>(cx: &LateContext<'tcx>, hir_id: HirId) -> Option<&'tcx Expr<'tcx>> {
 +    let hir = cx.tcx.hir();
 +    if_chain! {
 +        if let Some(Node::Binding(pat)) = hir.find(hir_id);
 +        if matches!(pat.kind, PatKind::Binding(BindingAnnotation::Unannotated, ..));
 +        let parent = hir.get_parent_node(hir_id);
 +        if let Some(Node::Local(local)) = hir.find(parent);
 +        then {
 +            return local.init;
 +        }
 +    }
 +    None
 +}
 +
 +/// Returns `true` if the given `NodeId` is inside a constant context
 +///
 +/// # Example
 +///
 +/// ```rust,ignore
 +/// if in_constant(cx, expr.hir_id) {
 +///     // Do something
 +/// }
 +/// ```
 +pub fn in_constant(cx: &LateContext<'_>, id: HirId) -> bool {
 +    let parent_id = cx.tcx.hir().get_parent_item(id);
 +    match cx.tcx.hir().get_by_def_id(parent_id) {
 +        Node::Item(&Item {
 +            kind: ItemKind::Const(..) | ItemKind::Static(..),
 +            ..
 +        })
 +        | Node::TraitItem(&TraitItem {
 +            kind: TraitItemKind::Const(..),
 +            ..
 +        })
 +        | Node::ImplItem(&ImplItem {
 +            kind: ImplItemKind::Const(..),
 +            ..
 +        })
 +        | Node::AnonConst(_) => true,
 +        Node::Item(&Item {
 +            kind: ItemKind::Fn(ref sig, ..),
 +            ..
 +        })
 +        | Node::ImplItem(&ImplItem {
 +            kind: ImplItemKind::Fn(ref sig, _),
 +            ..
 +        }) => sig.header.constness == Constness::Const,
 +        _ => false,
 +    }
 +}
 +
 +/// Checks if a `QPath` resolves to a constructor of a `LangItem`.
 +/// For example, use this to check whether a function call or a pattern is `Some(..)`.
 +pub fn is_lang_ctor(cx: &LateContext<'_>, qpath: &QPath<'_>, lang_item: LangItem) -> bool {
 +    if let QPath::Resolved(_, path) = qpath {
 +        if let Res::Def(DefKind::Ctor(..), ctor_id) = path.res {
 +            if let Ok(item_id) = cx.tcx.lang_items().require(lang_item) {
 +                return cx.tcx.parent(ctor_id) == Some(item_id);
 +            }
 +        }
 +    }
 +    false
 +}
 +
 +pub fn is_unit_expr(expr: &Expr<'_>) -> bool {
 +    matches!(
 +        expr.kind,
 +        ExprKind::Block(
 +            Block {
 +                stmts: [],
 +                expr: None,
 +                ..
 +            },
 +            _
 +        ) | ExprKind::Tup([])
 +    )
 +}
 +
 +/// Checks if given pattern is a wildcard (`_`)
 +pub fn is_wild(pat: &Pat<'_>) -> bool {
 +    matches!(pat.kind, PatKind::Wild)
 +}
 +
 +/// Checks if the first type parameter is a lang item.
 +pub fn is_ty_param_lang_item<'tcx>(
 +    cx: &LateContext<'_>,
 +    qpath: &QPath<'tcx>,
 +    item: LangItem,
 +) -> Option<&'tcx hir::Ty<'tcx>> {
 +    let ty = get_qpath_generic_tys(qpath).next()?;
 +
 +    if let TyKind::Path(qpath) = &ty.kind {
 +        cx.qpath_res(qpath, ty.hir_id)
 +            .opt_def_id()
 +            .map_or(false, |id| {
 +                cx.tcx.lang_items().require(item).map_or(false, |lang_id| id == lang_id)
 +            })
 +            .then(|| ty)
 +    } else {
 +        None
 +    }
 +}
 +
 +/// Checks if the first type parameter is a diagnostic item.
 +pub fn is_ty_param_diagnostic_item<'tcx>(
 +    cx: &LateContext<'_>,
 +    qpath: &QPath<'tcx>,
 +    item: Symbol,
 +) -> Option<&'tcx hir::Ty<'tcx>> {
 +    let ty = get_qpath_generic_tys(qpath).next()?;
 +
 +    if let TyKind::Path(qpath) = &ty.kind {
 +        cx.qpath_res(qpath, ty.hir_id)
 +            .opt_def_id()
 +            .map_or(false, |id| cx.tcx.is_diagnostic_item(item, id))
 +            .then(|| ty)
 +    } else {
 +        None
 +    }
 +}
 +
 +/// Checks if the method call given in `expr` belongs to the given trait.
 +/// This is a deprecated function, consider using [`is_trait_method`].
 +pub fn match_trait_method(cx: &LateContext<'_>, expr: &Expr<'_>, path: &[&str]) -> bool {
 +    let def_id = cx.typeck_results().type_dependent_def_id(expr.hir_id).unwrap();
 +    let trt_id = cx.tcx.trait_of_item(def_id);
 +    trt_id.map_or(false, |trt_id| match_def_path(cx, trt_id, path))
 +}
 +
 +/// Checks if a method is defined in an impl of a diagnostic item
 +pub fn is_diag_item_method(cx: &LateContext<'_>, def_id: DefId, diag_item: Symbol) -> bool {
 +    if let Some(impl_did) = cx.tcx.impl_of_method(def_id) {
 +        if let Some(adt) = cx.tcx.type_of(impl_did).ty_adt_def() {
 +            return cx.tcx.is_diagnostic_item(diag_item, adt.did);
 +        }
 +    }
 +    false
 +}
 +
 +/// Checks if a method is in a diagnostic item trait
 +pub fn is_diag_trait_item(cx: &LateContext<'_>, def_id: DefId, diag_item: Symbol) -> bool {
 +    if let Some(trait_did) = cx.tcx.trait_of_item(def_id) {
 +        return cx.tcx.is_diagnostic_item(diag_item, trait_did);
 +    }
 +    false
 +}
 +
 +/// Checks if the method call given in `expr` belongs to the given trait.
 +pub fn is_trait_method(cx: &LateContext<'_>, expr: &Expr<'_>, diag_item: Symbol) -> bool {
 +    cx.typeck_results()
 +        .type_dependent_def_id(expr.hir_id)
 +        .map_or(false, |did| is_diag_trait_item(cx, did, diag_item))
 +}
 +
 +/// Checks if the given expression is a path referring an item on the trait
 +/// that is marked with the given diagnostic item.
 +///
 +/// For checking method call expressions instead of path expressions, use
 +/// [`is_trait_method`].
 +///
 +/// For example, this can be used to find if an expression like `u64::default`
 +/// refers to an item of the trait `Default`, which is associated with the
 +/// `diag_item` of `sym::Default`.
 +pub fn is_trait_item(cx: &LateContext<'_>, expr: &Expr<'_>, diag_item: Symbol) -> bool {
 +    if let hir::ExprKind::Path(ref qpath) = expr.kind {
 +        cx.qpath_res(qpath, expr.hir_id)
 +            .opt_def_id()
 +            .map_or(false, |def_id| is_diag_trait_item(cx, def_id, diag_item))
 +    } else {
 +        false
 +    }
 +}
 +
 +pub fn last_path_segment<'tcx>(path: &QPath<'tcx>) -> &'tcx PathSegment<'tcx> {
 +    match *path {
 +        QPath::Resolved(_, path) => path.segments.last().expect("A path must have at least one segment"),
 +        QPath::TypeRelative(_, seg) => seg,
 +        QPath::LangItem(..) => panic!("last_path_segment: lang item has no path segments"),
 +    }
 +}
 +
 +pub fn get_qpath_generics<'tcx>(path: &QPath<'tcx>) -> Option<&'tcx GenericArgs<'tcx>> {
 +    match path {
 +        QPath::Resolved(_, p) => p.segments.last().and_then(|s| s.args),
 +        QPath::TypeRelative(_, s) => s.args,
 +        QPath::LangItem(..) => None,
 +    }
 +}
 +
 +pub fn get_qpath_generic_tys<'tcx>(path: &QPath<'tcx>) -> impl Iterator<Item = &'tcx hir::Ty<'tcx>> {
 +    get_qpath_generics(path)
 +        .map_or([].as_ref(), |a| a.args)
 +        .iter()
 +        .filter_map(|a| {
 +            if let hir::GenericArg::Type(ty) = a {
 +                Some(ty)
 +            } else {
 +                None
 +            }
 +        })
 +}
 +
 +pub fn single_segment_path<'tcx>(path: &QPath<'tcx>) -> Option<&'tcx PathSegment<'tcx>> {
 +    match *path {
 +        QPath::Resolved(_, path) => path.segments.get(0),
 +        QPath::TypeRelative(_, seg) => Some(seg),
 +        QPath::LangItem(..) => None,
 +    }
 +}
 +
 +/// THIS METHOD IS DEPRECATED and will eventually be removed since it does not match against the
 +/// entire path or resolved `DefId`. Prefer using `match_def_path`. Consider getting a `DefId` from
 +/// `QPath::Resolved.1.res.opt_def_id()`.
 +///
 +/// Matches a `QPath` against a slice of segment string literals.
 +///
 +/// There is also `match_path` if you are dealing with a `rustc_hir::Path` instead of a
 +/// `rustc_hir::QPath`.
 +///
 +/// # Examples
 +/// ```rust,ignore
 +/// match_qpath(path, &["std", "rt", "begin_unwind"])
 +/// ```
 +pub fn match_qpath(path: &QPath<'_>, segments: &[&str]) -> bool {
 +    match *path {
 +        QPath::Resolved(_, path) => match_path(path, segments),
 +        QPath::TypeRelative(ty, segment) => match ty.kind {
 +            TyKind::Path(ref inner_path) => {
 +                if let [prefix @ .., end] = segments {
 +                    if match_qpath(inner_path, prefix) {
 +                        return segment.ident.name.as_str() == *end;
 +                    }
 +                }
 +                false
 +            },
 +            _ => false,
 +        },
 +        QPath::LangItem(..) => false,
 +    }
 +}
 +
 +/// If the expression is a path, resolve it. Otherwise, return `Res::Err`.
 +pub fn expr_path_res(cx: &LateContext<'_>, expr: &Expr<'_>) -> Res {
 +    if let ExprKind::Path(p) = &expr.kind {
 +        cx.qpath_res(p, expr.hir_id)
 +    } else {
 +        Res::Err
 +    }
 +}
 +
 +/// Resolves the path to a `DefId` and checks if it matches the given path.
 +pub fn is_qpath_def_path(cx: &LateContext<'_>, path: &QPath<'_>, hir_id: HirId, segments: &[&str]) -> bool {
 +    cx.qpath_res(path, hir_id)
 +        .opt_def_id()
 +        .map_or(false, |id| match_def_path(cx, id, segments))
 +}
 +
 +/// If the expression is a path, resolves it to a `DefId` and checks if it matches the given path.
 +///
 +/// Please use `is_expr_diagnostic_item` if the target is a diagnostic item.
 +pub fn is_expr_path_def_path(cx: &LateContext<'_>, expr: &Expr<'_>, segments: &[&str]) -> bool {
 +    expr_path_res(cx, expr)
 +        .opt_def_id()
 +        .map_or(false, |id| match_def_path(cx, id, segments))
 +}
 +
 +/// If the expression is a path, resolves it to a `DefId` and checks if it matches the given
 +/// diagnostic item.
 +pub fn is_expr_diagnostic_item(cx: &LateContext<'_>, expr: &Expr<'_>, diag_item: Symbol) -> bool {
 +    expr_path_res(cx, expr)
 +        .opt_def_id()
 +        .map_or(false, |id| cx.tcx.is_diagnostic_item(diag_item, id))
 +}
 +
 +/// THIS METHOD IS DEPRECATED and will eventually be removed since it does not match against the
 +/// entire path or resolved `DefId`. Prefer using `match_def_path`. Consider getting a `DefId` from
 +/// `QPath::Resolved.1.res.opt_def_id()`.
 +///
 +/// Matches a `Path` against a slice of segment string literals.
 +///
 +/// There is also `match_qpath` if you are dealing with a `rustc_hir::QPath` instead of a
 +/// `rustc_hir::Path`.
 +///
 +/// # Examples
 +///
 +/// ```rust,ignore
 +/// if match_path(&trait_ref.path, &paths::HASH) {
 +///     // This is the `std::hash::Hash` trait.
 +/// }
 +///
 +/// if match_path(ty_path, &["rustc", "lint", "Lint"]) {
 +///     // This is a `rustc_middle::lint::Lint`.
 +/// }
 +/// ```
 +pub fn match_path(path: &Path<'_>, segments: &[&str]) -> bool {
 +    path.segments
 +        .iter()
 +        .rev()
 +        .zip(segments.iter().rev())
 +        .all(|(a, b)| a.ident.name.as_str() == *b)
 +}
 +
 +/// If the expression is a path to a local, returns the canonical `HirId` of the local.
 +pub fn path_to_local(expr: &Expr<'_>) -> Option<HirId> {
 +    if let ExprKind::Path(QPath::Resolved(None, path)) = expr.kind {
 +        if let Res::Local(id) = path.res {
 +            return Some(id);
 +        }
 +    }
 +    None
 +}
 +
 +/// Returns true if the expression is a path to a local with the specified `HirId`.
 +/// Use this function to see if an expression matches a function argument or a match binding.
 +pub fn path_to_local_id(expr: &Expr<'_>, id: HirId) -> bool {
 +    path_to_local(expr) == Some(id)
 +}
 +
 +/// Gets the definition associated to a path.
 +pub fn path_to_res(cx: &LateContext<'_>, path: &[&str]) -> Res {
 +    macro_rules! try_res {
 +        ($e:expr) => {
 +            match $e {
 +                Some(e) => e,
 +                None => return Res::Err,
 +            }
 +        };
 +    }
 +    fn item_child_by_name(tcx: TyCtxt<'_>, def_id: DefId, name: &str) -> Option<Res> {
 +        match tcx.def_kind(def_id) {
 +            DefKind::Mod | DefKind::Enum | DefKind::Trait => tcx
 +                .module_children(def_id)
 +                .iter()
 +                .find(|item| item.ident.name.as_str() == name)
 +                .map(|child| child.res.expect_non_local()),
 +            DefKind::Impl => tcx
 +                .associated_item_def_ids(def_id)
 +                .iter()
 +                .copied()
 +                .find(|assoc_def_id| tcx.item_name(*assoc_def_id).as_str() == name)
 +                .map(|assoc_def_id| Res::Def(tcx.def_kind(assoc_def_id), assoc_def_id)),
 +            _ => None,
 +        }
 +    }
 +    fn find_primitive(tcx: TyCtxt<'_>, name: &str) -> Option<DefId> {
 +        if let Some(&(index, Target::Impl)) = lang_items::ITEM_REFS.get(&Symbol::intern(name)) {
 +            tcx.lang_items().items()[index]
 +        } else {
 +            None
 +        }
 +    }
 +    fn find_crate(tcx: TyCtxt<'_>, name: &str) -> Option<DefId> {
 +        tcx.crates(())
 +            .iter()
 +            .find(|&&num| tcx.crate_name(num).as_str() == name)
 +            .map(CrateNum::as_def_id)
 +    }
 +
 +    let (base, first, path) = match *path {
 +        [base, first, ref path @ ..] => (base, first, path),
 +        [primitive] => {
 +            return PrimTy::from_name(Symbol::intern(primitive)).map_or(Res::Err, Res::PrimTy);
 +        },
 +        _ => return Res::Err,
 +    };
 +    let tcx = cx.tcx;
 +    let first = try_res!(
 +        find_primitive(tcx, base)
 +            .or_else(|| find_crate(tcx, base))
 +            .and_then(|id| item_child_by_name(tcx, id, first))
 +    );
 +
 +    let last = path
 +        .iter()
 +        .copied()
 +        // for each segment, find the child item
 +        .try_fold(first, |res, segment| {
 +            let def_id = res.def_id();
 +            if let Some(item) = item_child_by_name(tcx, def_id, segment) {
 +                Some(item)
 +            } else if matches!(res, Res::Def(DefKind::Enum | DefKind::Struct, _)) {
 +                // it is not a child item so check inherent impl items
 +                tcx.inherent_impls(def_id)
 +                    .iter()
 +                    .find_map(|&impl_def_id| item_child_by_name(tcx, impl_def_id, segment))
 +            } else {
 +                None
 +            }
 +        });
 +    try_res!(last).expect_non_local()
 +}
 +
 +/// Convenience function to get the `DefId` of a trait by path.
 +/// It could be a trait or trait alias.
 +pub fn get_trait_def_id(cx: &LateContext<'_>, path: &[&str]) -> Option<DefId> {
 +    match path_to_res(cx, path) {
 +        Res::Def(DefKind::Trait | DefKind::TraitAlias, trait_id) => Some(trait_id),
 +        _ => None,
 +    }
 +}
 +
 +/// Gets the `hir::TraitRef` of the trait the given method is implemented for.
 +///
 +/// Use this if you want to find the `TraitRef` of the `Add` trait in this example:
 +///
 +/// ```rust
 +/// struct Point(isize, isize);
 +///
 +/// impl std::ops::Add for Point {
 +///     type Output = Self;
 +///
 +///     fn add(self, other: Self) -> Self {
 +///         Point(0, 0)
 +///     }
 +/// }
 +/// ```
 +pub fn trait_ref_of_method<'tcx>(cx: &LateContext<'tcx>, def_id: LocalDefId) -> Option<&'tcx TraitRef<'tcx>> {
 +    // Get the implemented trait for the current function
 +    let hir_id = cx.tcx.hir().local_def_id_to_hir_id(def_id);
 +    let parent_impl = cx.tcx.hir().get_parent_item(hir_id);
 +    if_chain! {
 +        if parent_impl != CRATE_DEF_ID;
 +        if let hir::Node::Item(item) = cx.tcx.hir().get_by_def_id(parent_impl);
 +        if let hir::ItemKind::Impl(impl_) = &item.kind;
 +        then { return impl_.of_trait.as_ref(); }
 +    }
 +    None
 +}
 +
 +/// This method will return tuple of projection stack and root of the expression,
 +/// used in `can_mut_borrow_both`.
 +///
 +/// For example, if `e` represents the `v[0].a.b[x]`
 +/// this method will return a tuple, composed of a `Vec`
 +/// containing the `Expr`s for `v[0], v[0].a, v[0].a.b, v[0].a.b[x]`
 +/// and an `Expr` for root of them, `v`
 +fn projection_stack<'a, 'hir>(mut e: &'a Expr<'hir>) -> (Vec<&'a Expr<'hir>>, &'a Expr<'hir>) {
 +    let mut result = vec![];
 +    let root = loop {
 +        match e.kind {
 +            ExprKind::Index(ep, _) | ExprKind::Field(ep, _) => {
 +                result.push(e);
 +                e = ep;
 +            },
 +            _ => break e,
 +        };
 +    };
 +    result.reverse();
 +    (result, root)
 +}
 +
 +/// Gets the mutability of the custom deref adjustment, if any.
 +pub fn expr_custom_deref_adjustment(cx: &LateContext<'_>, e: &Expr<'_>) -> Option<Mutability> {
 +    cx.typeck_results()
 +        .expr_adjustments(e)
 +        .iter()
 +        .find_map(|a| match a.kind {
 +            Adjust::Deref(Some(d)) => Some(Some(d.mutbl)),
 +            Adjust::Deref(None) => None,
 +            _ => Some(None),
 +        })
 +        .and_then(|x| x)
 +}
 +
 +/// Checks if two expressions can be mutably borrowed simultaneously
 +/// and they aren't dependent on borrowing same thing twice
 +pub fn can_mut_borrow_both(cx: &LateContext<'_>, e1: &Expr<'_>, e2: &Expr<'_>) -> bool {
 +    let (s1, r1) = projection_stack(e1);
 +    let (s2, r2) = projection_stack(e2);
 +    if !eq_expr_value(cx, r1, r2) {
 +        return true;
 +    }
 +    if expr_custom_deref_adjustment(cx, r1).is_some() || expr_custom_deref_adjustment(cx, r2).is_some() {
 +        return false;
 +    }
 +
 +    for (x1, x2) in s1.iter().zip(s2.iter()) {
 +        if expr_custom_deref_adjustment(cx, x1).is_some() || expr_custom_deref_adjustment(cx, x2).is_some() {
 +            return false;
 +        }
 +
 +        match (&x1.kind, &x2.kind) {
 +            (ExprKind::Field(_, i1), ExprKind::Field(_, i2)) => {
 +                if i1 != i2 {
 +                    return true;
 +                }
 +            },
 +            (ExprKind::Index(_, i1), ExprKind::Index(_, i2)) => {
 +                if !eq_expr_value(cx, i1, i2) {
 +                    return false;
 +                }
 +            },
 +            _ => return false,
 +        }
 +    }
 +    false
 +}
 +
 +/// Returns true if the `def_id` associated with the `path` is recognized as a "default-equivalent"
 +/// constructor from the std library
 +fn is_default_equivalent_ctor(cx: &LateContext<'_>, def_id: DefId, path: &QPath<'_>) -> bool {
 +    let std_types_symbols = &[
 +        sym::String,
 +        sym::Vec,
 +        sym::VecDeque,
 +        sym::LinkedList,
 +        sym::HashMap,
 +        sym::BTreeMap,
 +        sym::HashSet,
 +        sym::BTreeSet,
 +        sym::BinaryHeap,
 +    ];
 +
 +    if let QPath::TypeRelative(_, method) = path {
 +        if method.ident.name == sym::new {
 +            if let Some(impl_did) = cx.tcx.impl_of_method(def_id) {
 +                if let Some(adt) = cx.tcx.type_of(impl_did).ty_adt_def() {
 +                    return std_types_symbols
 +                        .iter()
 +                        .any(|&symbol| cx.tcx.is_diagnostic_item(symbol, adt.did));
 +                }
 +            }
 +        }
 +    }
 +    false
 +}
 +
 +/// Return true if the expr is equal to `Default::default` when evaluated.
 +pub fn is_default_equivalent_call(cx: &LateContext<'_>, repl_func: &Expr<'_>) -> bool {
 +    if_chain! {
 +        if let hir::ExprKind::Path(ref repl_func_qpath) = repl_func.kind;
 +        if let Some(repl_def_id) = cx.qpath_res(repl_func_qpath, repl_func.hir_id).opt_def_id();
 +        if is_diag_trait_item(cx, repl_def_id, sym::Default)
 +            || is_default_equivalent_ctor(cx, repl_def_id, repl_func_qpath);
 +        then {
 +            true
 +        }
 +        else {
 +            false
 +        }
 +    }
 +}
 +
 +/// Returns true if the expr is equal to `Default::default()` of it's type when evaluated.
 +/// It doesn't cover all cases, for example indirect function calls (some of std
 +/// functions are supported) but it is the best we have.
 +pub fn is_default_equivalent(cx: &LateContext<'_>, e: &Expr<'_>) -> bool {
 +    match &e.kind {
 +        ExprKind::Lit(lit) => match lit.node {
 +            LitKind::Bool(false) | LitKind::Int(0, _) => true,
 +            LitKind::Str(s, _) => s.is_empty(),
 +            _ => false,
 +        },
 +        ExprKind::Tup(items) | ExprKind::Array(items) => items.iter().all(|x| is_default_equivalent(cx, x)),
 +        ExprKind::Repeat(x, ArrayLen::Body(len)) => if_chain! {
 +            if let ExprKind::Lit(ref const_lit) = cx.tcx.hir().body(len.body).value.kind;
 +            if let LitKind::Int(v, _) = const_lit.node;
 +            if v <= 32 && is_default_equivalent(cx, x);
 +            then {
 +                true
 +            }
 +            else {
 +                false
 +            }
 +        },
 +        ExprKind::Call(repl_func, _) => is_default_equivalent_call(cx, repl_func),
 +        ExprKind::Path(qpath) => is_lang_ctor(cx, qpath, OptionNone),
 +        ExprKind::AddrOf(rustc_hir::BorrowKind::Ref, _, expr) => matches!(expr.kind, ExprKind::Array([])),
 +        _ => false,
 +    }
 +}
 +
 +/// Checks if the top level expression can be moved into a closure as is.
 +/// Currently checks for:
 +/// * Break/Continue outside the given loop HIR ids.
 +/// * Yield/Return statements.
 +/// * Inline assembly.
 +/// * Usages of a field of a local where the type of the local can be partially moved.
 +///
 +/// For example, given the following function:
 +///
 +/// ```
 +/// fn f<'a>(iter: &mut impl Iterator<Item = (usize, &'a mut String)>) {
 +///     for item in iter {
 +///         let s = item.1;
 +///         if item.0 > 10 {
 +///             continue;
 +///         } else {
 +///             s.clear();
 +///         }
 +///     }
 +/// }
 +/// ```
 +///
 +/// When called on the expression `item.0` this will return false unless the local `item` is in the
 +/// `ignore_locals` set. The type `(usize, &mut String)` can have the second element moved, so it
 +/// isn't always safe to move into a closure when only a single field is needed.
 +///
 +/// When called on the `continue` expression this will return false unless the outer loop expression
 +/// is in the `loop_ids` set.
 +///
 +/// Note that this check is not recursive, so passing the `if` expression will always return true
 +/// even though sub-expressions might return false.
 +pub fn can_move_expr_to_closure_no_visit<'tcx>(
 +    cx: &LateContext<'tcx>,
 +    expr: &'tcx Expr<'_>,
 +    loop_ids: &[HirId],
 +    ignore_locals: &HirIdSet,
 +) -> bool {
 +    match expr.kind {
 +        ExprKind::Break(Destination { target_id: Ok(id), .. }, _)
 +        | ExprKind::Continue(Destination { target_id: Ok(id), .. })
 +            if loop_ids.contains(&id) =>
 +        {
 +            true
 +        },
 +        ExprKind::Break(..)
 +        | ExprKind::Continue(_)
 +        | ExprKind::Ret(_)
 +        | ExprKind::Yield(..)
 +        | ExprKind::InlineAsm(_) => false,
 +        // Accessing a field of a local value can only be done if the type isn't
 +        // partially moved.
 +        ExprKind::Field(
 +            &Expr {
 +                hir_id,
 +                kind:
 +                    ExprKind::Path(QPath::Resolved(
 +                        _,
 +                        Path {
 +                            res: Res::Local(local_id),
 +                            ..
 +                        },
 +                    )),
 +                ..
 +            },
 +            _,
 +        ) if !ignore_locals.contains(local_id) && can_partially_move_ty(cx, cx.typeck_results().node_type(hir_id)) => {
 +            // TODO: check if the local has been partially moved. Assume it has for now.
 +            false
 +        },
 +        _ => true,
 +    }
 +}
 +
 +/// How a local is captured by a closure
 +#[derive(Debug, Clone, Copy, PartialEq, Eq)]
 +pub enum CaptureKind {
 +    Value,
 +    Ref(Mutability),
 +}
 +impl CaptureKind {
 +    pub fn is_imm_ref(self) -> bool {
 +        self == Self::Ref(Mutability::Not)
 +    }
 +}
 +impl std::ops::BitOr for CaptureKind {
 +    type Output = Self;
 +    fn bitor(self, rhs: Self) -> Self::Output {
 +        match (self, rhs) {
 +            (CaptureKind::Value, _) | (_, CaptureKind::Value) => CaptureKind::Value,
 +            (CaptureKind::Ref(Mutability::Mut), CaptureKind::Ref(_))
 +            | (CaptureKind::Ref(_), CaptureKind::Ref(Mutability::Mut)) => CaptureKind::Ref(Mutability::Mut),
 +            (CaptureKind::Ref(Mutability::Not), CaptureKind::Ref(Mutability::Not)) => CaptureKind::Ref(Mutability::Not),
 +        }
 +    }
 +}
 +impl std::ops::BitOrAssign for CaptureKind {
 +    fn bitor_assign(&mut self, rhs: Self) {
 +        *self = *self | rhs;
 +    }
 +}
 +
 +/// Given an expression referencing a local, determines how it would be captured in a closure.
 +/// Note as this will walk up to parent expressions until the capture can be determined it should
 +/// only be used while making a closure somewhere a value is consumed. e.g. a block, match arm, or
 +/// function argument (other than a receiver).
 +pub fn capture_local_usage<'tcx>(cx: &LateContext<'tcx>, e: &Expr<'_>) -> CaptureKind {
 +    fn pat_capture_kind(cx: &LateContext<'_>, pat: &Pat<'_>) -> CaptureKind {
 +        let mut capture = CaptureKind::Ref(Mutability::Not);
 +        pat.each_binding_or_first(&mut |_, id, span, _| match cx
 +            .typeck_results()
 +            .extract_binding_mode(cx.sess(), id, span)
 +            .unwrap()
 +        {
 +            BindingMode::BindByValue(_) if !is_copy(cx, cx.typeck_results().node_type(id)) => {
 +                capture = CaptureKind::Value;
 +            },
 +            BindingMode::BindByReference(Mutability::Mut) if capture != CaptureKind::Value => {
 +                capture = CaptureKind::Ref(Mutability::Mut);
 +            },
 +            _ => (),
 +        });
 +        capture
 +    }
 +
 +    debug_assert!(matches!(
 +        e.kind,
 +        ExprKind::Path(QPath::Resolved(None, Path { res: Res::Local(_), .. }))
 +    ));
 +
 +    let mut child_id = e.hir_id;
 +    let mut capture = CaptureKind::Value;
 +    let mut capture_expr_ty = e;
 +
 +    for (parent_id, parent) in cx.tcx.hir().parent_iter(e.hir_id) {
 +        if let [
 +            Adjustment {
 +                kind: Adjust::Deref(_) | Adjust::Borrow(AutoBorrow::Ref(..)),
 +                target,
 +            },
 +            ref adjust @ ..,
 +        ] = *cx
 +            .typeck_results()
 +            .adjustments()
 +            .get(child_id)
 +            .map_or(&[][..], |x| &**x)
 +        {
 +            if let rustc_ty::RawPtr(TypeAndMut { mutbl: mutability, .. }) | rustc_ty::Ref(_, _, mutability) =
 +                *adjust.last().map_or(target, |a| a.target).kind()
 +            {
 +                return CaptureKind::Ref(mutability);
 +            }
 +        }
 +
 +        match parent {
 +            Node::Expr(e) => match e.kind {
 +                ExprKind::AddrOf(_, mutability, _) => return CaptureKind::Ref(mutability),
 +                ExprKind::Index(..) | ExprKind::Unary(UnOp::Deref, _) => capture = CaptureKind::Ref(Mutability::Not),
 +                ExprKind::Assign(lhs, ..) | ExprKind::Assign(_, lhs, _) if lhs.hir_id == child_id => {
 +                    return CaptureKind::Ref(Mutability::Mut);
 +                },
 +                ExprKind::Field(..) => {
 +                    if capture == CaptureKind::Value {
 +                        capture_expr_ty = e;
 +                    }
 +                },
 +                ExprKind::Let(let_expr) => {
 +                    let mutability = match pat_capture_kind(cx, let_expr.pat) {
 +                        CaptureKind::Value => Mutability::Not,
 +                        CaptureKind::Ref(m) => m,
 +                    };
 +                    return CaptureKind::Ref(mutability);
 +                },
 +                ExprKind::Match(_, arms, _) => {
 +                    let mut mutability = Mutability::Not;
 +                    for capture in arms.iter().map(|arm| pat_capture_kind(cx, arm.pat)) {
 +                        match capture {
 +                            CaptureKind::Value => break,
 +                            CaptureKind::Ref(Mutability::Mut) => mutability = Mutability::Mut,
 +                            CaptureKind::Ref(Mutability::Not) => (),
 +                        }
 +                    }
 +                    return CaptureKind::Ref(mutability);
 +                },
 +                _ => break,
 +            },
 +            Node::Local(l) => match pat_capture_kind(cx, l.pat) {
 +                CaptureKind::Value => break,
 +                capture @ CaptureKind::Ref(_) => return capture,
 +            },
 +            _ => break,
 +        }
 +
 +        child_id = parent_id;
 +    }
 +
 +    if capture == CaptureKind::Value && is_copy(cx, cx.typeck_results().expr_ty(capture_expr_ty)) {
 +        // Copy types are never automatically captured by value.
 +        CaptureKind::Ref(Mutability::Not)
 +    } else {
 +        capture
 +    }
 +}
 +
 +/// Checks if the expression can be moved into a closure as is. This will return a list of captures
 +/// if so, otherwise, `None`.
 +pub fn can_move_expr_to_closure<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) -> Option<HirIdMap<CaptureKind>> {
 +    struct V<'cx, 'tcx> {
 +        cx: &'cx LateContext<'tcx>,
 +        // Stack of potential break targets contained in the expression.
 +        loops: Vec<HirId>,
 +        /// Local variables created in the expression. These don't need to be captured.
 +        locals: HirIdSet,
 +        /// Whether this expression can be turned into a closure.
 +        allow_closure: bool,
 +        /// Locals which need to be captured, and whether they need to be by value, reference, or
 +        /// mutable reference.
 +        captures: HirIdMap<CaptureKind>,
 +    }
 +    impl<'tcx> Visitor<'tcx> for V<'_, 'tcx> {
 +        fn visit_expr(&mut self, e: &'tcx Expr<'_>) {
 +            if !self.allow_closure {
 +                return;
 +            }
 +
 +            match e.kind {
 +                ExprKind::Path(QPath::Resolved(None, &Path { res: Res::Local(l), .. })) => {
 +                    if !self.locals.contains(&l) {
 +                        let cap = capture_local_usage(self.cx, e);
 +                        self.captures.entry(l).and_modify(|e| *e |= cap).or_insert(cap);
 +                    }
 +                },
 +                ExprKind::Closure(..) => {
 +                    let closure_id = self.cx.tcx.hir().local_def_id(e.hir_id).to_def_id();
 +                    for capture in self.cx.typeck_results().closure_min_captures_flattened(closure_id) {
 +                        let local_id = match capture.place.base {
 +                            PlaceBase::Local(id) => id,
 +                            PlaceBase::Upvar(var) => var.var_path.hir_id,
 +                            _ => continue,
 +                        };
 +                        if !self.locals.contains(&local_id) {
 +                            let capture = match capture.info.capture_kind {
 +                                UpvarCapture::ByValue => CaptureKind::Value,
 +                                UpvarCapture::ByRef(kind) => match kind {
 +                                    BorrowKind::ImmBorrow => CaptureKind::Ref(Mutability::Not),
 +                                    BorrowKind::UniqueImmBorrow | BorrowKind::MutBorrow => {
 +                                        CaptureKind::Ref(Mutability::Mut)
 +                                    },
 +                                },
 +                            };
 +                            self.captures
 +                                .entry(local_id)
 +                                .and_modify(|e| *e |= capture)
 +                                .or_insert(capture);
 +                        }
 +                    }
 +                },
 +                ExprKind::Loop(b, ..) => {
 +                    self.loops.push(e.hir_id);
 +                    self.visit_block(b);
 +                    self.loops.pop();
 +                },
 +                _ => {
 +                    self.allow_closure &= can_move_expr_to_closure_no_visit(self.cx, e, &self.loops, &self.locals);
 +                    walk_expr(self, e);
 +                },
 +            }
 +        }
 +
 +        fn visit_pat(&mut self, p: &'tcx Pat<'tcx>) {
 +            p.each_binding_or_first(&mut |_, id, _, _| {
 +                self.locals.insert(id);
 +            });
 +        }
 +    }
 +
 +    let mut v = V {
 +        cx,
 +        allow_closure: true,
 +        loops: Vec::new(),
 +        locals: HirIdSet::default(),
 +        captures: HirIdMap::default(),
 +    };
 +    v.visit_expr(expr);
 +    v.allow_closure.then(|| v.captures)
 +}
 +
 +/// Returns the method names and argument list of nested method call expressions that make up
 +/// `expr`. method/span lists are sorted with the most recent call first.
 +pub fn method_calls<'tcx>(
 +    expr: &'tcx Expr<'tcx>,
 +    max_depth: usize,
 +) -> (Vec<Symbol>, Vec<&'tcx [Expr<'tcx>]>, Vec<Span>) {
 +    let mut method_names = Vec::with_capacity(max_depth);
 +    let mut arg_lists = Vec::with_capacity(max_depth);
 +    let mut spans = Vec::with_capacity(max_depth);
 +
 +    let mut current = expr;
 +    for _ in 0..max_depth {
 +        if let ExprKind::MethodCall(path, args, _) = &current.kind {
 +            if args.iter().any(|e| e.span.from_expansion()) {
 +                break;
 +            }
 +            method_names.push(path.ident.name);
 +            arg_lists.push(&**args);
 +            spans.push(path.ident.span);
 +            current = &args[0];
 +        } else {
 +            break;
 +        }
 +    }
 +
 +    (method_names, arg_lists, spans)
 +}
 +
 +/// Matches an `Expr` against a chain of methods, and return the matched `Expr`s.
 +///
 +/// For example, if `expr` represents the `.baz()` in `foo.bar().baz()`,
 +/// `method_chain_args(expr, &["bar", "baz"])` will return a `Vec`
 +/// containing the `Expr`s for
 +/// `.bar()` and `.baz()`
 +pub fn method_chain_args<'a>(expr: &'a Expr<'_>, methods: &[&str]) -> Option<Vec<&'a [Expr<'a>]>> {
 +    let mut current = expr;
 +    let mut matched = Vec::with_capacity(methods.len());
 +    for method_name in methods.iter().rev() {
 +        // method chains are stored last -> first
 +        if let ExprKind::MethodCall(path, args, _) = current.kind {
 +            if path.ident.name.as_str() == *method_name {
 +                if args.iter().any(|e| e.span.from_expansion()) {
 +                    return None;
 +                }
 +                matched.push(args); // build up `matched` backwards
 +                current = &args[0]; // go to parent expression
 +            } else {
 +                return None;
 +            }
 +        } else {
 +            return None;
 +        }
 +    }
 +    // Reverse `matched` so that it is in the same order as `methods`.
 +    matched.reverse();
 +    Some(matched)
 +}
 +
 +/// Returns `true` if the provided `def_id` is an entrypoint to a program.
 +pub fn is_entrypoint_fn(cx: &LateContext<'_>, def_id: DefId) -> bool {
 +    cx.tcx
 +        .entry_fn(())
 +        .map_or(false, |(entry_fn_def_id, _)| def_id == entry_fn_def_id)
 +}
 +
 +/// Returns `true` if the expression is in the program's `#[panic_handler]`.
 +pub fn is_in_panic_handler(cx: &LateContext<'_>, e: &Expr<'_>) -> bool {
 +    let parent = cx.tcx.hir().get_parent_item(e.hir_id);
 +    Some(parent.to_def_id()) == cx.tcx.lang_items().panic_impl()
 +}
 +
 +/// Gets the name of the item the expression is in, if available.
 +pub fn get_item_name(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option<Symbol> {
 +    let parent_id = cx.tcx.hir().get_parent_item(expr.hir_id);
 +    match cx.tcx.hir().find_by_def_id(parent_id) {
 +        Some(
 +            Node::Item(Item { ident, .. })
 +            | Node::TraitItem(TraitItem { ident, .. })
 +            | Node::ImplItem(ImplItem { ident, .. }),
 +        ) => Some(ident.name),
 +        _ => None,
 +    }
 +}
 +
 +pub struct ContainsName {
 +    pub name: Symbol,
 +    pub result: bool,
 +}
 +
 +impl<'tcx> Visitor<'tcx> for ContainsName {
 +    fn visit_name(&mut self, _: Span, name: Symbol) {
 +        if self.name == name {
 +            self.result = true;
 +        }
 +    }
 +}
 +
 +/// Checks if an `Expr` contains a certain name.
 +pub fn contains_name(name: Symbol, expr: &Expr<'_>) -> bool {
 +    let mut cn = ContainsName { name, result: false };
 +    cn.visit_expr(expr);
 +    cn.result
 +}
 +
 +/// Returns `true` if `expr` contains a return expression
 +pub fn contains_return(expr: &hir::Expr<'_>) -> bool {
 +    let mut found = false;
 +    expr_visitor_no_bodies(|expr| {
 +        if !found {
 +            if let hir::ExprKind::Ret(..) = &expr.kind {
 +                found = true;
 +            }
 +        }
 +        !found
 +    })
 +    .visit_expr(expr);
 +    found
 +}
 +
 +/// Extends the span to the beginning of the spans line, incl. whitespaces.
 +///
 +/// ```rust
 +///        let x = ();
 +/// //             ^^
 +/// // will be converted to
 +///        let x = ();
 +/// // ^^^^^^^^^^^^^^
 +/// ```
 +fn line_span<T: LintContext>(cx: &T, span: Span) -> Span {
 +    let span = original_sp(span, DUMMY_SP);
 +    let source_map_and_line = cx.sess().source_map().lookup_line(span.lo()).unwrap();
 +    let line_no = source_map_and_line.line;
 +    let line_start = source_map_and_line.sf.lines[line_no];
 +    span.with_lo(line_start)
 +}
 +
 +/// Gets the parent node, if any.
 +pub fn get_parent_node(tcx: TyCtxt<'_>, id: HirId) -> Option<Node<'_>> {
 +    tcx.hir().parent_iter(id).next().map(|(_, node)| node)
 +}
 +
 +/// Gets the parent expression, if any –- this is useful to constrain a lint.
 +pub fn get_parent_expr<'tcx>(cx: &LateContext<'tcx>, e: &Expr<'_>) -> Option<&'tcx Expr<'tcx>> {
 +    get_parent_expr_for_hir(cx, e.hir_id)
 +}
 +
 +/// This retrieves the parent for the given `HirId` if it's an expression. This is useful for
 +/// constraint lints
 +pub fn get_parent_expr_for_hir<'tcx>(cx: &LateContext<'tcx>, hir_id: hir::HirId) -> Option<&'tcx Expr<'tcx>> {
 +    match get_parent_node(cx.tcx, hir_id) {
 +        Some(Node::Expr(parent)) => Some(parent),
 +        _ => None,
 +    }
 +}
 +
 +pub fn get_enclosing_block<'tcx>(cx: &LateContext<'tcx>, hir_id: HirId) -> Option<&'tcx Block<'tcx>> {
 +    let map = &cx.tcx.hir();
 +    let enclosing_node = map
 +        .get_enclosing_scope(hir_id)
 +        .and_then(|enclosing_id| map.find(enclosing_id));
 +    enclosing_node.and_then(|node| match node {
 +        Node::Block(block) => Some(block),
 +        Node::Item(&Item {
 +            kind: ItemKind::Fn(_, _, eid),
 +            ..
 +        })
 +        | Node::ImplItem(&ImplItem {
 +            kind: ImplItemKind::Fn(_, eid),
 +            ..
 +        }) => match cx.tcx.hir().body(eid).value.kind {
 +            ExprKind::Block(block, _) => Some(block),
 +            _ => None,
 +        },
 +        _ => None,
 +    })
 +}
 +
 +/// Gets the loop or closure enclosing the given expression, if any.
 +pub fn get_enclosing_loop_or_closure<'tcx>(tcx: TyCtxt<'tcx>, expr: &Expr<'_>) -> Option<&'tcx Expr<'tcx>> {
 +    for (_, node) in tcx.hir().parent_iter(expr.hir_id) {
 +        match node {
 +            Node::Expr(
 +                e @ Expr {
 +                    kind: ExprKind::Loop(..) | ExprKind::Closure(..),
 +                    ..
 +                },
 +            ) => return Some(e),
 +            Node::Expr(_) | Node::Stmt(_) | Node::Block(_) | Node::Local(_) | Node::Arm(_) => (),
 +            _ => break,
 +        }
 +    }
 +    None
 +}
 +
 +/// Gets the parent node if it's an impl block.
 +pub fn get_parent_as_impl(tcx: TyCtxt<'_>, id: HirId) -> Option<&Impl<'_>> {
 +    match tcx.hir().parent_iter(id).next() {
 +        Some((
 +            _,
 +            Node::Item(Item {
 +                kind: ItemKind::Impl(imp),
 +                ..
 +            }),
 +        )) => Some(imp),
 +        _ => None,
 +    }
 +}
 +
 +/// Removes blocks around an expression, only if the block contains just one expression
 +/// and no statements. Unsafe blocks are not removed.
 +///
 +/// Examples:
 +///  * `{}`               -> `{}`
 +///  * `{ x }`            -> `x`
 +///  * `{{ x }}`          -> `x`
 +///  * `{ x; }`           -> `{ x; }`
 +///  * `{ x; y }`         -> `{ x; y }`
 +///  * `{ unsafe { x } }` -> `unsafe { x }`
 +pub fn peel_blocks<'a>(mut expr: &'a Expr<'a>) -> &'a Expr<'a> {
 +    while let ExprKind::Block(
 +        Block {
 +            stmts: [],
 +            expr: Some(inner),
 +            rules: BlockCheckMode::DefaultBlock,
 +            ..
 +        },
 +        _,
 +    ) = expr.kind
 +    {
 +        expr = inner;
 +    }
 +    expr
 +}
 +
 +/// Removes blocks around an expression, only if the block contains just one expression
 +/// or just one expression statement with a semicolon. Unsafe blocks are not removed.
 +///
 +/// Examples:
 +///  * `{}`               -> `{}`
 +///  * `{ x }`            -> `x`
 +///  * `{ x; }`           -> `x`
 +///  * `{{ x; }}`         -> `x`
 +///  * `{ x; y }`         -> `{ x; y }`
 +///  * `{ unsafe { x } }` -> `unsafe { x }`
 +pub fn peel_blocks_with_stmt<'a>(mut expr: &'a Expr<'a>) -> &'a Expr<'a> {
 +    while let ExprKind::Block(
 +        Block {
 +            stmts: [],
 +            expr: Some(inner),
 +            rules: BlockCheckMode::DefaultBlock,
 +            ..
 +        }
 +        | Block {
 +            stmts:
 +                [
 +                    Stmt {
 +                        kind: StmtKind::Expr(inner) | StmtKind::Semi(inner),
 +                        ..
 +                    },
 +                ],
 +            expr: None,
 +            rules: BlockCheckMode::DefaultBlock,
 +            ..
 +        },
 +        _,
 +    ) = expr.kind
 +    {
 +        expr = inner;
 +    }
 +    expr
 +}
 +
 +/// Checks if the given expression is the else clause of either an `if` or `if let` expression.
 +pub fn is_else_clause(tcx: TyCtxt<'_>, expr: &Expr<'_>) -> bool {
 +    let mut iter = tcx.hir().parent_iter(expr.hir_id);
 +    match iter.next() {
 +        Some((
 +            _,
 +            Node::Expr(Expr {
 +                kind: ExprKind::If(_, _, Some(else_expr)),
 +                ..
 +            }),
 +        )) => else_expr.hir_id == expr.hir_id,
 +        _ => false,
 +    }
 +}
 +
 +/// Checks whether the given expression is a constant integer of the given value.
 +/// unlike `is_integer_literal`, this version does const folding
 +pub fn is_integer_const(cx: &LateContext<'_>, e: &Expr<'_>, value: u128) -> bool {
 +    if is_integer_literal(e, value) {
 +        return true;
 +    }
 +    let enclosing_body = cx.tcx.hir().local_def_id(cx.tcx.hir().enclosing_body_owner(e.hir_id));
 +    if let Some((Constant::Int(v), _)) = constant(cx, cx.tcx.typeck(enclosing_body), e) {
 +        return value == v;
 +    }
 +    false
 +}
 +
 +/// Checks whether the given expression is a constant literal of the given value.
 +pub fn is_integer_literal(expr: &Expr<'_>, value: u128) -> bool {
 +    // FIXME: use constant folding
 +    if let ExprKind::Lit(ref spanned) = expr.kind {
 +        if let LitKind::Int(v, _) = spanned.node {
 +            return v == value;
 +        }
 +    }
 +    false
 +}
 +
 +/// Returns `true` if the given `Expr` has been coerced before.
 +///
 +/// Examples of coercions can be found in the Nomicon at
 +/// <https://doc.rust-lang.org/nomicon/coercions.html>.
 +///
 +/// See `rustc_middle::ty::adjustment::Adjustment` and `rustc_typeck::check::coercion` for more
 +/// information on adjustments and coercions.
 +pub fn is_adjusted(cx: &LateContext<'_>, e: &Expr<'_>) -> bool {
 +    cx.typeck_results().adjustments().get(e.hir_id).is_some()
 +}
 +
 +/// Returns the pre-expansion span if this comes from an expansion of the
 +/// macro `name`.
 +/// See also [`is_direct_expn_of`].
 +#[must_use]
 +pub fn is_expn_of(mut span: Span, name: &str) -> Option<Span> {
 +    loop {
 +        if span.from_expansion() {
 +            let data = span.ctxt().outer_expn_data();
 +            let new_span = data.call_site;
 +
 +            if let ExpnKind::Macro(MacroKind::Bang, mac_name) = data.kind {
 +                if mac_name.as_str() == name {
 +                    return Some(new_span);
 +                }
 +            }
 +
 +            span = new_span;
 +        } else {
 +            return None;
 +        }
 +    }
 +}
 +
 +/// Returns the pre-expansion span if the span directly comes from an expansion
 +/// of the macro `name`.
 +/// The difference with [`is_expn_of`] is that in
 +/// ```rust
 +/// # macro_rules! foo { ($name:tt!$args:tt) => { $name!$args } }
 +/// # macro_rules! bar { ($e:expr) => { $e } }
 +/// foo!(bar!(42));
 +/// ```
 +/// `42` is considered expanded from `foo!` and `bar!` by `is_expn_of` but only
 +/// from `bar!` by `is_direct_expn_of`.
 +#[must_use]
 +pub fn is_direct_expn_of(span: Span, name: &str) -> Option<Span> {
 +    if span.from_expansion() {
 +        let data = span.ctxt().outer_expn_data();
 +        let new_span = data.call_site;
 +
 +        if let ExpnKind::Macro(MacroKind::Bang, mac_name) = data.kind {
 +            if mac_name.as_str() == name {
 +                return Some(new_span);
 +            }
 +        }
 +    }
 +
 +    None
 +}
 +
 +/// Convenience function to get the return type of a function.
 +pub fn return_ty<'tcx>(cx: &LateContext<'tcx>, fn_item: hir::HirId) -> Ty<'tcx> {
 +    let fn_def_id = cx.tcx.hir().local_def_id(fn_item);
 +    let ret_ty = cx.tcx.fn_sig(fn_def_id).output();
 +    cx.tcx.erase_late_bound_regions(ret_ty)
 +}
 +
 +/// Convenience function to get the nth argument type of a function.
 +pub fn nth_arg<'tcx>(cx: &LateContext<'tcx>, fn_item: hir::HirId, nth: usize) -> Ty<'tcx> {
 +    let fn_def_id = cx.tcx.hir().local_def_id(fn_item);
 +    let arg = cx.tcx.fn_sig(fn_def_id).input(nth);
 +    cx.tcx.erase_late_bound_regions(arg)
 +}
 +
 +/// Checks if an expression is constructing a tuple-like enum variant or struct
 +pub fn is_ctor_or_promotable_const_function(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
 +    if let ExprKind::Call(fun, _) = expr.kind {
 +        if let ExprKind::Path(ref qp) = fun.kind {
 +            let res = cx.qpath_res(qp, fun.hir_id);
 +            return match res {
 +                def::Res::Def(DefKind::Variant | DefKind::Ctor(..), ..) => true,
 +                def::Res::Def(_, def_id) => cx.tcx.is_promotable_const_fn(def_id),
 +                _ => false,
 +            };
 +        }
 +    }
 +    false
 +}
 +
 +/// Returns `true` if a pattern is refutable.
 +// TODO: should be implemented using rustc/mir_build/thir machinery
 +pub fn is_refutable(cx: &LateContext<'_>, pat: &Pat<'_>) -> bool {
 +    fn is_enum_variant(cx: &LateContext<'_>, qpath: &QPath<'_>, id: HirId) -> bool {
 +        matches!(
 +            cx.qpath_res(qpath, id),
 +            def::Res::Def(DefKind::Variant, ..) | Res::Def(DefKind::Ctor(def::CtorOf::Variant, _), _)
 +        )
 +    }
 +
 +    fn are_refutable<'a, I: IntoIterator<Item = &'a Pat<'a>>>(cx: &LateContext<'_>, i: I) -> bool {
 +        i.into_iter().any(|pat| is_refutable(cx, pat))
 +    }
 +
 +    match pat.kind {
 +        PatKind::Wild => false,
 +        PatKind::Binding(_, _, _, pat) => pat.map_or(false, |pat| is_refutable(cx, pat)),
 +        PatKind::Box(pat) | PatKind::Ref(pat, _) => is_refutable(cx, pat),
 +        PatKind::Lit(..) | PatKind::Range(..) => true,
 +        PatKind::Path(ref qpath) => is_enum_variant(cx, qpath, pat.hir_id),
 +        PatKind::Or(pats) => {
 +            // TODO: should be the honest check, that pats is exhaustive set
 +            are_refutable(cx, pats)
 +        },
 +        PatKind::Tuple(pats, _) => are_refutable(cx, pats),
 +        PatKind::Struct(ref qpath, fields, _) => {
 +            is_enum_variant(cx, qpath, pat.hir_id) || are_refutable(cx, fields.iter().map(|field| &*field.pat))
 +        },
 +        PatKind::TupleStruct(ref qpath, pats, _) => is_enum_variant(cx, qpath, pat.hir_id) || are_refutable(cx, pats),
 +        PatKind::Slice(head, middle, tail) => {
 +            match &cx.typeck_results().node_type(pat.hir_id).kind() {
 +                rustc_ty::Slice(..) => {
 +                    // [..] is the only irrefutable slice pattern.
 +                    !head.is_empty() || middle.is_none() || !tail.is_empty()
 +                },
 +                rustc_ty::Array(..) => are_refutable(cx, head.iter().chain(middle).chain(tail.iter())),
 +                _ => {
 +                    // unreachable!()
 +                    true
 +                },
 +            }
 +        },
 +    }
 +}
 +
 +/// If the pattern is an `or` pattern, call the function once for each sub pattern. Otherwise, call
 +/// the function once on the given pattern.
 +pub fn recurse_or_patterns<'tcx, F: FnMut(&'tcx Pat<'tcx>)>(pat: &'tcx Pat<'tcx>, mut f: F) {
 +    if let PatKind::Or(pats) = pat.kind {
 +        pats.iter().for_each(f);
 +    } else {
 +        f(pat);
 +    }
 +}
 +
 +/// Checks for the `#[automatically_derived]` attribute all `#[derive]`d
 +/// implementations have.
 +pub fn is_automatically_derived(attrs: &[ast::Attribute]) -> bool {
 +    has_attr(attrs, sym::automatically_derived)
 +}
 +
 +pub fn is_self(slf: &Param<'_>) -> bool {
 +    if let PatKind::Binding(.., name, _) = slf.pat.kind {
 +        name.name == kw::SelfLower
 +    } else {
 +        false
 +    }
 +}
 +
 +pub fn is_self_ty(slf: &hir::Ty<'_>) -> bool {
 +    if let TyKind::Path(QPath::Resolved(None, path)) = slf.kind {
 +        if let Res::SelfTy(..) = path.res {
 +            return true;
 +        }
 +    }
 +    false
 +}
 +
 +pub fn iter_input_pats<'tcx>(decl: &FnDecl<'_>, body: &'tcx Body<'_>) -> impl Iterator<Item = &'tcx Param<'tcx>> {
 +    (0..decl.inputs.len()).map(move |i| &body.params[i])
 +}
 +
 +/// Checks if a given expression is a match expression expanded from the `?`
 +/// operator or the `try` macro.
 +pub fn is_try<'tcx>(cx: &LateContext<'_>, expr: &'tcx Expr<'tcx>) -> Option<&'tcx Expr<'tcx>> {
 +    fn is_ok(cx: &LateContext<'_>, arm: &Arm<'_>) -> bool {
 +        if_chain! {
 +            if let PatKind::TupleStruct(ref path, pat, None) = arm.pat.kind;
 +            if is_lang_ctor(cx, path, ResultOk);
 +            if let PatKind::Binding(_, hir_id, _, None) = pat[0].kind;
 +            if path_to_local_id(arm.body, hir_id);
 +            then {
 +                return true;
 +            }
 +        }
 +        false
 +    }
 +
 +    fn is_err(cx: &LateContext<'_>, arm: &Arm<'_>) -> bool {
 +        if let PatKind::TupleStruct(ref path, _, _) = arm.pat.kind {
 +            is_lang_ctor(cx, path, ResultErr)
 +        } else {
 +            false
 +        }
 +    }
 +
 +    if let ExprKind::Match(_, arms, ref source) = expr.kind {
 +        // desugared from a `?` operator
 +        if *source == MatchSource::TryDesugar {
 +            return Some(expr);
 +        }
 +
 +        if_chain! {
 +            if arms.len() == 2;
 +            if arms[0].guard.is_none();
 +            if arms[1].guard.is_none();
 +            if (is_ok(cx, &arms[0]) && is_err(cx, &arms[1])) ||
 +                (is_ok(cx, &arms[1]) && is_err(cx, &arms[0]));
 +            then {
 +                return Some(expr);
 +            }
 +        }
 +    }
 +
 +    None
 +}
 +
 +/// Returns `true` if the lint is allowed in the current context
 +///
 +/// Useful for skipping long running code when it's unnecessary
 +pub fn is_lint_allowed(cx: &LateContext<'_>, lint: &'static Lint, id: HirId) -> bool {
 +    cx.tcx.lint_level_at_node(lint, id).0 == Level::Allow
 +}
 +
 +pub fn strip_pat_refs<'hir>(mut pat: &'hir Pat<'hir>) -> &'hir Pat<'hir> {
 +    while let PatKind::Ref(subpat, _) = pat.kind {
 +        pat = subpat;
 +    }
 +    pat
 +}
 +
 +pub fn int_bits(tcx: TyCtxt<'_>, ity: rustc_ty::IntTy) -> u64 {
 +    Integer::from_int_ty(&tcx, ity).size().bits()
 +}
 +
 +#[allow(clippy::cast_possible_wrap)]
 +/// Turn a constant int byte representation into an i128
 +pub fn sext(tcx: TyCtxt<'_>, u: u128, ity: rustc_ty::IntTy) -> i128 {
 +    let amt = 128 - int_bits(tcx, ity);
 +    ((u as i128) << amt) >> amt
 +}
 +
 +#[allow(clippy::cast_sign_loss)]
 +/// clip unused bytes
 +pub fn unsext(tcx: TyCtxt<'_>, u: i128, ity: rustc_ty::IntTy) -> u128 {
 +    let amt = 128 - int_bits(tcx, ity);
 +    ((u as u128) << amt) >> amt
 +}
 +
 +/// clip unused bytes
 +pub fn clip(tcx: TyCtxt<'_>, u: u128, ity: rustc_ty::UintTy) -> u128 {
 +    let bits = Integer::from_uint_ty(&tcx, ity).size().bits();
 +    let amt = 128 - bits;
 +    (u << amt) >> amt
 +}
 +
 +pub fn has_attr(attrs: &[ast::Attribute], symbol: Symbol) -> bool {
 +    attrs.iter().any(|attr| attr.has_name(symbol))
 +}
 +
 +pub fn any_parent_has_attr(tcx: TyCtxt<'_>, node: HirId, symbol: Symbol) -> bool {
 +    let map = &tcx.hir();
 +    let mut prev_enclosing_node = None;
 +    let mut enclosing_node = node;
 +    while Some(enclosing_node) != prev_enclosing_node {
 +        if has_attr(map.attrs(enclosing_node), symbol) {
 +            return true;
 +        }
 +        prev_enclosing_node = Some(enclosing_node);
 +        enclosing_node = map.local_def_id_to_hir_id(map.get_parent_item(enclosing_node));
 +    }
 +
 +    false
 +}
 +
 +pub fn any_parent_is_automatically_derived(tcx: TyCtxt<'_>, node: HirId) -> bool {
 +    any_parent_has_attr(tcx, node, sym::automatically_derived)
 +}
 +
 +/// Matches a function call with the given path and returns the arguments.
 +///
 +/// Usage:
 +///
 +/// ```rust,ignore
 +/// if let Some(args) = match_function_call(cx, cmp_max_call, &paths::CMP_MAX);
 +/// ```
 +pub fn match_function_call<'tcx>(
 +    cx: &LateContext<'tcx>,
 +    expr: &'tcx Expr<'_>,
 +    path: &[&str],
 +) -> Option<&'tcx [Expr<'tcx>]> {
 +    if_chain! {
 +        if let ExprKind::Call(fun, args) = expr.kind;
 +        if let ExprKind::Path(ref qpath) = fun.kind;
 +        if let Some(fun_def_id) = cx.qpath_res(qpath, fun.hir_id).opt_def_id();
 +        if match_def_path(cx, fun_def_id, path);
 +        then {
 +            return Some(args)
 +        }
 +    };
 +    None
 +}
 +
 +/// Checks if the given `DefId` matches any of the paths. Returns the index of matching path, if
 +/// any.
 +///
 +/// Please use `match_any_diagnostic_items` if the targets are all diagnostic items.
 +pub fn match_any_def_paths(cx: &LateContext<'_>, did: DefId, paths: &[&[&str]]) -> Option<usize> {
 +    let search_path = cx.get_def_path(did);
 +    paths
 +        .iter()
 +        .position(|p| p.iter().map(|x| Symbol::intern(x)).eq(search_path.iter().copied()))
 +}
 +
 +/// Checks if the given `DefId` matches any of provided diagnostic items. Returns the index of
 +/// matching path, if any.
 +pub fn match_any_diagnostic_items(cx: &LateContext<'_>, def_id: DefId, diag_items: &[Symbol]) -> Option<usize> {
 +    diag_items
 +        .iter()
 +        .position(|item| cx.tcx.is_diagnostic_item(*item, def_id))
 +}
 +
 +/// Checks if the given `DefId` matches the path.
 +pub fn match_def_path<'tcx>(cx: &LateContext<'tcx>, did: DefId, syms: &[&str]) -> bool {
 +    // We should probably move to Symbols in Clippy as well rather than interning every time.
 +    let path = cx.get_def_path(did);
 +    syms.iter().map(|x| Symbol::intern(x)).eq(path.iter().copied())
 +}
 +
 +/// Checks if the given `DefId` matches the `libc` item.
 +pub fn match_libc_symbol(cx: &LateContext<'_>, did: DefId, name: &str) -> bool {
 +    let path = cx.get_def_path(did);
 +    // libc is meant to be used as a flat list of names, but they're all actually defined in different
 +    // modules based on the target platform. Ignore everything but crate name and the item name.
 +    path.first().map_or(false, |s| s.as_str() == "libc") && path.last().map_or(false, |s| s.as_str() == name)
 +}
 +
 +/// Returns the list of condition expressions and the list of blocks in a
 +/// sequence of `if/else`.
 +/// E.g., this returns `([a, b], [c, d, e])` for the expression
 +/// `if a { c } else if b { d } else { e }`.
 +pub fn if_sequence<'tcx>(mut expr: &'tcx Expr<'tcx>) -> (Vec<&'tcx Expr<'tcx>>, Vec<&'tcx Block<'tcx>>) {
 +    let mut conds = Vec::new();
 +    let mut blocks: Vec<&Block<'_>> = Vec::new();
 +
 +    while let Some(higher::IfOrIfLet { cond, then, r#else }) = higher::IfOrIfLet::hir(expr) {
 +        conds.push(&*cond);
 +        if let ExprKind::Block(block, _) = then.kind {
 +            blocks.push(block);
 +        } else {
 +            panic!("ExprKind::If node is not an ExprKind::Block");
 +        }
 +
 +        if let Some(else_expr) = r#else {
 +            expr = else_expr;
 +        } else {
 +            break;
 +        }
 +    }
 +
 +    // final `else {..}`
 +    if !blocks.is_empty() {
 +        if let ExprKind::Block(block, _) = expr.kind {
 +            blocks.push(block);
 +        }
 +    }
 +
 +    (conds, blocks)
 +}
 +
 +/// Checks if the given function kind is an async function.
 +pub fn is_async_fn(kind: FnKind<'_>) -> bool {
 +    matches!(kind, FnKind::ItemFn(_, _, header, _) if header.asyncness == IsAsync::Async)
 +}
 +
 +/// Peels away all the compiler generated code surrounding the body of an async function,
 +pub fn get_async_fn_body<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'_>) -> Option<&'tcx Expr<'tcx>> {
 +    if let ExprKind::Call(
 +        _,
 +        &[
 +            Expr {
 +                kind: ExprKind::Closure(_, _, body, _, _),
 +                ..
 +            },
 +        ],
 +    ) = body.value.kind
 +    {
 +        if let ExprKind::Block(
 +            Block {
 +                stmts: [],
 +                expr:
 +                    Some(Expr {
 +                        kind: ExprKind::DropTemps(expr),
 +                        ..
 +                    }),
 +                ..
 +            },
 +            _,
 +        ) = tcx.hir().body(body).value.kind
 +        {
 +            return Some(expr);
 +        }
 +    };
 +    None
 +}
 +
 +// Finds the `#[must_use]` attribute, if any
 +pub fn must_use_attr(attrs: &[Attribute]) -> Option<&Attribute> {
 +    attrs.iter().find(|a| a.has_name(sym::must_use))
 +}
 +
 +// check if expr is calling method or function with #[must_use] attribute
 +pub fn is_must_use_func_call(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
 +    let did = match expr.kind {
 +        ExprKind::Call(path, _) => if_chain! {
 +            if let ExprKind::Path(ref qpath) = path.kind;
 +            if let def::Res::Def(_, did) = cx.qpath_res(qpath, path.hir_id);
 +            then {
 +                Some(did)
 +            } else {
 +                None
 +            }
 +        },
 +        ExprKind::MethodCall(..) => cx.typeck_results().type_dependent_def_id(expr.hir_id),
 +        _ => None,
 +    };
 +
 +    did.map_or(false, |did| must_use_attr(cx.tcx.get_attrs(did)).is_some())
 +}
 +
 +/// Checks if an expression represents the identity function
 +/// Only examines closures and `std::convert::identity`
 +pub fn is_expr_identity_function(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
 +    /// Checks if a function's body represents the identity function. Looks for bodies of the form:
 +    /// * `|x| x`
 +    /// * `|x| return x`
 +    /// * `|x| { return x }`
 +    /// * `|x| { return x; }`
 +    fn is_body_identity_function(cx: &LateContext<'_>, func: &Body<'_>) -> bool {
 +        let id = if_chain! {
 +            if let [param] = func.params;
 +            if let PatKind::Binding(_, id, _, _) = param.pat.kind;
 +            then {
 +                id
 +            } else {
 +                return false;
 +            }
 +        };
 +
 +        let mut expr = &func.value;
 +        loop {
 +            match expr.kind {
 +                #[rustfmt::skip]
 +                ExprKind::Block(&Block { stmts: [], expr: Some(e), .. }, _, )
 +                | ExprKind::Ret(Some(e)) => expr = e,
 +                #[rustfmt::skip]
 +                ExprKind::Block(&Block { stmts: [stmt], expr: None, .. }, _) => {
 +                    if_chain! {
 +                        if let StmtKind::Semi(e) | StmtKind::Expr(e) = stmt.kind;
 +                        if let ExprKind::Ret(Some(ret_val)) = e.kind;
 +                        then {
 +                            expr = ret_val;
 +                        } else {
 +                            return false;
 +                        }
 +                    }
 +                },
 +                _ => return path_to_local_id(expr, id) && cx.typeck_results().expr_adjustments(expr).is_empty(),
 +            }
 +        }
 +    }
 +
 +    match expr.kind {
 +        ExprKind::Closure(_, _, body_id, _, _) => is_body_identity_function(cx, cx.tcx.hir().body(body_id)),
 +        ExprKind::Path(ref path) => is_qpath_def_path(cx, path, expr.hir_id, &paths::CONVERT_IDENTITY),
 +        _ => false,
 +    }
 +}
 +
 +/// Gets the node where an expression is either used, or it's type is unified with another branch.
-                 _ => break Some(Node::Expr(expr)),
++/// Returns both the node and the `HirId` of the closest child node.
++pub fn get_expr_use_or_unification_node<'tcx>(tcx: TyCtxt<'tcx>, expr: &Expr<'_>) -> Option<(Node<'tcx>, HirId)> {
 +    let mut child_id = expr.hir_id;
 +    let mut iter = tcx.hir().parent_iter(child_id);
 +    loop {
 +        match iter.next() {
 +            None => break None,
 +            Some((id, Node::Block(_))) => child_id = id,
 +            Some((id, Node::Arm(arm))) if arm.body.hir_id == child_id => child_id = id,
 +            Some((_, Node::Expr(expr))) => match expr.kind {
 +                ExprKind::Match(_, [arm], _) if arm.hir_id == child_id => child_id = expr.hir_id,
 +                ExprKind::Block(..) | ExprKind::DropTemps(_) => child_id = expr.hir_id,
 +                ExprKind::If(_, then_expr, None) if then_expr.hir_id == child_id => break None,
-             Some((_, node)) => break Some(node),
++                _ => break Some((Node::Expr(expr), child_id)),
 +            },
-         None | Some(Node::Stmt(Stmt {
-             kind: StmtKind::Expr(_)
-                 | StmtKind::Semi(_)
-                 | StmtKind::Local(Local {
-                     pat: Pat {
-                         kind: PatKind::Wild,
++            Some((_, node)) => break Some((node, child_id)),
 +        }
 +    }
 +}
 +
 +/// Checks if the result of an expression is used, or it's type is unified with another branch.
 +pub fn is_expr_used_or_unified(tcx: TyCtxt<'_>, expr: &Expr<'_>) -> bool {
 +    !matches!(
 +        get_expr_use_or_unification_node(tcx, expr),
-                     },
-                     ..
-                 }),
-             ..
-         }))
++        None | Some((
++            Node::Stmt(Stmt {
++                kind: StmtKind::Expr(_)
++                    | StmtKind::Semi(_)
++                    | StmtKind::Local(Local {
++                        pat: Pat {
++                            kind: PatKind::Wild,
++                            ..
++                        },
 +                        ..
++                    }),
++                ..
++            }),
++            _
++        ))
 +    )
 +}
 +
 +/// Checks if the expression is the final expression returned from a block.
 +pub fn is_expr_final_block_expr(tcx: TyCtxt<'_>, expr: &Expr<'_>) -> bool {
 +    matches!(get_parent_node(tcx, expr.hir_id), Some(Node::Block(..)))
 +}
 +
 +pub fn std_or_core(cx: &LateContext<'_>) -> Option<&'static str> {
 +    if !is_no_std_crate(cx) {
 +        Some("std")
 +    } else if !is_no_core_crate(cx) {
 +        Some("core")
 +    } else {
 +        None
 +    }
 +}
 +
 +pub fn is_no_std_crate(cx: &LateContext<'_>) -> bool {
 +    cx.tcx.hir().attrs(hir::CRATE_HIR_ID).iter().any(|attr| {
 +        if let ast::AttrKind::Normal(ref attr, _) = attr.kind {
 +            attr.path == sym::no_std
 +        } else {
 +            false
 +        }
 +    })
 +}
 +
 +pub fn is_no_core_crate(cx: &LateContext<'_>) -> bool {
 +    cx.tcx.hir().attrs(hir::CRATE_HIR_ID).iter().any(|attr| {
 +        if let ast::AttrKind::Normal(ref attr, _) = attr.kind {
 +            attr.path == sym::no_core
 +        } else {
 +            false
 +        }
 +    })
 +}
 +
 +/// Check if parent of a hir node is a trait implementation block.
 +/// For example, `f` in
 +/// ```rust
 +/// # struct S;
 +/// # trait Trait { fn f(); }
 +/// impl Trait for S {
 +///     fn f() {}
 +/// }
 +/// ```
 +pub fn is_trait_impl_item(cx: &LateContext<'_>, hir_id: HirId) -> bool {
 +    if let Some(Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_node(hir_id)) {
 +        matches!(item.kind, ItemKind::Impl(hir::Impl { of_trait: Some(_), .. }))
 +    } else {
 +        false
 +    }
 +}
 +
 +/// Check if it's even possible to satisfy the `where` clause for the item.
 +///
 +/// `trivial_bounds` feature allows functions with unsatisfiable bounds, for example:
 +///
 +/// ```ignore
 +/// fn foo() where i32: Iterator {
 +///     for _ in 2i32 {}
 +/// }
 +/// ```
 +pub fn fn_has_unsatisfiable_preds(cx: &LateContext<'_>, did: DefId) -> bool {
 +    use rustc_trait_selection::traits;
 +    let predicates = cx
 +        .tcx
 +        .predicates_of(did)
 +        .predicates
 +        .iter()
 +        .filter_map(|(p, _)| if p.is_global() { Some(*p) } else { None });
 +    traits::impossible_predicates(
 +        cx.tcx,
 +        traits::elaborate_predicates(cx.tcx, predicates)
 +            .map(|o| o.predicate)
 +            .collect::<Vec<_>>(),
 +    )
 +}
 +
 +/// Returns the `DefId` of the callee if the given expression is a function or method call.
 +pub fn fn_def_id(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option<DefId> {
 +    match &expr.kind {
 +        ExprKind::MethodCall(..) => cx.typeck_results().type_dependent_def_id(expr.hir_id),
 +        ExprKind::Call(
 +            Expr {
 +                kind: ExprKind::Path(qpath),
 +                hir_id: path_hir_id,
 +                ..
 +            },
 +            ..,
 +        ) => cx.typeck_results().qpath_res(qpath, *path_hir_id).opt_def_id(),
 +        _ => None,
 +    }
 +}
 +
 +/// Returns Option<String> where String is a textual representation of the type encapsulated in the
 +/// slice iff the given expression is a slice of primitives (as defined in the
 +/// `is_recursively_primitive_type` function) and None otherwise.
 +pub fn is_slice_of_primitives(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option<String> {
 +    let expr_type = cx.typeck_results().expr_ty_adjusted(expr);
 +    let expr_kind = expr_type.kind();
 +    let is_primitive = match expr_kind {
 +        rustc_ty::Slice(element_type) => is_recursively_primitive_type(element_type),
 +        rustc_ty::Ref(_, inner_ty, _) if matches!(inner_ty.kind(), &rustc_ty::Slice(_)) => {
 +            if let rustc_ty::Slice(element_type) = inner_ty.kind() {
 +                is_recursively_primitive_type(element_type)
 +            } else {
 +                unreachable!()
 +            }
 +        },
 +        _ => false,
 +    };
 +
 +    if is_primitive {
 +        // if we have wrappers like Array, Slice or Tuple, print these
 +        // and get the type enclosed in the slice ref
 +        match expr_type.peel_refs().walk().nth(1).unwrap().expect_ty().kind() {
 +            rustc_ty::Slice(..) => return Some("slice".into()),
 +            rustc_ty::Array(..) => return Some("array".into()),
 +            rustc_ty::Tuple(..) => return Some("tuple".into()),
 +            _ => {
 +                // is_recursively_primitive_type() should have taken care
 +                // of the rest and we can rely on the type that is found
 +                let refs_peeled = expr_type.peel_refs();
 +                return Some(refs_peeled.walk().last().unwrap().to_string());
 +            },
 +        }
 +    }
 +    None
 +}
 +
 +/// returns list of all pairs (a, b) from `exprs` such that `eq(a, b)`
 +/// `hash` must be comformed with `eq`
 +pub fn search_same<T, Hash, Eq>(exprs: &[T], hash: Hash, eq: Eq) -> Vec<(&T, &T)>
 +where
 +    Hash: Fn(&T) -> u64,
 +    Eq: Fn(&T, &T) -> bool,
 +{
 +    match exprs {
 +        [a, b] if eq(a, b) => return vec![(a, b)],
 +        _ if exprs.len() <= 2 => return vec![],
 +        _ => {},
 +    }
 +
 +    let mut match_expr_list: Vec<(&T, &T)> = Vec::new();
 +
 +    let mut map: UnhashMap<u64, Vec<&_>> =
 +        UnhashMap::with_capacity_and_hasher(exprs.len(), BuildHasherDefault::default());
 +
 +    for expr in exprs {
 +        match map.entry(hash(expr)) {
 +            Entry::Occupied(mut o) => {
 +                for o in o.get() {
 +                    if eq(o, expr) {
 +                        match_expr_list.push((o, expr));
 +                    }
 +                }
 +                o.get_mut().push(expr);
 +            },
 +            Entry::Vacant(v) => {
 +                v.insert(vec![expr]);
 +            },
 +        }
 +    }
 +
 +    match_expr_list
 +}
 +
 +/// Peels off all references on the pattern. Returns the underlying pattern and the number of
 +/// references removed.
 +pub fn peel_hir_pat_refs<'a>(pat: &'a Pat<'a>) -> (&'a Pat<'a>, usize) {
 +    fn peel<'a>(pat: &'a Pat<'a>, count: usize) -> (&'a Pat<'a>, usize) {
 +        if let PatKind::Ref(pat, _) = pat.kind {
 +            peel(pat, count + 1)
 +        } else {
 +            (pat, count)
 +        }
 +    }
 +    peel(pat, 0)
 +}
 +
 +/// Peels of expressions while the given closure returns `Some`.
 +pub fn peel_hir_expr_while<'tcx>(
 +    mut expr: &'tcx Expr<'tcx>,
 +    mut f: impl FnMut(&'tcx Expr<'tcx>) -> Option<&'tcx Expr<'tcx>>,
 +) -> &'tcx Expr<'tcx> {
 +    while let Some(e) = f(expr) {
 +        expr = e;
 +    }
 +    expr
 +}
 +
 +/// Peels off up to the given number of references on the expression. Returns the underlying
 +/// expression and the number of references removed.
 +pub fn peel_n_hir_expr_refs<'a>(expr: &'a Expr<'a>, count: usize) -> (&'a Expr<'a>, usize) {
 +    let mut remaining = count;
 +    let e = peel_hir_expr_while(expr, |e| match e.kind {
 +        ExprKind::AddrOf(ast::BorrowKind::Ref, _, e) if remaining != 0 => {
 +            remaining -= 1;
 +            Some(e)
 +        },
 +        _ => None,
 +    });
 +    (e, count - remaining)
 +}
 +
 +/// Peels off all references on the expression. Returns the underlying expression and the number of
 +/// references removed.
 +pub fn peel_hir_expr_refs<'a>(expr: &'a Expr<'a>) -> (&'a Expr<'a>, usize) {
 +    let mut count = 0;
 +    let e = peel_hir_expr_while(expr, |e| match e.kind {
 +        ExprKind::AddrOf(ast::BorrowKind::Ref, _, e) => {
 +            count += 1;
 +            Some(e)
 +        },
 +        _ => None,
 +    });
 +    (e, count)
 +}
 +
 +/// Removes `AddrOf` operators (`&`) or deref operators (`*`), but only if a reference type is
 +/// dereferenced. An overloaded deref such as `Vec` to slice would not be removed.
 +pub fn peel_ref_operators<'hir>(cx: &LateContext<'_>, mut expr: &'hir Expr<'hir>) -> &'hir Expr<'hir> {
 +    loop {
 +        match expr.kind {
 +            ExprKind::AddrOf(_, _, e) => expr = e,
 +            ExprKind::Unary(UnOp::Deref, e) if cx.typeck_results().expr_ty(e).is_ref() => expr = e,
 +            _ => break,
 +        }
 +    }
 +    expr
 +}
 +
 +#[macro_export]
 +macro_rules! unwrap_cargo_metadata {
 +    ($cx: ident, $lint: ident, $deps: expr) => {{
 +        let mut command = cargo_metadata::MetadataCommand::new();
 +        if !$deps {
 +            command.no_deps();
 +        }
 +
 +        match command.exec() {
 +            Ok(metadata) => metadata,
 +            Err(err) => {
 +                span_lint($cx, $lint, DUMMY_SP, &format!("could not read cargo metadata: {}", err));
 +                return;
 +            },
 +        }
 +    }};
 +}
 +
 +pub fn is_hir_ty_cfg_dependant(cx: &LateContext<'_>, ty: &hir::Ty<'_>) -> bool {
 +    if let TyKind::Path(QPath::Resolved(_, path)) = ty.kind {
 +        if let Res::Def(_, def_id) = path.res {
 +            return cx.tcx.has_attr(def_id, sym::cfg) || cx.tcx.has_attr(def_id, sym::cfg_attr);
 +        }
 +    }
 +    false
 +}
 +
 +struct TestItemNamesVisitor<'tcx> {
 +    tcx: TyCtxt<'tcx>,
 +    names: Vec<Symbol>,
 +}
 +
 +impl<'hir> ItemLikeVisitor<'hir> for TestItemNamesVisitor<'hir> {
 +    fn visit_item(&mut self, item: &Item<'_>) {
 +        if let ItemKind::Const(ty, _body) = item.kind {
 +            if let TyKind::Path(QPath::Resolved(_, path)) = ty.kind {
 +                // We could also check for the type name `test::TestDescAndFn`
 +                if let Res::Def(DefKind::Struct, _) = path.res {
 +                    let has_test_marker = self
 +                        .tcx
 +                        .hir()
 +                        .attrs(item.hir_id())
 +                        .iter()
 +                        .any(|a| a.has_name(sym::rustc_test_marker));
 +                    if has_test_marker {
 +                        self.names.push(item.ident.name);
 +                    }
 +                }
 +            }
 +        }
 +    }
 +    fn visit_trait_item(&mut self, _: &TraitItem<'_>) {}
 +    fn visit_impl_item(&mut self, _: &ImplItem<'_>) {}
 +    fn visit_foreign_item(&mut self, _: &ForeignItem<'_>) {}
 +}
 +
 +static TEST_ITEM_NAMES_CACHE: SyncOnceCell<Mutex<FxHashMap<LocalDefId, Vec<Symbol>>>> = SyncOnceCell::new();
 +
 +fn with_test_item_names<'tcx>(tcx: TyCtxt<'tcx>, module: LocalDefId, f: impl Fn(&[Symbol]) -> bool) -> bool {
 +    let cache = TEST_ITEM_NAMES_CACHE.get_or_init(|| Mutex::new(FxHashMap::default()));
 +    let mut map: MutexGuard<'_, FxHashMap<LocalDefId, Vec<Symbol>>> = cache.lock().unwrap();
 +    match map.entry(module) {
 +        Entry::Occupied(entry) => f(entry.get()),
 +        Entry::Vacant(entry) => {
 +            let mut visitor = TestItemNamesVisitor { tcx, names: Vec::new() };
 +            tcx.hir().visit_item_likes_in_module(module, &mut visitor);
 +            visitor.names.sort_unstable();
 +            f(&*entry.insert(visitor.names))
 +        },
 +    }
 +}
 +
 +/// Checks if the function containing the given `HirId` is a `#[test]` function
 +///
 +/// Note: If you use this function, please add a `#[test]` case in `tests/ui_test`.
 +pub fn is_in_test_function(tcx: TyCtxt<'_>, id: hir::HirId) -> bool {
 +    with_test_item_names(tcx, tcx.parent_module(id), |names| {
 +        tcx.hir()
 +            .parent_iter(id)
 +            // Since you can nest functions we need to collect all until we leave
 +            // function scope
 +            .any(|(_id, node)| {
 +                if let Node::Item(item) = node {
 +                    if let ItemKind::Fn(_, _, _) = item.kind {
 +                        // Note that we have sorted the item names in the visitor,
 +                        // so the binary_search gets the same as `contains`, but faster.
 +                        return names.binary_search(&item.ident.name).is_ok();
 +                    }
 +                }
 +                false
 +            })
 +    })
 +}
 +
 +/// Checks whether item either has `test` attribute applied, or
 +/// is a module with `test` in its name.
 +///
 +/// Note: If you use this function, please add a `#[test]` case in `tests/ui_test`.
 +pub fn is_test_module_or_function(tcx: TyCtxt<'_>, item: &Item<'_>) -> bool {
 +    is_in_test_function(tcx, item.hir_id())
 +        || matches!(item.kind, ItemKind::Mod(..))
 +            && item.ident.name.as_str().split('_').any(|a| a == "test" || a == "tests")
 +}
 +
 +macro_rules! op_utils {
 +    ($($name:ident $assign:ident)*) => {
 +        /// Binary operation traits like `LangItem::Add`
 +        pub static BINOP_TRAITS: &[LangItem] = &[$(LangItem::$name,)*];
 +
 +        /// Operator-Assign traits like `LangItem::AddAssign`
 +        pub static OP_ASSIGN_TRAITS: &[LangItem] = &[$(LangItem::$assign,)*];
 +
 +        /// Converts `BinOpKind::Add` to `(LangItem::Add, LangItem::AddAssign)`, for example
 +        pub fn binop_traits(kind: hir::BinOpKind) -> Option<(LangItem, LangItem)> {
 +            match kind {
 +                $(hir::BinOpKind::$name => Some((LangItem::$name, LangItem::$assign)),)*
 +                _ => None,
 +            }
 +        }
 +    };
 +}
 +
 +op_utils! {
 +    Add    AddAssign
 +    Sub    SubAssign
 +    Mul    MulAssign
 +    Div    DivAssign
 +    Rem    RemAssign
 +    BitXor BitXorAssign
 +    BitAnd BitAndAssign
 +    BitOr  BitOrAssign
 +    Shl    ShlAssign
 +    Shr    ShrAssign
 +}
index 68dd1b29845a570cc4f6b30af834414fc34d70c5,0000000000000000000000000000000000000000..908ff822712ffa0a171f9d043a78ed9b7c8fceb2
mode 100644,000000..100644
--- /dev/null
@@@ -1,241 -1,0 +1,248 @@@
-         if lit_kind.is_numeric() && src.chars().next().map_or(false, |c| c.is_digit(10)) {
 +use rustc_ast::ast::{Lit, LitFloatType, LitIntType, LitKind};
 +use std::iter;
 +
 +#[derive(Debug, PartialEq, Copy, Clone)]
 +pub enum Radix {
 +    Binary,
 +    Octal,
 +    Decimal,
 +    Hexadecimal,
 +}
 +
 +impl Radix {
 +    /// Returns a reasonable digit group size for this radix.
 +    #[must_use]
 +    fn suggest_grouping(self) -> usize {
 +        match self {
 +            Self::Binary | Self::Hexadecimal => 4,
 +            Self::Octal | Self::Decimal => 3,
 +        }
 +    }
 +}
 +
 +/// A helper method to format numeric literals with digit grouping.
 +/// `lit` must be a valid numeric literal without suffix.
 +pub fn format(lit: &str, type_suffix: Option<&str>, float: bool) -> String {
 +    NumericLiteral::new(lit, type_suffix, float).format()
 +}
 +
 +#[derive(Debug)]
 +pub struct NumericLiteral<'a> {
 +    /// Which radix the literal was represented in.
 +    pub radix: Radix,
 +    /// The radix prefix, if present.
 +    pub prefix: Option<&'a str>,
 +
 +    /// The integer part of the number.
 +    pub integer: &'a str,
 +    /// The fraction part of the number.
 +    pub fraction: Option<&'a str>,
 +    /// The exponent separator (b'e' or b'E') including preceding underscore if present
 +    /// and the exponent part.
 +    pub exponent: Option<(&'a str, &'a str)>,
 +
 +    /// The type suffix, including preceding underscore if present.
 +    pub suffix: Option<&'a str>,
 +}
 +
 +impl<'a> NumericLiteral<'a> {
 +    pub fn from_lit(src: &'a str, lit: &Lit) -> Option<NumericLiteral<'a>> {
 +        NumericLiteral::from_lit_kind(src, &lit.kind)
 +    }
 +
 +    pub fn from_lit_kind(src: &'a str, lit_kind: &LitKind) -> Option<NumericLiteral<'a>> {
++        let unsigned_src = src.strip_prefix('-').map_or(src, |s| s);
++        if lit_kind.is_numeric()
++            && unsigned_src
++                .trim_start()
++                .chars()
++                .next()
++                .map_or(false, |c| c.is_digit(10))
++        {
 +            let (unsuffixed, suffix) = split_suffix(src, lit_kind);
 +            let float = matches!(lit_kind, LitKind::Float(..));
 +            Some(NumericLiteral::new(unsuffixed, suffix, float))
 +        } else {
 +            None
 +        }
 +    }
 +
 +    #[must_use]
 +    pub fn new(lit: &'a str, suffix: Option<&'a str>, float: bool) -> Self {
 +        // Determine delimiter for radix prefix, if present, and radix.
 +        let radix = if lit.starts_with("0x") {
 +            Radix::Hexadecimal
 +        } else if lit.starts_with("0b") {
 +            Radix::Binary
 +        } else if lit.starts_with("0o") {
 +            Radix::Octal
 +        } else {
 +            Radix::Decimal
 +        };
 +
 +        // Grab part of the literal after prefix, if present.
 +        let (prefix, mut sans_prefix) = if radix == Radix::Decimal {
 +            (None, lit)
 +        } else {
 +            let (p, s) = lit.split_at(2);
 +            (Some(p), s)
 +        };
 +
 +        if suffix.is_some() && sans_prefix.ends_with('_') {
 +            // The '_' before the suffix isn't part of the digits
 +            sans_prefix = &sans_prefix[..sans_prefix.len() - 1];
 +        }
 +
 +        let (integer, fraction, exponent) = Self::split_digit_parts(sans_prefix, float);
 +
 +        Self {
 +            radix,
 +            prefix,
 +            integer,
 +            fraction,
 +            exponent,
 +            suffix,
 +        }
 +    }
 +
 +    pub fn is_decimal(&self) -> bool {
 +        self.radix == Radix::Decimal
 +    }
 +
 +    pub fn split_digit_parts(digits: &str, float: bool) -> (&str, Option<&str>, Option<(&str, &str)>) {
 +        let mut integer = digits;
 +        let mut fraction = None;
 +        let mut exponent = None;
 +
 +        if float {
 +            for (i, c) in digits.char_indices() {
 +                match c {
 +                    '.' => {
 +                        integer = &digits[..i];
 +                        fraction = Some(&digits[i + 1..]);
 +                    },
 +                    'e' | 'E' => {
 +                        let exp_start = if digits[..i].ends_with('_') { i - 1 } else { i };
 +
 +                        if integer.len() > exp_start {
 +                            integer = &digits[..exp_start];
 +                        } else {
 +                            fraction = Some(&digits[integer.len() + 1..exp_start]);
 +                        };
 +                        exponent = Some((&digits[exp_start..=i], &digits[i + 1..]));
 +                        break;
 +                    },
 +                    _ => {},
 +                }
 +            }
 +        }
 +
 +        (integer, fraction, exponent)
 +    }
 +
 +    /// Returns literal formatted in a sensible way.
 +    pub fn format(&self) -> String {
 +        let mut output = String::new();
 +
 +        if let Some(prefix) = self.prefix {
 +            output.push_str(prefix);
 +        }
 +
 +        let group_size = self.radix.suggest_grouping();
 +
 +        Self::group_digits(
 +            &mut output,
 +            self.integer,
 +            group_size,
 +            true,
 +            self.radix == Radix::Hexadecimal,
 +        );
 +
 +        if let Some(fraction) = self.fraction {
 +            output.push('.');
 +            Self::group_digits(&mut output, fraction, group_size, false, false);
 +        }
 +
 +        if let Some((separator, exponent)) = self.exponent {
 +            if exponent != "0" {
 +                output.push_str(separator);
 +                Self::group_digits(&mut output, exponent, group_size, true, false);
 +            }
 +        }
 +
 +        if let Some(suffix) = self.suffix {
 +            if output.ends_with('.') {
 +                output.push('0');
 +            }
 +            output.push('_');
 +            output.push_str(suffix);
 +        }
 +
 +        output
 +    }
 +
 +    pub fn group_digits(output: &mut String, input: &str, group_size: usize, partial_group_first: bool, pad: bool) {
 +        debug_assert!(group_size > 0);
 +
 +        let mut digits = input.chars().filter(|&c| c != '_');
 +
 +        // The exponent may have a sign, output it early, otherwise it will be
 +        // treated as a digit
 +        if digits.clone().next() == Some('-') {
 +            let _ = digits.next();
 +            output.push('-');
 +        }
 +
 +        let first_group_size;
 +
 +        if partial_group_first {
 +            first_group_size = (digits.clone().count() - 1) % group_size + 1;
 +            if pad {
 +                for _ in 0..group_size - first_group_size {
 +                    output.push('0');
 +                }
 +            }
 +        } else {
 +            first_group_size = group_size;
 +        }
 +
 +        for _ in 0..first_group_size {
 +            if let Some(digit) = digits.next() {
 +                output.push(digit);
 +            }
 +        }
 +
 +        for (c, i) in iter::zip(digits, (0..group_size).cycle()) {
 +            if i == 0 {
 +                output.push('_');
 +            }
 +            output.push(c);
 +        }
 +    }
 +}
 +
 +fn split_suffix<'a>(src: &'a str, lit_kind: &LitKind) -> (&'a str, Option<&'a str>) {
 +    debug_assert!(lit_kind.is_numeric());
 +    lit_suffix_length(lit_kind).map_or((src, None), |suffix_length| {
 +        let (unsuffixed, suffix) = src.split_at(src.len() - suffix_length);
 +        (unsuffixed, Some(suffix))
 +    })
 +}
 +
 +fn lit_suffix_length(lit_kind: &LitKind) -> Option<usize> {
 +    debug_assert!(lit_kind.is_numeric());
 +    let suffix = match lit_kind {
 +        LitKind::Int(_, int_lit_kind) => match int_lit_kind {
 +            LitIntType::Signed(int_ty) => Some(int_ty.name_str()),
 +            LitIntType::Unsigned(uint_ty) => Some(uint_ty.name_str()),
 +            LitIntType::Unsuffixed => None,
 +        },
 +        LitKind::Float(_, float_lit_kind) => match float_lit_kind {
 +            LitFloatType::Suffixed(float_ty) => Some(float_ty.name_str()),
 +            LitFloatType::Unsuffixed => None,
 +        },
 +        _ => None,
 +    };
 +
 +    suffix.map(str::len)
 +}
index 48525f9a5725e3c6f070572023e4efb5bd105517,0000000000000000000000000000000000000000..fa63ddff253cfd7afa686a48c2e4af3d82512079
mode 100644,000000..100644
--- /dev/null
@@@ -1,1089 -1,0 +1,1089 @@@
- fn has_enclosing_paren(sugg: impl AsRef<str>) -> bool {
 +//! Contains utility functions to generate suggestions.
 +#![deny(clippy::missing_docs_in_private_items)]
 +
 +use crate::source::{snippet, snippet_opt, snippet_with_applicability, snippet_with_macro_callsite};
 +use crate::{get_parent_expr_for_hir, higher};
 +use rustc_ast::util::parser::AssocOp;
 +use rustc_ast::{ast, token};
 +use rustc_ast_pretty::pprust::token_kind_to_string;
 +use rustc_errors::Applicability;
 +use rustc_hir as hir;
 +use rustc_hir::{ExprKind, HirId, MutTy, TyKind};
 +use rustc_infer::infer::TyCtxtInferExt;
 +use rustc_lint::{EarlyContext, LateContext, LintContext};
 +use rustc_middle::hir::place::ProjectionKind;
 +use rustc_middle::mir::{FakeReadCause, Mutability};
 +use rustc_middle::ty;
 +use rustc_span::source_map::{BytePos, CharPos, Pos, Span, SyntaxContext};
 +use rustc_typeck::expr_use_visitor::{Delegate, ExprUseVisitor, PlaceBase, PlaceWithHirId};
 +use std::borrow::Cow;
 +use std::convert::TryInto;
 +use std::fmt::Display;
 +use std::iter;
 +use std::ops::{Add, Neg, Not, Sub};
 +
 +/// A helper type to build suggestion correctly handling parentheses.
 +#[derive(Clone, PartialEq)]
 +pub enum Sugg<'a> {
 +    /// An expression that never needs parentheses such as `1337` or `[0; 42]`.
 +    NonParen(Cow<'a, str>),
 +    /// An expression that does not fit in other variants.
 +    MaybeParen(Cow<'a, str>),
 +    /// A binary operator expression, including `as`-casts and explicit type
 +    /// coercion.
 +    BinOp(AssocOp, Cow<'a, str>, Cow<'a, str>),
 +}
 +
 +/// Literal constant `0`, for convenience.
 +pub const ZERO: Sugg<'static> = Sugg::NonParen(Cow::Borrowed("0"));
 +/// Literal constant `1`, for convenience.
 +pub const ONE: Sugg<'static> = Sugg::NonParen(Cow::Borrowed("1"));
 +/// a constant represents an empty string, for convenience.
 +pub const EMPTY: Sugg<'static> = Sugg::NonParen(Cow::Borrowed(""));
 +
 +impl Display for Sugg<'_> {
 +    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
 +        match *self {
 +            Sugg::NonParen(ref s) | Sugg::MaybeParen(ref s) => s.fmt(f),
 +            Sugg::BinOp(op, ref lhs, ref rhs) => binop_to_string(op, lhs, rhs).fmt(f),
 +        }
 +    }
 +}
 +
 +#[allow(clippy::wrong_self_convention)] // ok, because of the function `as_ty` method
 +impl<'a> Sugg<'a> {
 +    /// Prepare a suggestion from an expression.
 +    pub fn hir_opt(cx: &LateContext<'_>, expr: &hir::Expr<'_>) -> Option<Self> {
 +        let get_snippet = |span| snippet(cx, span, "");
 +        snippet_opt(cx, expr.span).map(|_| Self::hir_from_snippet(expr, get_snippet))
 +    }
 +
 +    /// Convenience function around `hir_opt` for suggestions with a default
 +    /// text.
 +    pub fn hir(cx: &LateContext<'_>, expr: &hir::Expr<'_>, default: &'a str) -> Self {
 +        Self::hir_opt(cx, expr).unwrap_or(Sugg::NonParen(Cow::Borrowed(default)))
 +    }
 +
 +    /// Same as `hir`, but it adapts the applicability level by following rules:
 +    ///
 +    /// - Applicability level `Unspecified` will never be changed.
 +    /// - If the span is inside a macro, change the applicability level to `MaybeIncorrect`.
 +    /// - If the default value is used and the applicability level is `MachineApplicable`, change it
 +    ///   to
 +    /// `HasPlaceholders`
 +    pub fn hir_with_applicability(
 +        cx: &LateContext<'_>,
 +        expr: &hir::Expr<'_>,
 +        default: &'a str,
 +        applicability: &mut Applicability,
 +    ) -> Self {
 +        if *applicability != Applicability::Unspecified && expr.span.from_expansion() {
 +            *applicability = Applicability::MaybeIncorrect;
 +        }
 +        Self::hir_opt(cx, expr).unwrap_or_else(|| {
 +            if *applicability == Applicability::MachineApplicable {
 +                *applicability = Applicability::HasPlaceholders;
 +            }
 +            Sugg::NonParen(Cow::Borrowed(default))
 +        })
 +    }
 +
 +    /// Same as `hir`, but will use the pre expansion span if the `expr` was in a macro.
 +    pub fn hir_with_macro_callsite(cx: &LateContext<'_>, expr: &hir::Expr<'_>, default: &'a str) -> Self {
 +        let get_snippet = |span| snippet_with_macro_callsite(cx, span, default);
 +        Self::hir_from_snippet(expr, get_snippet)
 +    }
 +
 +    /// Same as `hir`, but first walks the span up to the given context. This will result in the
 +    /// macro call, rather then the expansion, if the span is from a child context. If the span is
 +    /// not from a child context, it will be used directly instead.
 +    ///
 +    /// e.g. Given the expression `&vec![]`, getting a snippet from the span for `vec![]` as a HIR
 +    /// node would result in `box []`. If given the context of the address of expression, this
 +    /// function will correctly get a snippet of `vec![]`.
 +    pub fn hir_with_context(
 +        cx: &LateContext<'_>,
 +        expr: &hir::Expr<'_>,
 +        ctxt: SyntaxContext,
 +        default: &'a str,
 +        applicability: &mut Applicability,
 +    ) -> Self {
 +        if expr.span.ctxt() == ctxt {
 +            Self::hir_from_snippet(expr, |span| snippet(cx, span, default))
 +        } else {
 +            let snip = snippet_with_applicability(cx, expr.span, default, applicability);
 +            Sugg::NonParen(snip)
 +        }
 +    }
 +
 +    /// Generate a suggestion for an expression with the given snippet. This is used by the `hir_*`
 +    /// function variants of `Sugg`, since these use different snippet functions.
 +    fn hir_from_snippet(expr: &hir::Expr<'_>, get_snippet: impl Fn(Span) -> Cow<'a, str>) -> Self {
 +        if let Some(range) = higher::Range::hir(expr) {
 +            let op = match range.limits {
 +                ast::RangeLimits::HalfOpen => AssocOp::DotDot,
 +                ast::RangeLimits::Closed => AssocOp::DotDotEq,
 +            };
 +            let start = range.start.map_or("".into(), |expr| get_snippet(expr.span));
 +            let end = range.end.map_or("".into(), |expr| get_snippet(expr.span));
 +
 +            return Sugg::BinOp(op, start, end);
 +        }
 +
 +        match expr.kind {
 +            hir::ExprKind::AddrOf(..)
 +            | hir::ExprKind::Box(..)
 +            | hir::ExprKind::If(..)
 +            | hir::ExprKind::Let(..)
 +            | hir::ExprKind::Closure(..)
 +            | hir::ExprKind::Unary(..)
 +            | hir::ExprKind::Match(..) => Sugg::MaybeParen(get_snippet(expr.span)),
 +            hir::ExprKind::Continue(..)
 +            | hir::ExprKind::Yield(..)
 +            | hir::ExprKind::Array(..)
 +            | hir::ExprKind::Block(..)
 +            | hir::ExprKind::Break(..)
 +            | hir::ExprKind::Call(..)
 +            | hir::ExprKind::Field(..)
 +            | hir::ExprKind::Index(..)
 +            | hir::ExprKind::InlineAsm(..)
 +            | hir::ExprKind::ConstBlock(..)
 +            | hir::ExprKind::Lit(..)
 +            | hir::ExprKind::Loop(..)
 +            | hir::ExprKind::MethodCall(..)
 +            | hir::ExprKind::Path(..)
 +            | hir::ExprKind::Repeat(..)
 +            | hir::ExprKind::Ret(..)
 +            | hir::ExprKind::Struct(..)
 +            | hir::ExprKind::Tup(..)
 +            | hir::ExprKind::DropTemps(_)
 +            | hir::ExprKind::Err => Sugg::NonParen(get_snippet(expr.span)),
 +            hir::ExprKind::Assign(lhs, rhs, _) => {
 +                Sugg::BinOp(AssocOp::Assign, get_snippet(lhs.span), get_snippet(rhs.span))
 +            },
 +            hir::ExprKind::AssignOp(op, lhs, rhs) => {
 +                Sugg::BinOp(hirbinop2assignop(op), get_snippet(lhs.span), get_snippet(rhs.span))
 +            },
 +            hir::ExprKind::Binary(op, lhs, rhs) => Sugg::BinOp(
 +                AssocOp::from_ast_binop(op.node.into()),
 +                get_snippet(lhs.span),
 +                get_snippet(rhs.span),
 +            ),
 +            hir::ExprKind::Cast(lhs, ty) => Sugg::BinOp(AssocOp::As, get_snippet(lhs.span), get_snippet(ty.span)),
 +            hir::ExprKind::Type(lhs, ty) => Sugg::BinOp(AssocOp::Colon, get_snippet(lhs.span), get_snippet(ty.span)),
 +        }
 +    }
 +
 +    /// Prepare a suggestion from an expression.
 +    pub fn ast(cx: &EarlyContext<'_>, expr: &ast::Expr, default: &'a str) -> Self {
 +        use rustc_ast::ast::RangeLimits;
 +
 +        let get_whole_snippet = || {
 +            if expr.span.from_expansion() {
 +                snippet_with_macro_callsite(cx, expr.span, default)
 +            } else {
 +                snippet(cx, expr.span, default)
 +            }
 +        };
 +
 +        match expr.kind {
 +            ast::ExprKind::AddrOf(..)
 +            | ast::ExprKind::Box(..)
 +            | ast::ExprKind::Closure(..)
 +            | ast::ExprKind::If(..)
 +            | ast::ExprKind::Let(..)
 +            | ast::ExprKind::Unary(..)
 +            | ast::ExprKind::Match(..) => Sugg::MaybeParen(get_whole_snippet()),
 +            ast::ExprKind::Async(..)
 +            | ast::ExprKind::Block(..)
 +            | ast::ExprKind::Break(..)
 +            | ast::ExprKind::Call(..)
 +            | ast::ExprKind::Continue(..)
 +            | ast::ExprKind::Yield(..)
 +            | ast::ExprKind::Field(..)
 +            | ast::ExprKind::ForLoop(..)
 +            | ast::ExprKind::Index(..)
 +            | ast::ExprKind::InlineAsm(..)
 +            | ast::ExprKind::ConstBlock(..)
 +            | ast::ExprKind::Lit(..)
 +            | ast::ExprKind::Loop(..)
 +            | ast::ExprKind::MacCall(..)
 +            | ast::ExprKind::MethodCall(..)
 +            | ast::ExprKind::Paren(..)
 +            | ast::ExprKind::Underscore
 +            | ast::ExprKind::Path(..)
 +            | ast::ExprKind::Repeat(..)
 +            | ast::ExprKind::Ret(..)
 +            | ast::ExprKind::Struct(..)
 +            | ast::ExprKind::Try(..)
 +            | ast::ExprKind::TryBlock(..)
 +            | ast::ExprKind::Tup(..)
 +            | ast::ExprKind::Array(..)
 +            | ast::ExprKind::While(..)
 +            | ast::ExprKind::Await(..)
 +            | ast::ExprKind::Err => Sugg::NonParen(get_whole_snippet()),
 +            ast::ExprKind::Range(ref lhs, ref rhs, RangeLimits::HalfOpen) => Sugg::BinOp(
 +                AssocOp::DotDot,
 +                lhs.as_ref().map_or("".into(), |lhs| snippet(cx, lhs.span, default)),
 +                rhs.as_ref().map_or("".into(), |rhs| snippet(cx, rhs.span, default)),
 +            ),
 +            ast::ExprKind::Range(ref lhs, ref rhs, RangeLimits::Closed) => Sugg::BinOp(
 +                AssocOp::DotDotEq,
 +                lhs.as_ref().map_or("".into(), |lhs| snippet(cx, lhs.span, default)),
 +                rhs.as_ref().map_or("".into(), |rhs| snippet(cx, rhs.span, default)),
 +            ),
 +            ast::ExprKind::Assign(ref lhs, ref rhs, _) => Sugg::BinOp(
 +                AssocOp::Assign,
 +                snippet(cx, lhs.span, default),
 +                snippet(cx, rhs.span, default),
 +            ),
 +            ast::ExprKind::AssignOp(op, ref lhs, ref rhs) => Sugg::BinOp(
 +                astbinop2assignop(op),
 +                snippet(cx, lhs.span, default),
 +                snippet(cx, rhs.span, default),
 +            ),
 +            ast::ExprKind::Binary(op, ref lhs, ref rhs) => Sugg::BinOp(
 +                AssocOp::from_ast_binop(op.node),
 +                snippet(cx, lhs.span, default),
 +                snippet(cx, rhs.span, default),
 +            ),
 +            ast::ExprKind::Cast(ref lhs, ref ty) => Sugg::BinOp(
 +                AssocOp::As,
 +                snippet(cx, lhs.span, default),
 +                snippet(cx, ty.span, default),
 +            ),
 +            ast::ExprKind::Type(ref lhs, ref ty) => Sugg::BinOp(
 +                AssocOp::Colon,
 +                snippet(cx, lhs.span, default),
 +                snippet(cx, ty.span, default),
 +            ),
 +        }
 +    }
 +
 +    /// Convenience method to create the `<lhs> && <rhs>` suggestion.
 +    pub fn and(self, rhs: &Self) -> Sugg<'static> {
 +        make_binop(ast::BinOpKind::And, &self, rhs)
 +    }
 +
 +    /// Convenience method to create the `<lhs> & <rhs>` suggestion.
 +    pub fn bit_and(self, rhs: &Self) -> Sugg<'static> {
 +        make_binop(ast::BinOpKind::BitAnd, &self, rhs)
 +    }
 +
 +    /// Convenience method to create the `<lhs> as <rhs>` suggestion.
 +    pub fn as_ty<R: Display>(self, rhs: R) -> Sugg<'static> {
 +        make_assoc(AssocOp::As, &self, &Sugg::NonParen(rhs.to_string().into()))
 +    }
 +
 +    /// Convenience method to create the `&<expr>` suggestion.
 +    pub fn addr(self) -> Sugg<'static> {
 +        make_unop("&", self)
 +    }
 +
 +    /// Convenience method to create the `&mut <expr>` suggestion.
 +    pub fn mut_addr(self) -> Sugg<'static> {
 +        make_unop("&mut ", self)
 +    }
 +
 +    /// Convenience method to create the `*<expr>` suggestion.
 +    pub fn deref(self) -> Sugg<'static> {
 +        make_unop("*", self)
 +    }
 +
 +    /// Convenience method to create the `&*<expr>` suggestion. Currently this
 +    /// is needed because `sugg.deref().addr()` produces an unnecessary set of
 +    /// parentheses around the deref.
 +    pub fn addr_deref(self) -> Sugg<'static> {
 +        make_unop("&*", self)
 +    }
 +
 +    /// Convenience method to create the `&mut *<expr>` suggestion. Currently
 +    /// this is needed because `sugg.deref().mut_addr()` produces an unnecessary
 +    /// set of parentheses around the deref.
 +    pub fn mut_addr_deref(self) -> Sugg<'static> {
 +        make_unop("&mut *", self)
 +    }
 +
 +    /// Convenience method to transform suggestion into a return call
 +    pub fn make_return(self) -> Sugg<'static> {
 +        Sugg::NonParen(Cow::Owned(format!("return {}", self)))
 +    }
 +
 +    /// Convenience method to transform suggestion into a block
 +    /// where the suggestion is a trailing expression
 +    pub fn blockify(self) -> Sugg<'static> {
 +        Sugg::NonParen(Cow::Owned(format!("{{ {} }}", self)))
 +    }
 +
 +    /// Convenience method to create the `<lhs>..<rhs>` or `<lhs>...<rhs>`
 +    /// suggestion.
 +    #[allow(dead_code)]
 +    pub fn range(self, end: &Self, limit: ast::RangeLimits) -> Sugg<'static> {
 +        match limit {
 +            ast::RangeLimits::HalfOpen => make_assoc(AssocOp::DotDot, &self, end),
 +            ast::RangeLimits::Closed => make_assoc(AssocOp::DotDotEq, &self, end),
 +        }
 +    }
 +
 +    /// Adds parentheses to any expression that might need them. Suitable to the
 +    /// `self` argument of a method call
 +    /// (e.g., to build `bar.foo()` or `(1 + 2).foo()`).
 +    #[must_use]
 +    pub fn maybe_par(self) -> Self {
 +        match self {
 +            Sugg::NonParen(..) => self,
 +            // `(x)` and `(x).y()` both don't need additional parens.
 +            Sugg::MaybeParen(sugg) => {
 +                if has_enclosing_paren(&sugg) {
 +                    Sugg::MaybeParen(sugg)
 +                } else {
 +                    Sugg::NonParen(format!("({})", sugg).into())
 +                }
 +            },
 +            Sugg::BinOp(op, lhs, rhs) => {
 +                let sugg = binop_to_string(op, &lhs, &rhs);
 +                Sugg::NonParen(format!("({})", sugg).into())
 +            },
 +        }
 +    }
 +}
 +
 +/// Generates a string from the operator and both sides.
 +fn binop_to_string(op: AssocOp, lhs: &str, rhs: &str) -> String {
 +    match op {
 +        AssocOp::Add
 +        | AssocOp::Subtract
 +        | AssocOp::Multiply
 +        | AssocOp::Divide
 +        | AssocOp::Modulus
 +        | AssocOp::LAnd
 +        | AssocOp::LOr
 +        | AssocOp::BitXor
 +        | AssocOp::BitAnd
 +        | AssocOp::BitOr
 +        | AssocOp::ShiftLeft
 +        | AssocOp::ShiftRight
 +        | AssocOp::Equal
 +        | AssocOp::Less
 +        | AssocOp::LessEqual
 +        | AssocOp::NotEqual
 +        | AssocOp::Greater
 +        | AssocOp::GreaterEqual => format!(
 +            "{} {} {}",
 +            lhs,
 +            op.to_ast_binop().expect("Those are AST ops").to_string(),
 +            rhs
 +        ),
 +        AssocOp::Assign => format!("{} = {}", lhs, rhs),
 +        AssocOp::AssignOp(op) => {
 +            format!("{} {}= {}", lhs, token_kind_to_string(&token::BinOp(op)), rhs)
 +        },
 +        AssocOp::As => format!("{} as {}", lhs, rhs),
 +        AssocOp::DotDot => format!("{}..{}", lhs, rhs),
 +        AssocOp::DotDotEq => format!("{}..={}", lhs, rhs),
 +        AssocOp::Colon => format!("{}: {}", lhs, rhs),
 +    }
 +}
 +
 +/// Return `true` if `sugg` is enclosed in parenthesis.
++pub fn has_enclosing_paren(sugg: impl AsRef<str>) -> bool {
 +    let mut chars = sugg.as_ref().chars();
 +    if chars.next() == Some('(') {
 +        let mut depth = 1;
 +        for c in &mut chars {
 +            if c == '(' {
 +                depth += 1;
 +            } else if c == ')' {
 +                depth -= 1;
 +            }
 +            if depth == 0 {
 +                break;
 +            }
 +        }
 +        chars.next().is_none()
 +    } else {
 +        false
 +    }
 +}
 +
 +/// Copied from the rust standard library, and then edited
 +macro_rules! forward_binop_impls_to_ref {
 +    (impl $imp:ident, $method:ident for $t:ty, type Output = $o:ty) => {
 +        impl $imp<$t> for &$t {
 +            type Output = $o;
 +
 +            fn $method(self, other: $t) -> $o {
 +                $imp::$method(self, &other)
 +            }
 +        }
 +
 +        impl $imp<&$t> for $t {
 +            type Output = $o;
 +
 +            fn $method(self, other: &$t) -> $o {
 +                $imp::$method(&self, other)
 +            }
 +        }
 +
 +        impl $imp for $t {
 +            type Output = $o;
 +
 +            fn $method(self, other: $t) -> $o {
 +                $imp::$method(&self, &other)
 +            }
 +        }
 +    };
 +}
 +
 +impl Add for &Sugg<'_> {
 +    type Output = Sugg<'static>;
 +    fn add(self, rhs: &Sugg<'_>) -> Sugg<'static> {
 +        make_binop(ast::BinOpKind::Add, self, rhs)
 +    }
 +}
 +
 +impl Sub for &Sugg<'_> {
 +    type Output = Sugg<'static>;
 +    fn sub(self, rhs: &Sugg<'_>) -> Sugg<'static> {
 +        make_binop(ast::BinOpKind::Sub, self, rhs)
 +    }
 +}
 +
 +forward_binop_impls_to_ref!(impl Add, add for Sugg<'_>, type Output = Sugg<'static>);
 +forward_binop_impls_to_ref!(impl Sub, sub for Sugg<'_>, type Output = Sugg<'static>);
 +
 +impl Neg for Sugg<'_> {
 +    type Output = Sugg<'static>;
 +    fn neg(self) -> Sugg<'static> {
 +        make_unop("-", self)
 +    }
 +}
 +
 +impl<'a> Not for Sugg<'a> {
 +    type Output = Sugg<'a>;
 +    fn not(self) -> Sugg<'a> {
 +        use AssocOp::{Equal, Greater, GreaterEqual, Less, LessEqual, NotEqual};
 +
 +        if let Sugg::BinOp(op, lhs, rhs) = self {
 +            let to_op = match op {
 +                Equal => NotEqual,
 +                NotEqual => Equal,
 +                Less => GreaterEqual,
 +                GreaterEqual => Less,
 +                Greater => LessEqual,
 +                LessEqual => Greater,
 +                _ => return make_unop("!", Sugg::BinOp(op, lhs, rhs)),
 +            };
 +            Sugg::BinOp(to_op, lhs, rhs)
 +        } else {
 +            make_unop("!", self)
 +        }
 +    }
 +}
 +
 +/// Helper type to display either `foo` or `(foo)`.
 +struct ParenHelper<T> {
 +    /// `true` if parentheses are needed.
 +    paren: bool,
 +    /// The main thing to display.
 +    wrapped: T,
 +}
 +
 +impl<T> ParenHelper<T> {
 +    /// Builds a `ParenHelper`.
 +    fn new(paren: bool, wrapped: T) -> Self {
 +        Self { paren, wrapped }
 +    }
 +}
 +
 +impl<T: Display> Display for ParenHelper<T> {
 +    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
 +        if self.paren {
 +            write!(f, "({})", self.wrapped)
 +        } else {
 +            self.wrapped.fmt(f)
 +        }
 +    }
 +}
 +
 +/// Builds the string for `<op><expr>` adding parenthesis when necessary.
 +///
 +/// For convenience, the operator is taken as a string because all unary
 +/// operators have the same
 +/// precedence.
 +pub fn make_unop(op: &str, expr: Sugg<'_>) -> Sugg<'static> {
 +    Sugg::MaybeParen(format!("{}{}", op, expr.maybe_par()).into())
 +}
 +
 +/// Builds the string for `<lhs> <op> <rhs>` adding parenthesis when necessary.
 +///
 +/// Precedence of shift operator relative to other arithmetic operation is
 +/// often confusing so
 +/// parenthesis will always be added for a mix of these.
 +pub fn make_assoc(op: AssocOp, lhs: &Sugg<'_>, rhs: &Sugg<'_>) -> Sugg<'static> {
 +    /// Returns `true` if the operator is a shift operator `<<` or `>>`.
 +    fn is_shift(op: AssocOp) -> bool {
 +        matches!(op, AssocOp::ShiftLeft | AssocOp::ShiftRight)
 +    }
 +
 +    /// Returns `true` if the operator is an arithmetic operator
 +    /// (i.e., `+`, `-`, `*`, `/`, `%`).
 +    fn is_arith(op: AssocOp) -> bool {
 +        matches!(
 +            op,
 +            AssocOp::Add | AssocOp::Subtract | AssocOp::Multiply | AssocOp::Divide | AssocOp::Modulus
 +        )
 +    }
 +
 +    /// Returns `true` if the operator `op` needs parenthesis with the operator
 +    /// `other` in the direction `dir`.
 +    fn needs_paren(op: AssocOp, other: AssocOp, dir: Associativity) -> bool {
 +        other.precedence() < op.precedence()
 +            || (other.precedence() == op.precedence()
 +                && ((op != other && associativity(op) != dir)
 +                    || (op == other && associativity(op) != Associativity::Both)))
 +            || is_shift(op) && is_arith(other)
 +            || is_shift(other) && is_arith(op)
 +    }
 +
 +    let lhs_paren = if let Sugg::BinOp(lop, _, _) = *lhs {
 +        needs_paren(op, lop, Associativity::Left)
 +    } else {
 +        false
 +    };
 +
 +    let rhs_paren = if let Sugg::BinOp(rop, _, _) = *rhs {
 +        needs_paren(op, rop, Associativity::Right)
 +    } else {
 +        false
 +    };
 +
 +    let lhs = ParenHelper::new(lhs_paren, lhs).to_string();
 +    let rhs = ParenHelper::new(rhs_paren, rhs).to_string();
 +    Sugg::BinOp(op, lhs.into(), rhs.into())
 +}
 +
 +/// Convenience wrapper around `make_assoc` and `AssocOp::from_ast_binop`.
 +pub fn make_binop(op: ast::BinOpKind, lhs: &Sugg<'_>, rhs: &Sugg<'_>) -> Sugg<'static> {
 +    make_assoc(AssocOp::from_ast_binop(op), lhs, rhs)
 +}
 +
 +#[derive(PartialEq, Eq, Clone, Copy)]
 +/// Operator associativity.
 +enum Associativity {
 +    /// The operator is both left-associative and right-associative.
 +    Both,
 +    /// The operator is left-associative.
 +    Left,
 +    /// The operator is not associative.
 +    None,
 +    /// The operator is right-associative.
 +    Right,
 +}
 +
 +/// Returns the associativity/fixity of an operator. The difference with
 +/// `AssocOp::fixity` is that an operator can be both left and right associative
 +/// (such as `+`: `a + b + c == (a + b) + c == a + (b + c)`.
 +///
 +/// Chained `as` and explicit `:` type coercion never need inner parenthesis so
 +/// they are considered
 +/// associative.
 +#[must_use]
 +fn associativity(op: AssocOp) -> Associativity {
 +    use rustc_ast::util::parser::AssocOp::{
 +        Add, As, Assign, AssignOp, BitAnd, BitOr, BitXor, Colon, Divide, DotDot, DotDotEq, Equal, Greater,
 +        GreaterEqual, LAnd, LOr, Less, LessEqual, Modulus, Multiply, NotEqual, ShiftLeft, ShiftRight, Subtract,
 +    };
 +
 +    match op {
 +        Assign | AssignOp(_) => Associativity::Right,
 +        Add | BitAnd | BitOr | BitXor | LAnd | LOr | Multiply | As | Colon => Associativity::Both,
 +        Divide | Equal | Greater | GreaterEqual | Less | LessEqual | Modulus | NotEqual | ShiftLeft | ShiftRight
 +        | Subtract => Associativity::Left,
 +        DotDot | DotDotEq => Associativity::None,
 +    }
 +}
 +
 +/// Converts a `hir::BinOp` to the corresponding assigning binary operator.
 +fn hirbinop2assignop(op: hir::BinOp) -> AssocOp {
 +    use rustc_ast::token::BinOpToken::{And, Caret, Minus, Or, Percent, Plus, Shl, Shr, Slash, Star};
 +
 +    AssocOp::AssignOp(match op.node {
 +        hir::BinOpKind::Add => Plus,
 +        hir::BinOpKind::BitAnd => And,
 +        hir::BinOpKind::BitOr => Or,
 +        hir::BinOpKind::BitXor => Caret,
 +        hir::BinOpKind::Div => Slash,
 +        hir::BinOpKind::Mul => Star,
 +        hir::BinOpKind::Rem => Percent,
 +        hir::BinOpKind::Shl => Shl,
 +        hir::BinOpKind::Shr => Shr,
 +        hir::BinOpKind::Sub => Minus,
 +
 +        hir::BinOpKind::And
 +        | hir::BinOpKind::Eq
 +        | hir::BinOpKind::Ge
 +        | hir::BinOpKind::Gt
 +        | hir::BinOpKind::Le
 +        | hir::BinOpKind::Lt
 +        | hir::BinOpKind::Ne
 +        | hir::BinOpKind::Or => panic!("This operator does not exist"),
 +    })
 +}
 +
 +/// Converts an `ast::BinOp` to the corresponding assigning binary operator.
 +fn astbinop2assignop(op: ast::BinOp) -> AssocOp {
 +    use rustc_ast::ast::BinOpKind::{
 +        Add, And, BitAnd, BitOr, BitXor, Div, Eq, Ge, Gt, Le, Lt, Mul, Ne, Or, Rem, Shl, Shr, Sub,
 +    };
 +    use rustc_ast::token::BinOpToken;
 +
 +    AssocOp::AssignOp(match op.node {
 +        Add => BinOpToken::Plus,
 +        BitAnd => BinOpToken::And,
 +        BitOr => BinOpToken::Or,
 +        BitXor => BinOpToken::Caret,
 +        Div => BinOpToken::Slash,
 +        Mul => BinOpToken::Star,
 +        Rem => BinOpToken::Percent,
 +        Shl => BinOpToken::Shl,
 +        Shr => BinOpToken::Shr,
 +        Sub => BinOpToken::Minus,
 +        And | Eq | Ge | Gt | Le | Lt | Ne | Or => panic!("This operator does not exist"),
 +    })
 +}
 +
 +/// Returns the indentation before `span` if there are nothing but `[ \t]`
 +/// before it on its line.
 +fn indentation<T: LintContext>(cx: &T, span: Span) -> Option<String> {
 +    let lo = cx.sess().source_map().lookup_char_pos(span.lo());
 +    lo.file
 +        .get_line(lo.line - 1 /* line numbers in `Loc` are 1-based */)
 +        .and_then(|line| {
 +            if let Some((pos, _)) = line.char_indices().find(|&(_, c)| c != ' ' && c != '\t') {
 +                // We can mix char and byte positions here because we only consider `[ \t]`.
 +                if lo.col == CharPos(pos) {
 +                    Some(line[..pos].into())
 +                } else {
 +                    None
 +                }
 +            } else {
 +                None
 +            }
 +        })
 +}
 +
 +/// Convenience extension trait for `DiagnosticBuilder`.
 +pub trait DiagnosticBuilderExt<T: LintContext> {
 +    /// Suggests to add an attribute to an item.
 +    ///
 +    /// Correctly handles indentation of the attribute and item.
 +    ///
 +    /// # Example
 +    ///
 +    /// ```rust,ignore
 +    /// diag.suggest_item_with_attr(cx, item, "#[derive(Default)]");
 +    /// ```
 +    fn suggest_item_with_attr<D: Display + ?Sized>(
 +        &mut self,
 +        cx: &T,
 +        item: Span,
 +        msg: &str,
 +        attr: &D,
 +        applicability: Applicability,
 +    );
 +
 +    /// Suggest to add an item before another.
 +    ///
 +    /// The item should not be indented (except for inner indentation).
 +    ///
 +    /// # Example
 +    ///
 +    /// ```rust,ignore
 +    /// diag.suggest_prepend_item(cx, item,
 +    /// "fn foo() {
 +    ///     bar();
 +    /// }");
 +    /// ```
 +    fn suggest_prepend_item(&mut self, cx: &T, item: Span, msg: &str, new_item: &str, applicability: Applicability);
 +
 +    /// Suggest to completely remove an item.
 +    ///
 +    /// This will remove an item and all following whitespace until the next non-whitespace
 +    /// character. This should work correctly if item is on the same indentation level as the
 +    /// following item.
 +    ///
 +    /// # Example
 +    ///
 +    /// ```rust,ignore
 +    /// diag.suggest_remove_item(cx, item, "remove this")
 +    /// ```
 +    fn suggest_remove_item(&mut self, cx: &T, item: Span, msg: &str, applicability: Applicability);
 +}
 +
 +impl<T: LintContext> DiagnosticBuilderExt<T> for rustc_errors::DiagnosticBuilder<'_> {
 +    fn suggest_item_with_attr<D: Display + ?Sized>(
 +        &mut self,
 +        cx: &T,
 +        item: Span,
 +        msg: &str,
 +        attr: &D,
 +        applicability: Applicability,
 +    ) {
 +        if let Some(indent) = indentation(cx, item) {
 +            let span = item.with_hi(item.lo());
 +
 +            self.span_suggestion(span, msg, format!("{}\n{}", attr, indent), applicability);
 +        }
 +    }
 +
 +    fn suggest_prepend_item(&mut self, cx: &T, item: Span, msg: &str, new_item: &str, applicability: Applicability) {
 +        if let Some(indent) = indentation(cx, item) {
 +            let span = item.with_hi(item.lo());
 +
 +            let mut first = true;
 +            let new_item = new_item
 +                .lines()
 +                .map(|l| {
 +                    if first {
 +                        first = false;
 +                        format!("{}\n", l)
 +                    } else {
 +                        format!("{}{}\n", indent, l)
 +                    }
 +                })
 +                .collect::<String>();
 +
 +            self.span_suggestion(span, msg, format!("{}\n{}", new_item, indent), applicability);
 +        }
 +    }
 +
 +    fn suggest_remove_item(&mut self, cx: &T, item: Span, msg: &str, applicability: Applicability) {
 +        let mut remove_span = item;
 +        let hi = cx.sess().source_map().next_point(remove_span).hi();
 +        let fmpos = cx.sess().source_map().lookup_byte_offset(hi);
 +
 +        if let Some(ref src) = fmpos.sf.src {
 +            let non_whitespace_offset = src[fmpos.pos.to_usize()..].find(|c| c != ' ' && c != '\t' && c != '\n');
 +
 +            if let Some(non_whitespace_offset) = non_whitespace_offset {
 +                remove_span = remove_span
 +                    .with_hi(remove_span.hi() + BytePos(non_whitespace_offset.try_into().expect("offset too large")));
 +            }
 +        }
 +
 +        self.span_suggestion(remove_span, msg, String::new(), applicability);
 +    }
 +}
 +
 +/// Suggestion results for handling closure
 +/// args dereferencing and borrowing
 +pub struct DerefClosure {
 +    /// confidence on the built suggestion
 +    pub applicability: Applicability,
 +    /// gradually built suggestion
 +    pub suggestion: String,
 +}
 +
 +/// Build suggestion gradually by handling closure arg specific usages,
 +/// such as explicit deref and borrowing cases.
 +/// Returns `None` if no such use cases have been triggered in closure body
 +///
 +/// note: this only works on single line immutable closures with exactly one input parameter.
 +pub fn deref_closure_args<'tcx>(cx: &LateContext<'_>, closure: &'tcx hir::Expr<'_>) -> Option<DerefClosure> {
 +    if let hir::ExprKind::Closure(_, fn_decl, body_id, ..) = closure.kind {
 +        let closure_body = cx.tcx.hir().body(body_id);
 +        // is closure arg a type annotated double reference (i.e.: `|x: &&i32| ...`)
 +        // a type annotation is present if param `kind` is different from `TyKind::Infer`
 +        let closure_arg_is_type_annotated_double_ref = if let TyKind::Rptr(_, MutTy { ty, .. }) = fn_decl.inputs[0].kind
 +        {
 +            matches!(ty.kind, TyKind::Rptr(_, MutTy { .. }))
 +        } else {
 +            false
 +        };
 +
 +        let mut visitor = DerefDelegate {
 +            cx,
 +            closure_span: closure.span,
 +            closure_arg_is_type_annotated_double_ref,
 +            next_pos: closure.span.lo(),
 +            suggestion_start: String::new(),
 +            applicability: Applicability::MaybeIncorrect,
 +        };
 +
 +        let fn_def_id = cx.tcx.hir().local_def_id(closure.hir_id);
 +        cx.tcx.infer_ctxt().enter(|infcx| {
 +            ExprUseVisitor::new(&mut visitor, &infcx, fn_def_id, cx.param_env, cx.typeck_results())
 +                .consume_body(closure_body);
 +        });
 +
 +        if !visitor.suggestion_start.is_empty() {
 +            return Some(DerefClosure {
 +                applicability: visitor.applicability,
 +                suggestion: visitor.finish(),
 +            });
 +        }
 +    }
 +    None
 +}
 +
 +/// Visitor struct used for tracking down
 +/// dereferencing and borrowing of closure's args
 +struct DerefDelegate<'a, 'tcx> {
 +    /// The late context of the lint
 +    cx: &'a LateContext<'tcx>,
 +    /// The span of the input closure to adapt
 +    closure_span: Span,
 +    /// Indicates if the arg of the closure is a type annotated double reference
 +    closure_arg_is_type_annotated_double_ref: bool,
 +    /// last position of the span to gradually build the suggestion
 +    next_pos: BytePos,
 +    /// starting part of the gradually built suggestion
 +    suggestion_start: String,
 +    /// confidence on the built suggestion
 +    applicability: Applicability,
 +}
 +
 +impl<'tcx> DerefDelegate<'_, 'tcx> {
 +    /// build final suggestion:
 +    /// - create the ending part of suggestion
 +    /// - concatenate starting and ending parts
 +    /// - potentially remove needless borrowing
 +    pub fn finish(&mut self) -> String {
 +        let end_span = Span::new(self.next_pos, self.closure_span.hi(), self.closure_span.ctxt(), None);
 +        let end_snip = snippet_with_applicability(self.cx, end_span, "..", &mut self.applicability);
 +        let sugg = format!("{}{}", self.suggestion_start, end_snip);
 +        if self.closure_arg_is_type_annotated_double_ref {
 +            sugg.replacen('&', "", 1)
 +        } else {
 +            sugg
 +        }
 +    }
 +
 +    /// indicates whether the function from `parent_expr` takes its args by double reference
 +    fn func_takes_arg_by_double_ref(&self, parent_expr: &'tcx hir::Expr<'_>, cmt_hir_id: HirId) -> bool {
 +        let (call_args, inputs) = match parent_expr.kind {
 +            ExprKind::MethodCall(_, call_args, _) => {
 +                if let Some(method_did) = self.cx.typeck_results().type_dependent_def_id(parent_expr.hir_id) {
 +                    (call_args, self.cx.tcx.fn_sig(method_did).skip_binder().inputs())
 +                } else {
 +                    return false;
 +                }
 +            },
 +            ExprKind::Call(func, call_args) => {
 +                let typ = self.cx.typeck_results().expr_ty(func);
 +                (call_args, typ.fn_sig(self.cx.tcx).skip_binder().inputs())
 +            },
 +            _ => return false,
 +        };
 +
 +        iter::zip(call_args, inputs)
 +            .any(|(arg, ty)| arg.hir_id == cmt_hir_id && matches!(ty.kind(), ty::Ref(_, inner, _) if inner.is_ref()))
 +    }
 +}
 +
 +impl<'tcx> Delegate<'tcx> for DerefDelegate<'_, 'tcx> {
 +    fn consume(&mut self, _: &PlaceWithHirId<'tcx>, _: HirId) {}
 +
 +    #[allow(clippy::too_many_lines)]
 +    fn borrow(&mut self, cmt: &PlaceWithHirId<'tcx>, _: HirId, _: ty::BorrowKind) {
 +        if let PlaceBase::Local(id) = cmt.place.base {
 +            let map = self.cx.tcx.hir();
 +            let span = map.span(cmt.hir_id);
 +            let start_span = Span::new(self.next_pos, span.lo(), span.ctxt(), None);
 +            let mut start_snip = snippet_with_applicability(self.cx, start_span, "..", &mut self.applicability);
 +
 +            // identifier referring to the variable currently triggered (i.e.: `fp`)
 +            let ident_str = map.name(id).to_string();
 +            // full identifier that includes projection (i.e.: `fp.field`)
 +            let ident_str_with_proj = snippet(self.cx, span, "..").to_string();
 +
 +            if cmt.place.projections.is_empty() {
 +                // handle item without any projection, that needs an explicit borrowing
 +                // i.e.: suggest `&x` instead of `x`
 +                self.suggestion_start.push_str(&format!("{}&{}", start_snip, ident_str));
 +            } else {
 +                // cases where a parent `Call` or `MethodCall` is using the item
 +                // i.e.: suggest `.contains(&x)` for `.find(|x| [1, 2, 3].contains(x)).is_none()`
 +                //
 +                // Note about method calls:
 +                // - compiler automatically dereference references if the target type is a reference (works also for
 +                //   function call)
 +                // - `self` arguments in the case of `x.is_something()` are also automatically (de)referenced, and
 +                //   no projection should be suggested
 +                if let Some(parent_expr) = get_parent_expr_for_hir(self.cx, cmt.hir_id) {
 +                    match &parent_expr.kind {
 +                        // given expression is the self argument and will be handled completely by the compiler
 +                        // i.e.: `|x| x.is_something()`
 +                        ExprKind::MethodCall(_, [self_expr, ..], _) if self_expr.hir_id == cmt.hir_id => {
 +                            self.suggestion_start
 +                                .push_str(&format!("{}{}", start_snip, ident_str_with_proj));
 +                            self.next_pos = span.hi();
 +                            return;
 +                        },
 +                        // item is used in a call
 +                        // i.e.: `Call`: `|x| please(x)` or `MethodCall`: `|x| [1, 2, 3].contains(x)`
 +                        ExprKind::Call(_, [call_args @ ..]) | ExprKind::MethodCall(_, [_, call_args @ ..], _) => {
 +                            let expr = self.cx.tcx.hir().expect_expr(cmt.hir_id);
 +                            let arg_ty_kind = self.cx.typeck_results().expr_ty(expr).kind();
 +
 +                            if matches!(arg_ty_kind, ty::Ref(_, _, Mutability::Not)) {
 +                                // suggest ampersand if call function is taking args by double reference
 +                                let takes_arg_by_double_ref =
 +                                    self.func_takes_arg_by_double_ref(parent_expr, cmt.hir_id);
 +
 +                                // compiler will automatically dereference field or index projection, so no need
 +                                // to suggest ampersand, but full identifier that includes projection is required
 +                                let has_field_or_index_projection =
 +                                    cmt.place.projections.iter().any(|proj| {
 +                                        matches!(proj.kind, ProjectionKind::Field(..) | ProjectionKind::Index)
 +                                    });
 +
 +                                // no need to bind again if the function doesn't take arg by double ref
 +                                // and if the item is already a double ref
 +                                let ident_sugg = if !call_args.is_empty()
 +                                    && !takes_arg_by_double_ref
 +                                    && (self.closure_arg_is_type_annotated_double_ref || has_field_or_index_projection)
 +                                {
 +                                    let ident = if has_field_or_index_projection {
 +                                        ident_str_with_proj
 +                                    } else {
 +                                        ident_str
 +                                    };
 +                                    format!("{}{}", start_snip, ident)
 +                                } else {
 +                                    format!("{}&{}", start_snip, ident_str)
 +                                };
 +                                self.suggestion_start.push_str(&ident_sugg);
 +                                self.next_pos = span.hi();
 +                                return;
 +                            }
 +
 +                            self.applicability = Applicability::Unspecified;
 +                        },
 +                        _ => (),
 +                    }
 +                }
 +
 +                let mut replacement_str = ident_str;
 +                let mut projections_handled = false;
 +                cmt.place.projections.iter().enumerate().for_each(|(i, proj)| {
 +                    match proj.kind {
 +                        // Field projection like `|v| v.foo`
 +                        // no adjustment needed here, as field projections are handled by the compiler
 +                        ProjectionKind::Field(..) => match cmt.place.ty_before_projection(i).kind() {
 +                            ty::Adt(..) | ty::Tuple(_) => {
 +                                replacement_str = ident_str_with_proj.clone();
 +                                projections_handled = true;
 +                            },
 +                            _ => (),
 +                        },
 +                        // Index projection like `|x| foo[x]`
 +                        // the index is dropped so we can't get it to build the suggestion,
 +                        // so the span is set-up again to get more code, using `span.hi()` (i.e.: `foo[x]`)
 +                        // instead of `span.lo()` (i.e.: `foo`)
 +                        ProjectionKind::Index => {
 +                            let start_span = Span::new(self.next_pos, span.hi(), span.ctxt(), None);
 +                            start_snip = snippet_with_applicability(self.cx, start_span, "..", &mut self.applicability);
 +                            replacement_str.clear();
 +                            projections_handled = true;
 +                        },
 +                        // note: unable to trigger `Subslice` kind in tests
 +                        ProjectionKind::Subslice => (),
 +                        ProjectionKind::Deref => {
 +                            // Explicit derefs are typically handled later on, but
 +                            // some items do not need explicit deref, such as array accesses,
 +                            // so we mark them as already processed
 +                            // i.e.: don't suggest `*sub[1..4].len()` for `|sub| sub[1..4].len() == 3`
 +                            if let ty::Ref(_, inner, _) = cmt.place.ty_before_projection(i).kind() {
 +                                if matches!(inner.kind(), ty::Ref(_, innermost, _) if innermost.is_array()) {
 +                                    projections_handled = true;
 +                                }
 +                            }
 +                        },
 +                    }
 +                });
 +
 +                // handle `ProjectionKind::Deref` by removing one explicit deref
 +                // if no special case was detected (i.e.: suggest `*x` instead of `**x`)
 +                if !projections_handled {
 +                    let last_deref = cmt
 +                        .place
 +                        .projections
 +                        .iter()
 +                        .rposition(|proj| proj.kind == ProjectionKind::Deref);
 +
 +                    if let Some(pos) = last_deref {
 +                        let mut projections = cmt.place.projections.clone();
 +                        projections.truncate(pos);
 +
 +                        for item in projections {
 +                            if item.kind == ProjectionKind::Deref {
 +                                replacement_str = format!("*{}", replacement_str);
 +                            }
 +                        }
 +                    }
 +                }
 +
 +                self.suggestion_start
 +                    .push_str(&format!("{}{}", start_snip, replacement_str));
 +            }
 +            self.next_pos = span.hi();
 +        }
 +    }
 +
 +    fn mutate(&mut self, _: &PlaceWithHirId<'tcx>, _: HirId) {}
 +
 +    fn fake_read(&mut self, _: rustc_typeck::expr_use_visitor::Place<'tcx>, _: FakeReadCause, _: HirId) {}
 +}
 +
 +#[cfg(test)]
 +mod test {
 +    use super::Sugg;
 +
 +    use rustc_ast::util::parser::AssocOp;
 +    use std::borrow::Cow;
 +
 +    const SUGGESTION: Sugg<'static> = Sugg::NonParen(Cow::Borrowed("function_call()"));
 +
 +    #[test]
 +    fn make_return_transform_sugg_into_a_return_call() {
 +        assert_eq!("return function_call()", SUGGESTION.make_return().to_string());
 +    }
 +
 +    #[test]
 +    fn blockify_transforms_sugg_into_a_block() {
 +        assert_eq!("{ function_call() }", SUGGESTION.blockify().to_string());
 +    }
 +
 +    #[test]
 +    fn binop_maybe_par() {
 +        let sugg = Sugg::BinOp(AssocOp::Add, "1".into(), "1".into());
 +        assert_eq!("(1 + 1)", sugg.maybe_par().to_string());
 +
 +        let sugg = Sugg::BinOp(AssocOp::Add, "(1 + 1)".into(), "(1 + 1)".into());
 +        assert_eq!("((1 + 1) + (1 + 1))", sugg.maybe_par().to_string());
 +    }
 +    #[test]
 +    fn not_op() {
 +        use AssocOp::{Add, Equal, Greater, GreaterEqual, LAnd, LOr, Less, LessEqual, NotEqual};
 +
 +        fn test_not(op: AssocOp, correct: &str) {
 +            let sugg = Sugg::BinOp(op, "x".into(), "y".into());
 +            assert_eq!((!sugg).to_string(), correct);
 +        }
 +
 +        // Invert the comparison operator.
 +        test_not(Equal, "x != y");
 +        test_not(NotEqual, "x == y");
 +        test_not(Less, "x >= y");
 +        test_not(LessEqual, "x > y");
 +        test_not(Greater, "x <= y");
 +        test_not(GreaterEqual, "x < y");
 +
 +        // Other operators are inverted like !(..).
 +        test_not(Add, "!(x + y)");
 +        test_not(LAnd, "!(x && y)");
 +        test_not(LOr, "!(x || y)");
 +    }
 +}
index f109b7845b4bdf7e63af2399cdba24b674fccc05,0000000000000000000000000000000000000000..d057da73302a25bc76d3109fc13557a76daa17f9
mode 100644,000000..100644
--- /dev/null
@@@ -1,412 -1,0 +1,517 @@@
- use rustc_hir::{TyKind, Unsafety};
 +//! Util methods for [`rustc_middle::ty`]
 +
 +#![allow(clippy::module_name_repetitions)]
 +
 +use rustc_ast::ast::Mutability;
 +use rustc_data_structures::fx::FxHashMap;
 +use rustc_hir as hir;
++use rustc_hir::def::{CtorKind, DefKind, Res};
 +use rustc_hir::def_id::DefId;
- use rustc_middle::ty::subst::{GenericArg, GenericArgKind};
- use rustc_middle::ty::{self, AdtDef, IntTy, Predicate, Ty, TyCtxt, TypeFoldable, UintTy};
++use rustc_hir::{Expr, TyKind, Unsafety};
 +use rustc_infer::infer::TyCtxtInferExt;
 +use rustc_lint::LateContext;
- use crate::{match_def_path, must_use_attr};
++use rustc_middle::ty::subst::{GenericArg, GenericArgKind, Subst};
++use rustc_middle::ty::{
++    self, AdtDef, Binder, FnSig, IntTy, Predicate, PredicateKind, Ty, TyCtxt, TypeFoldable, UintTy,
++};
 +use rustc_span::symbol::Ident;
 +use rustc_span::{sym, Span, Symbol, DUMMY_SP};
 +use rustc_trait_selection::infer::InferCtxtExt;
 +use rustc_trait_selection::traits::query::normalize::AtExt;
 +use std::iter;
 +
++use crate::{expr_path_res, match_def_path, must_use_attr};
 +
 +// Checks if the given type implements copy.
 +pub fn is_copy<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool {
 +    ty.is_copy_modulo_regions(cx.tcx.at(DUMMY_SP), cx.param_env)
 +}
 +
 +/// Checks whether a type can be partially moved.
 +pub fn can_partially_move_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool {
 +    if has_drop(cx, ty) || is_copy(cx, ty) {
 +        return false;
 +    }
 +    match ty.kind() {
 +        ty::Param(_) => false,
 +        ty::Adt(def, subs) => def.all_fields().any(|f| !is_copy(cx, f.ty(cx.tcx, subs))),
 +        _ => true,
 +    }
 +}
 +
 +/// Walks into `ty` and returns `true` if any inner type is the same as `other_ty`
 +pub fn contains_ty(ty: Ty<'_>, other_ty: Ty<'_>) -> bool {
 +    ty.walk().any(|inner| match inner.unpack() {
 +        GenericArgKind::Type(inner_ty) => ty::TyS::same_type(other_ty, inner_ty),
 +        GenericArgKind::Lifetime(_) | GenericArgKind::Const(_) => false,
 +    })
 +}
 +
 +/// Walks into `ty` and returns `true` if any inner type is an instance of the given adt
 +/// constructor.
 +pub fn contains_adt_constructor(ty: Ty<'_>, adt: &AdtDef) -> bool {
 +    ty.walk().any(|inner| match inner.unpack() {
 +        GenericArgKind::Type(inner_ty) => inner_ty.ty_adt_def() == Some(adt),
 +        GenericArgKind::Lifetime(_) | GenericArgKind::Const(_) => false,
 +    })
 +}
 +
 +/// Resolves `<T as Iterator>::Item` for `T`
 +/// Do not invoke without first verifying that the type implements `Iterator`
 +pub fn get_iterator_item_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option<Ty<'tcx>> {
 +    cx.tcx
 +        .get_diagnostic_item(sym::Iterator)
 +        .and_then(|iter_did| get_associated_type(cx, ty, iter_did, "Item"))
 +}
 +
 +/// Returns the associated type `name` for `ty` as an implementation of `trait_id`.
 +/// Do not invoke without first verifying that the type implements the trait.
 +pub fn get_associated_type<'tcx>(
 +    cx: &LateContext<'tcx>,
 +    ty: Ty<'tcx>,
 +    trait_id: DefId,
 +    name: &str,
 +) -> Option<Ty<'tcx>> {
 +    cx.tcx
 +        .associated_items(trait_id)
 +        .find_by_name_and_kind(cx.tcx, Ident::from_str(name), ty::AssocKind::Type, trait_id)
 +        .map(|assoc| {
 +            let proj = cx.tcx.mk_projection(assoc.def_id, cx.tcx.mk_substs_trait(ty, &[]));
 +            cx.tcx.normalize_erasing_regions(cx.param_env, proj)
 +        })
 +}
 +
 +/// Returns true if ty has `iter` or `iter_mut` methods
 +pub fn has_iter_method(cx: &LateContext<'_>, probably_ref_ty: Ty<'_>) -> Option<Symbol> {
 +    // FIXME: instead of this hard-coded list, we should check if `<adt>::iter`
 +    // exists and has the desired signature. Unfortunately FnCtxt is not exported
 +    // so we can't use its `lookup_method` method.
 +    let into_iter_collections: &[Symbol] = &[
 +        sym::Vec,
 +        sym::Option,
 +        sym::Result,
 +        sym::BTreeMap,
 +        sym::BTreeSet,
 +        sym::VecDeque,
 +        sym::LinkedList,
 +        sym::BinaryHeap,
 +        sym::HashSet,
 +        sym::HashMap,
 +        sym::PathBuf,
 +        sym::Path,
 +        sym::Receiver,
 +    ];
 +
 +    let ty_to_check = match probably_ref_ty.kind() {
 +        ty::Ref(_, ty_to_check, _) => ty_to_check,
 +        _ => probably_ref_ty,
 +    };
 +
 +    let def_id = match ty_to_check.kind() {
 +        ty::Array(..) => return Some(sym::array),
 +        ty::Slice(..) => return Some(sym::slice),
 +        ty::Adt(adt, _) => adt.did,
 +        _ => return None,
 +    };
 +
 +    for &name in into_iter_collections {
 +        if cx.tcx.is_diagnostic_item(name, def_id) {
 +            return Some(cx.tcx.item_name(def_id));
 +        }
 +    }
 +    None
 +}
 +
 +/// Checks whether a type implements a trait.
 +/// The function returns false in case the type contains an inference variable.
 +///
 +/// See:
 +/// * [`get_trait_def_id`](super::get_trait_def_id) to get a trait [`DefId`].
 +/// * [Common tools for writing lints] for an example how to use this function and other options.
 +///
 +/// [Common tools for writing lints]: https://github.com/rust-lang/rust-clippy/blob/master/doc/common_tools_writing_lints.md#checking-if-a-type-implements-a-specific-trait
 +pub fn implements_trait<'tcx>(
 +    cx: &LateContext<'tcx>,
 +    ty: Ty<'tcx>,
 +    trait_id: DefId,
 +    ty_params: &[GenericArg<'tcx>],
 +) -> bool {
 +    // Clippy shouldn't have infer types
 +    assert!(!ty.needs_infer());
 +
 +    let ty = cx.tcx.erase_regions(ty);
 +    if ty.has_escaping_bound_vars() {
 +        return false;
 +    }
 +    let ty_params = cx.tcx.mk_substs(ty_params.iter());
 +    cx.tcx.infer_ctxt().enter(|infcx| {
 +        infcx
 +            .type_implements_trait(trait_id, ty, ty_params, cx.param_env)
 +            .must_apply_modulo_regions()
 +    })
 +}
 +
 +/// Checks whether this type implements `Drop`.
 +pub fn has_drop<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool {
 +    match ty.ty_adt_def() {
 +        Some(def) => def.has_dtor(cx.tcx),
 +        None => false,
 +    }
 +}
 +
 +// Returns whether the type has #[must_use] attribute
 +pub fn is_must_use_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool {
 +    match ty.kind() {
 +        ty::Adt(adt, _) => must_use_attr(cx.tcx.get_attrs(adt.did)).is_some(),
 +        ty::Foreign(ref did) => must_use_attr(cx.tcx.get_attrs(*did)).is_some(),
 +        ty::Slice(ty) | ty::Array(ty, _) | ty::RawPtr(ty::TypeAndMut { ty, .. }) | ty::Ref(_, ty, _) => {
 +            // for the Array case we don't need to care for the len == 0 case
 +            // because we don't want to lint functions returning empty arrays
 +            is_must_use_ty(cx, *ty)
 +        },
 +        ty::Tuple(substs) => substs.types().any(|ty| is_must_use_ty(cx, ty)),
 +        ty::Opaque(ref def_id, _) => {
 +            for (predicate, _) in cx.tcx.explicit_item_bounds(*def_id) {
 +                if let ty::PredicateKind::Trait(trait_predicate) = predicate.kind().skip_binder() {
 +                    if must_use_attr(cx.tcx.get_attrs(trait_predicate.trait_ref.def_id)).is_some() {
 +                        return true;
 +                    }
 +                }
 +            }
 +            false
 +        },
 +        ty::Dynamic(binder, _) => {
 +            for predicate in binder.iter() {
 +                if let ty::ExistentialPredicate::Trait(ref trait_ref) = predicate.skip_binder() {
 +                    if must_use_attr(cx.tcx.get_attrs(trait_ref.def_id)).is_some() {
 +                        return true;
 +                    }
 +                }
 +            }
 +            false
 +        },
 +        _ => false,
 +    }
 +}
 +
 +// FIXME: Per https://doc.rust-lang.org/nightly/nightly-rustc/rustc_trait_selection/infer/at/struct.At.html#method.normalize
 +// this function can be removed once the `normalize` method does not panic when normalization does
 +// not succeed
 +/// Checks if `Ty` is normalizable. This function is useful
 +/// to avoid crashes on `layout_of`.
 +pub fn is_normalizable<'tcx>(cx: &LateContext<'tcx>, param_env: ty::ParamEnv<'tcx>, ty: Ty<'tcx>) -> bool {
 +    is_normalizable_helper(cx, param_env, ty, &mut FxHashMap::default())
 +}
 +
 +fn is_normalizable_helper<'tcx>(
 +    cx: &LateContext<'tcx>,
 +    param_env: ty::ParamEnv<'tcx>,
 +    ty: Ty<'tcx>,
 +    cache: &mut FxHashMap<Ty<'tcx>, bool>,
 +) -> bool {
 +    if let Some(&cached_result) = cache.get(ty) {
 +        return cached_result;
 +    }
 +    // prevent recursive loops, false-negative is better than endless loop leading to stack overflow
 +    cache.insert(ty, false);
 +    let result = cx.tcx.infer_ctxt().enter(|infcx| {
 +        let cause = rustc_middle::traits::ObligationCause::dummy();
 +        if infcx.at(&cause, param_env).normalize(ty).is_ok() {
 +            match ty.kind() {
 +                ty::Adt(def, substs) => def.variants.iter().all(|variant| {
 +                    variant
 +                        .fields
 +                        .iter()
 +                        .all(|field| is_normalizable_helper(cx, param_env, field.ty(cx.tcx, substs), cache))
 +                }),
 +                _ => ty.walk().all(|generic_arg| match generic_arg.unpack() {
 +                    GenericArgKind::Type(inner_ty) if inner_ty != ty => {
 +                        is_normalizable_helper(cx, param_env, inner_ty, cache)
 +                    },
 +                    _ => true, // if inner_ty == ty, we've already checked it
 +                }),
 +            }
 +        } else {
 +            false
 +        }
 +    });
 +    cache.insert(ty, result);
 +    result
 +}
 +
 +/// Returns `true` if the given type is a non aggregate primitive (a `bool` or `char`, any
 +/// integer or floating-point number type). For checking aggregation of primitive types (e.g.
 +/// tuples and slices of primitive type) see `is_recursively_primitive_type`
 +pub fn is_non_aggregate_primitive_type(ty: Ty<'_>) -> bool {
 +    matches!(ty.kind(), ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Float(_))
 +}
 +
 +/// Returns `true` if the given type is a primitive (a `bool` or `char`, any integer or
 +/// floating-point number type, a `str`, or an array, slice, or tuple of those types).
 +pub fn is_recursively_primitive_type(ty: Ty<'_>) -> bool {
 +    match ty.kind() {
 +        ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::Str => true,
 +        ty::Ref(_, inner, _) if *inner.kind() == ty::Str => true,
 +        ty::Array(inner_type, _) | ty::Slice(inner_type) => is_recursively_primitive_type(inner_type),
 +        ty::Tuple(inner_types) => inner_types.types().all(is_recursively_primitive_type),
 +        _ => false,
 +    }
 +}
 +
 +/// Checks if the type is a reference equals to a diagnostic item
 +pub fn is_type_ref_to_diagnostic_item(cx: &LateContext<'_>, ty: Ty<'_>, diag_item: Symbol) -> bool {
 +    match ty.kind() {
 +        ty::Ref(_, ref_ty, _) => match ref_ty.kind() {
 +            ty::Adt(adt, _) => cx.tcx.is_diagnostic_item(diag_item, adt.did),
 +            _ => false,
 +        },
 +        _ => false,
 +    }
 +}
 +
 +/// Checks if the type is equal to a diagnostic item. To check if a type implements a
 +/// trait marked with a diagnostic item use [`implements_trait`].
 +///
 +/// For a further exploitation what diagnostic items are see [diagnostic items] in
 +/// rustc-dev-guide.
 +///
 +/// ---
 +///
 +/// If you change the signature, remember to update the internal lint `MatchTypeOnDiagItem`
 +///
 +/// [Diagnostic Items]: https://rustc-dev-guide.rust-lang.org/diagnostics/diagnostic-items.html
 +pub fn is_type_diagnostic_item(cx: &LateContext<'_>, ty: Ty<'_>, diag_item: Symbol) -> bool {
 +    match ty.kind() {
 +        ty::Adt(adt, _) => cx.tcx.is_diagnostic_item(diag_item, adt.did),
 +        _ => false,
 +    }
 +}
 +
 +/// Checks if the type is equal to a lang item.
 +///
 +/// Returns `false` if the `LangItem` is not defined.
 +pub fn is_type_lang_item(cx: &LateContext<'_>, ty: Ty<'_>, lang_item: hir::LangItem) -> bool {
 +    match ty.kind() {
 +        ty::Adt(adt, _) => cx.tcx.lang_items().require(lang_item).map_or(false, |li| li == adt.did),
 +        _ => false,
 +    }
 +}
 +
 +/// Return `true` if the passed `typ` is `isize` or `usize`.
 +pub fn is_isize_or_usize(typ: Ty<'_>) -> bool {
 +    matches!(typ.kind(), ty::Int(IntTy::Isize) | ty::Uint(UintTy::Usize))
 +}
 +
 +/// Checks if type is struct, enum or union type with the given def path.
 +///
 +/// If the type is a diagnostic item, use `is_type_diagnostic_item` instead.
 +/// If you change the signature, remember to update the internal lint `MatchTypeOnDiagItem`
 +pub fn match_type(cx: &LateContext<'_>, ty: Ty<'_>, path: &[&str]) -> bool {
 +    match ty.kind() {
 +        ty::Adt(adt, _) => match_def_path(cx, adt.did, path),
 +        _ => false,
 +    }
 +}
 +
 +/// Peels off all references on the type. Returns the underlying type and the number of references
 +/// removed.
 +pub fn peel_mid_ty_refs(ty: Ty<'_>) -> (Ty<'_>, usize) {
 +    fn peel(ty: Ty<'_>, count: usize) -> (Ty<'_>, usize) {
 +        if let ty::Ref(_, ty, _) = ty.kind() {
 +            peel(ty, count + 1)
 +        } else {
 +            (ty, count)
 +        }
 +    }
 +    peel(ty, 0)
 +}
 +
 +/// Peels off all references on the type.Returns the underlying type, the number of references
 +/// removed, and whether the pointer is ultimately mutable or not.
 +pub fn peel_mid_ty_refs_is_mutable(ty: Ty<'_>) -> (Ty<'_>, usize, Mutability) {
 +    fn f(ty: Ty<'_>, count: usize, mutability: Mutability) -> (Ty<'_>, usize, Mutability) {
 +        match ty.kind() {
 +            ty::Ref(_, ty, Mutability::Mut) => f(ty, count + 1, mutability),
 +            ty::Ref(_, ty, Mutability::Not) => f(ty, count + 1, Mutability::Not),
 +            _ => (ty, count, mutability),
 +        }
 +    }
 +    f(ty, 0, Mutability::Mut)
 +}
 +
 +/// Returns `true` if the given type is an `unsafe` function.
 +pub fn type_is_unsafe_function<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool {
 +    match ty.kind() {
 +        ty::FnDef(..) | ty::FnPtr(_) => ty.fn_sig(cx.tcx).unsafety() == Unsafety::Unsafe,
 +        _ => false,
 +    }
 +}
 +
 +/// Returns the base type for HIR references and pointers.
 +pub fn walk_ptrs_hir_ty<'tcx>(ty: &'tcx hir::Ty<'tcx>) -> &'tcx hir::Ty<'tcx> {
 +    match ty.kind {
 +        TyKind::Ptr(ref mut_ty) | TyKind::Rptr(_, ref mut_ty) => walk_ptrs_hir_ty(mut_ty.ty),
 +        _ => ty,
 +    }
 +}
 +
 +/// Returns the base type for references and raw pointers, and count reference
 +/// depth.
 +pub fn walk_ptrs_ty_depth(ty: Ty<'_>) -> (Ty<'_>, usize) {
 +    fn inner(ty: Ty<'_>, depth: usize) -> (Ty<'_>, usize) {
 +        match ty.kind() {
 +            ty::Ref(_, ty, _) => inner(ty, depth + 1),
 +            _ => (ty, depth),
 +        }
 +    }
 +    inner(ty, 0)
 +}
 +
 +/// Returns `true` if types `a` and `b` are same types having same `Const` generic args,
 +/// otherwise returns `false`
 +pub fn same_type_and_consts<'tcx>(a: Ty<'tcx>, b: Ty<'tcx>) -> bool {
 +    match (&a.kind(), &b.kind()) {
 +        (&ty::Adt(did_a, substs_a), &ty::Adt(did_b, substs_b)) => {
 +            if did_a != did_b {
 +                return false;
 +            }
 +
 +            substs_a
 +                .iter()
 +                .zip(substs_b.iter())
 +                .all(|(arg_a, arg_b)| match (arg_a.unpack(), arg_b.unpack()) {
 +                    (GenericArgKind::Const(inner_a), GenericArgKind::Const(inner_b)) => inner_a == inner_b,
 +                    (GenericArgKind::Type(type_a), GenericArgKind::Type(type_b)) => {
 +                        same_type_and_consts(type_a, type_b)
 +                    },
 +                    _ => true,
 +                })
 +        },
 +        _ => a == b,
 +    }
 +}
 +
 +/// Checks if a given type looks safe to be uninitialized.
 +pub fn is_uninit_value_valid_for_ty(cx: &LateContext<'_>, ty: Ty<'_>) -> bool {
 +    match ty.kind() {
 +        ty::Array(component, _) => is_uninit_value_valid_for_ty(cx, component),
 +        ty::Tuple(types) => types.types().all(|ty| is_uninit_value_valid_for_ty(cx, ty)),
 +        ty::Adt(adt, _) => cx.tcx.lang_items().maybe_uninit() == Some(adt.did),
 +        _ => false,
 +    }
 +}
 +
 +/// Gets an iterator over all predicates which apply to the given item.
 +pub fn all_predicates_of(tcx: TyCtxt<'_>, id: DefId) -> impl Iterator<Item = &(Predicate<'_>, Span)> {
 +    let mut next_id = Some(id);
 +    iter::from_fn(move || {
 +        next_id.take().map(|id| {
 +            let preds = tcx.predicates_of(id);
 +            next_id = preds.parent;
 +            preds.predicates.iter()
 +        })
 +    })
 +    .flatten()
 +}
++
++/// A signature for a function like type.
++#[derive(Clone, Copy)]
++pub enum ExprFnSig<'tcx> {
++    Sig(Binder<'tcx, FnSig<'tcx>>),
++    Closure(Binder<'tcx, FnSig<'tcx>>),
++    Trait(Binder<'tcx, Ty<'tcx>>, Option<Binder<'tcx, Ty<'tcx>>>),
++}
++impl<'tcx> ExprFnSig<'tcx> {
++    /// Gets the argument type at the given offset.
++    pub fn input(self, i: usize) -> Binder<'tcx, Ty<'tcx>> {
++        match self {
++            Self::Sig(sig) => sig.input(i),
++            Self::Closure(sig) => sig.input(0).map_bound(|ty| ty.tuple_element_ty(i).unwrap()),
++            Self::Trait(inputs, _) => inputs.map_bound(|ty| ty.tuple_element_ty(i).unwrap()),
++        }
++    }
++
++    /// Gets the result type, if one could be found. Note that the result type of a trait may not be
++    /// specified.
++    pub fn output(self) -> Option<Binder<'tcx, Ty<'tcx>>> {
++        match self {
++            Self::Sig(sig) | Self::Closure(sig) => Some(sig.output()),
++            Self::Trait(_, output) => output,
++        }
++    }
++}
++
++/// If the expression is function like, get the signature for it.
++pub fn expr_sig<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'_>) -> Option<ExprFnSig<'tcx>> {
++    if let Res::Def(DefKind::Fn | DefKind::Ctor(_, CtorKind::Fn) | DefKind::AssocFn, id) = expr_path_res(cx, expr) {
++        Some(ExprFnSig::Sig(cx.tcx.fn_sig(id)))
++    } else {
++        let ty = cx.typeck_results().expr_ty_adjusted(expr).peel_refs();
++        match *ty.kind() {
++            ty::Closure(_, subs) => Some(ExprFnSig::Closure(subs.as_closure().sig())),
++            ty::FnDef(id, subs) => Some(ExprFnSig::Sig(cx.tcx.fn_sig(id).subst(cx.tcx, subs))),
++            ty::FnPtr(sig) => Some(ExprFnSig::Sig(sig)),
++            ty::Dynamic(bounds, _) => {
++                let lang_items = cx.tcx.lang_items();
++                match bounds.principal() {
++                    Some(bound)
++                        if Some(bound.def_id()) == lang_items.fn_trait()
++                            || Some(bound.def_id()) == lang_items.fn_once_trait()
++                            || Some(bound.def_id()) == lang_items.fn_mut_trait() =>
++                    {
++                        let output = bounds
++                            .projection_bounds()
++                            .find(|p| lang_items.fn_once_output().map_or(false, |id| id == p.item_def_id()))
++                            .map(|p| p.map_bound(|p| p.term.ty().expect("return type was a const")));
++                        Some(ExprFnSig::Trait(bound.map_bound(|b| b.substs.type_at(0)), output))
++                    },
++                    _ => None,
++                }
++            },
++            ty::Param(_) | ty::Projection(..) => {
++                let mut inputs = None;
++                let mut output = None;
++                let lang_items = cx.tcx.lang_items();
++
++                for (pred, _) in all_predicates_of(cx.tcx, cx.typeck_results().hir_owner.to_def_id()) {
++                    let mut is_input = false;
++                    if let Some(ty) = pred
++                        .kind()
++                        .map_bound(|pred| match pred {
++                            PredicateKind::Trait(p)
++                                if (lang_items.fn_trait() == Some(p.def_id())
++                                    || lang_items.fn_mut_trait() == Some(p.def_id())
++                                    || lang_items.fn_once_trait() == Some(p.def_id()))
++                                    && p.self_ty() == ty =>
++                            {
++                                is_input = true;
++                                Some(p.trait_ref.substs.type_at(1))
++                            },
++                            PredicateKind::Projection(p)
++                                if Some(p.projection_ty.item_def_id) == lang_items.fn_once_output()
++                                    && p.projection_ty.self_ty() == ty =>
++                            {
++                                is_input = false;
++                                p.term.ty()
++                            },
++                            _ => None,
++                        })
++                        .transpose()
++                    {
++                        if is_input && inputs.is_none() {
++                            inputs = Some(ty);
++                        } else if !is_input && output.is_none() {
++                            output = Some(ty);
++                        } else {
++                            // Multiple different fn trait impls. Is this even allowed?
++                            return None;
++                        }
++                    }
++                }
++
++                inputs.map(|ty| ExprFnSig::Trait(ty, output))
++            },
++            _ => None,
++        }
++    }
++}
index e6a58e92072501a2f4bc8293392634d5bae93cac,0000000000000000000000000000000000000000..e23dc73ab08c1233e51d9b926923e2790fbabb5c
mode 100644,000000..100644
--- /dev/null
@@@ -1,3 -1,0 +1,3 @@@
- channel = "nightly-2022-01-13"
 +[toolchain]
++channel = "nightly-2022-01-27"
 +components = ["cargo", "llvm-tools-preview", "rust-src", "rust-std", "rustc", "rustc-dev", "rustfmt"]
index a8aa3a76abc6c04a2bc1ec508af74ba946c96c45,0000000000000000000000000000000000000000..8f8f1140a3da62e86f030a16f10abacaccb9d6df
mode 100644,000000..100644
--- /dev/null
@@@ -1,349 -1,0 +1,348 @@@
-         let clippy_tests_set = env::var("__CLIPPY_INTERNAL_TESTS").map_or(false, |val| val == "true");
 +#![feature(rustc_private)]
 +#![feature(once_cell)]
 +#![cfg_attr(feature = "deny-warnings", deny(warnings))]
 +// warn on lints, that are included in `rust-lang/rust`s bootstrap
 +#![warn(rust_2018_idioms, unused_lifetimes)]
 +// warn on rustc internal lints
 +#![warn(rustc::internal)]
 +
 +// FIXME: switch to something more ergonomic here, once available.
 +// (Currently there is no way to opt into sysroot crates without `extern crate`.)
 +extern crate rustc_driver;
 +extern crate rustc_errors;
 +extern crate rustc_interface;
 +extern crate rustc_session;
 +extern crate rustc_span;
 +
 +use rustc_interface::interface;
 +use rustc_session::parse::ParseSess;
 +use rustc_span::symbol::Symbol;
 +use rustc_tools_util::VersionInfo;
 +
 +use std::borrow::Cow;
 +use std::env;
 +use std::lazy::SyncLazy;
 +use std::ops::Deref;
 +use std::panic;
 +use std::path::{Path, PathBuf};
 +use std::process::{exit, Command};
 +
 +/// If a command-line option matches `find_arg`, then apply the predicate `pred` on its value. If
 +/// true, then return it. The parameter is assumed to be either `--arg=value` or `--arg value`.
 +fn arg_value<'a, T: Deref<Target = str>>(
 +    args: &'a [T],
 +    find_arg: &str,
 +    pred: impl Fn(&str) -> bool,
 +) -> Option<&'a str> {
 +    let mut args = args.iter().map(Deref::deref);
 +    while let Some(arg) = args.next() {
 +        let mut arg = arg.splitn(2, '=');
 +        if arg.next() != Some(find_arg) {
 +            continue;
 +        }
 +
 +        match arg.next().or_else(|| args.next()) {
 +            Some(v) if pred(v) => return Some(v),
 +            _ => {},
 +        }
 +    }
 +    None
 +}
 +
 +#[test]
 +fn test_arg_value() {
 +    let args = &["--bar=bar", "--foobar", "123", "--foo"];
 +
 +    assert_eq!(arg_value(&[] as &[&str], "--foobar", |_| true), None);
 +    assert_eq!(arg_value(args, "--bar", |_| false), None);
 +    assert_eq!(arg_value(args, "--bar", |_| true), Some("bar"));
 +    assert_eq!(arg_value(args, "--bar", |p| p == "bar"), Some("bar"));
 +    assert_eq!(arg_value(args, "--bar", |p| p == "foo"), None);
 +    assert_eq!(arg_value(args, "--foobar", |p| p == "foo"), None);
 +    assert_eq!(arg_value(args, "--foobar", |p| p == "123"), Some("123"));
 +    assert_eq!(arg_value(args, "--foo", |_| true), None);
 +}
 +
 +fn track_clippy_args(parse_sess: &mut ParseSess, args_env_var: &Option<String>) {
 +    parse_sess.env_depinfo.get_mut().insert((
 +        Symbol::intern("CLIPPY_ARGS"),
 +        args_env_var.as_deref().map(Symbol::intern),
 +    ));
 +}
 +
 +struct DefaultCallbacks;
 +impl rustc_driver::Callbacks for DefaultCallbacks {}
 +
 +/// This is different from `DefaultCallbacks` that it will inform Cargo to track the value of
 +/// `CLIPPY_ARGS` environment variable.
 +struct RustcCallbacks {
 +    clippy_args_var: Option<String>,
 +}
 +
 +impl rustc_driver::Callbacks for RustcCallbacks {
 +    fn config(&mut self, config: &mut interface::Config) {
 +        let clippy_args_var = self.clippy_args_var.take();
 +        config.parse_sess_created = Some(Box::new(move |parse_sess| {
 +            track_clippy_args(parse_sess, &clippy_args_var);
 +        }));
 +    }
 +}
 +
 +struct ClippyCallbacks {
 +    clippy_args_var: Option<String>,
 +}
 +
 +impl rustc_driver::Callbacks for ClippyCallbacks {
 +    fn config(&mut self, config: &mut interface::Config) {
 +        let previous = config.register_lints.take();
 +        let clippy_args_var = self.clippy_args_var.take();
 +        config.parse_sess_created = Some(Box::new(move |parse_sess| {
 +            track_clippy_args(parse_sess, &clippy_args_var);
 +        }));
 +        config.register_lints = Some(Box::new(move |sess, lint_store| {
 +            // technically we're ~guaranteed that this is none but might as well call anything that
 +            // is there already. Certainly it can't hurt.
 +            if let Some(previous) = &previous {
 +                (previous)(sess, lint_store);
 +            }
 +
 +            let conf = clippy_lints::read_conf(sess);
 +            clippy_lints::register_plugins(lint_store, sess, &conf);
 +            clippy_lints::register_pre_expansion_lints(lint_store, sess, &conf);
 +            clippy_lints::register_renamed(lint_store);
 +        }));
 +
 +        // FIXME: #4825; This is required, because Clippy lints that are based on MIR have to be
 +        // run on the unoptimized MIR. On the other hand this results in some false negatives. If
 +        // MIR passes can be enabled / disabled separately, we should figure out, what passes to
 +        // use for Clippy.
 +        config.opts.debugging_opts.mir_opt_level = Some(0);
 +    }
 +}
 +
 +fn display_help() {
 +    println!(
 +        "\
 +Checks a package to catch common mistakes and improve your Rust code.
 +
 +Usage:
 +    cargo clippy [options] [--] [<opts>...]
 +
 +Common options:
 +    -h, --help               Print this message
 +        --rustc              Pass all args to rustc
 +    -V, --version            Print version info and exit
 +
 +Other options are the same as `cargo check`.
 +
 +To allow or deny a lint from the command line you can use `cargo clippy --`
 +with:
 +
 +    -W --warn OPT       Set lint warnings
 +    -A --allow OPT      Set lint allowed
 +    -D --deny OPT       Set lint denied
 +    -F --forbid OPT     Set lint forbidden
 +
 +You can use tool lints to allow or deny lints from your code, eg.:
 +
 +    #[allow(clippy::needless_lifetimes)]
 +"
 +    );
 +}
 +
 +const BUG_REPORT_URL: &str = "https://github.com/rust-lang/rust-clippy/issues/new";
 +
 +static ICE_HOOK: SyncLazy<Box<dyn Fn(&panic::PanicInfo<'_>) + Sync + Send + 'static>> = SyncLazy::new(|| {
 +    let hook = panic::take_hook();
 +    panic::set_hook(Box::new(|info| report_clippy_ice(info, BUG_REPORT_URL)));
 +    hook
 +});
 +
 +fn report_clippy_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) {
 +    // Invoke our ICE handler, which prints the actual panic message and optionally a backtrace
 +    (*ICE_HOOK)(info);
 +
 +    // Separate the output with an empty line
 +    eprintln!();
 +
 +    let emitter = Box::new(rustc_errors::emitter::EmitterWriter::stderr(
 +        rustc_errors::ColorConfig::Auto,
 +        None,
 +        false,
 +        false,
 +        None,
 +        false,
 +    ));
 +    let handler = rustc_errors::Handler::with_emitter(true, None, emitter);
 +
 +    // a .span_bug or .bug call has already printed what
 +    // it wants to print.
 +    if !info.payload().is::<rustc_errors::ExplicitBug>() {
 +        let d = rustc_errors::Diagnostic::new(rustc_errors::Level::Bug, "unexpected panic");
 +        handler.emit_diagnostic(&d);
 +    }
 +
 +    let version_info = rustc_tools_util::get_version_info!();
 +
 +    let xs: Vec<Cow<'static, str>> = vec![
 +        "the compiler unexpectedly panicked. this is a bug.".into(),
 +        format!("we would appreciate a bug report: {}", bug_report_url).into(),
 +        format!("Clippy version: {}", version_info).into(),
 +    ];
 +
 +    for note in &xs {
 +        handler.note_without_error(note);
 +    }
 +
 +    // If backtraces are enabled, also print the query stack
 +    let backtrace = env::var_os("RUST_BACKTRACE").map_or(false, |x| &x != "0");
 +
 +    let num_frames = if backtrace { None } else { Some(2) };
 +
 +    interface::try_print_query_stack(&handler, num_frames);
 +}
 +
 +fn toolchain_path(home: Option<String>, toolchain: Option<String>) -> Option<PathBuf> {
 +    home.and_then(|home| {
 +        toolchain.map(|toolchain| {
 +            let mut path = PathBuf::from(home);
 +            path.push("toolchains");
 +            path.push(toolchain);
 +            path
 +        })
 +    })
 +}
 +
 +#[allow(clippy::too_many_lines)]
 +pub fn main() {
 +    rustc_driver::init_rustc_env_logger();
 +    SyncLazy::force(&ICE_HOOK);
 +    exit(rustc_driver::catch_with_exit_code(move || {
 +        let mut orig_args: Vec<String> = env::args().collect();
 +
 +        // Get the sysroot, looking from most specific to this invocation to the least:
 +        // - command line
 +        // - runtime environment
 +        //    - SYSROOT
 +        //    - RUSTUP_HOME, MULTIRUST_HOME, RUSTUP_TOOLCHAIN, MULTIRUST_TOOLCHAIN
 +        // - sysroot from rustc in the path
 +        // - compile-time environment
 +        //    - SYSROOT
 +        //    - RUSTUP_HOME, MULTIRUST_HOME, RUSTUP_TOOLCHAIN, MULTIRUST_TOOLCHAIN
 +        let sys_root_arg = arg_value(&orig_args, "--sysroot", |_| true);
 +        let have_sys_root_arg = sys_root_arg.is_some();
 +        let sys_root = sys_root_arg
 +            .map(PathBuf::from)
 +            .or_else(|| std::env::var("SYSROOT").ok().map(PathBuf::from))
 +            .or_else(|| {
 +                let home = std::env::var("RUSTUP_HOME")
 +                    .or_else(|_| std::env::var("MULTIRUST_HOME"))
 +                    .ok();
 +                let toolchain = std::env::var("RUSTUP_TOOLCHAIN")
 +                    .or_else(|_| std::env::var("MULTIRUST_TOOLCHAIN"))
 +                    .ok();
 +                toolchain_path(home, toolchain)
 +            })
 +            .or_else(|| {
 +                Command::new("rustc")
 +                    .arg("--print")
 +                    .arg("sysroot")
 +                    .output()
 +                    .ok()
 +                    .and_then(|out| String::from_utf8(out.stdout).ok())
 +                    .map(|s| PathBuf::from(s.trim()))
 +            })
 +            .or_else(|| option_env!("SYSROOT").map(PathBuf::from))
 +            .or_else(|| {
 +                let home = option_env!("RUSTUP_HOME")
 +                    .or(option_env!("MULTIRUST_HOME"))
 +                    .map(ToString::to_string);
 +                let toolchain = option_env!("RUSTUP_TOOLCHAIN")
 +                    .or(option_env!("MULTIRUST_TOOLCHAIN"))
 +                    .map(ToString::to_string);
 +                toolchain_path(home, toolchain)
 +            })
 +            .map(|pb| pb.to_string_lossy().to_string())
 +            .expect("need to specify SYSROOT env var during clippy compilation, or use rustup or multirust");
 +
 +        // make "clippy-driver --rustc" work like a subcommand that passes further args to "rustc"
 +        // for example `clippy-driver --rustc --version` will print the rustc version that clippy-driver
 +        // uses
 +        if let Some(pos) = orig_args.iter().position(|arg| arg == "--rustc") {
 +            orig_args.remove(pos);
 +            orig_args[0] = "rustc".to_string();
 +
 +            // if we call "rustc", we need to pass --sysroot here as well
 +            let mut args: Vec<String> = orig_args.clone();
 +            if !have_sys_root_arg {
 +                args.extend(vec!["--sysroot".into(), sys_root]);
 +            };
 +
 +            return rustc_driver::RunCompiler::new(&args, &mut DefaultCallbacks).run();
 +        }
 +
 +        if orig_args.iter().any(|a| a == "--version" || a == "-V") {
 +            let version_info = rustc_tools_util::get_version_info!();
 +            println!("{}", version_info);
 +            exit(0);
 +        }
 +
 +        // Setting RUSTC_WRAPPER causes Cargo to pass 'rustc' as the first argument.
 +        // We're invoking the compiler programmatically, so we ignore this/
 +        let wrapper_mode = orig_args.get(1).map(Path::new).and_then(Path::file_stem) == Some("rustc".as_ref());
 +
 +        if wrapper_mode {
 +            // we still want to be able to invoke it normally though
 +            orig_args.remove(1);
 +        }
 +
 +        if !wrapper_mode && (orig_args.iter().any(|a| a == "--help" || a == "-h") || orig_args.len() == 1) {
 +            display_help();
 +            exit(0);
 +        }
 +
 +        // this conditional check for the --sysroot flag is there so users can call
 +        // `clippy_driver` directly
 +        // without having to pass --sysroot or anything
 +        let mut args: Vec<String> = orig_args.clone();
 +        if !have_sys_root_arg {
 +            args.extend(vec!["--sysroot".into(), sys_root]);
 +        };
 +
 +        let mut no_deps = false;
 +        let clippy_args_var = env::var("CLIPPY_ARGS").ok();
 +        let clippy_args = clippy_args_var
 +            .as_deref()
 +            .unwrap_or_default()
 +            .split("__CLIPPY_HACKERY__")
 +            .filter_map(|s| match s {
 +                "" => None,
 +                "--no-deps" => {
 +                    no_deps = true;
 +                    None
 +                },
 +                _ => Some(s.to_string()),
 +            })
 +            .chain(vec!["--cfg".into(), r#"feature="cargo-clippy""#.into()])
 +            .collect::<Vec<String>>();
 +
 +        // We enable Clippy if one of the following conditions is met
 +        // - IF Clippy is run on its test suite OR
 +        // - IF Clippy is run on the main crate, not on deps (`!cap_lints_allow`) THEN
 +        //    - IF `--no-deps` is not set (`!no_deps`) OR
 +        //    - IF `--no-deps` is set and Clippy is run on the specified primary package
-         let clippy_enabled = clippy_tests_set || (!cap_lints_allow && (!no_deps || in_primary_package));
 +        let cap_lints_allow = arg_value(&orig_args, "--cap-lints", |val| val == "allow").is_some();
 +        let in_primary_package = env::var("CARGO_PRIMARY_PACKAGE").is_ok();
 +
++        let clippy_enabled = !cap_lints_allow && (!no_deps || in_primary_package);
 +        if clippy_enabled {
 +            args.extend(clippy_args);
 +        }
 +
 +        if clippy_enabled {
 +            rustc_driver::RunCompiler::new(&args, &mut ClippyCallbacks { clippy_args_var }).run()
 +        } else {
 +            rustc_driver::RunCompiler::new(&args, &mut RustcCallbacks { clippy_args_var }).run()
 +        }
 +    }))
 +}
index 531890c863f5efeda3642e73a67029ea1e879f63,0000000000000000000000000000000000000000..6505028db9fadc1f5e75e62e468bcde1d805d737
mode 100644,000000..100644
--- /dev/null
@@@ -1,370 -1,0 +1,364 @@@
- fn prepare_env() {
-     set_var("CLIPPY_DISABLE_DOCS_LINKS", "true");
-     set_var("__CLIPPY_INTERNAL_TESTS", "true");
-     //set_var("RUST_BACKTRACE", "0");
- }
 +#![feature(test)] // compiletest_rs requires this attribute
 +#![feature(once_cell)]
 +#![cfg_attr(feature = "deny-warnings", deny(warnings))]
 +#![warn(rust_2018_idioms, unused_lifetimes)]
 +
 +use compiletest_rs as compiletest;
 +use compiletest_rs::common::Mode as TestMode;
 +
 +use std::collections::HashMap;
 +use std::env::{self, remove_var, set_var, var_os};
 +use std::ffi::{OsStr, OsString};
 +use std::fs;
 +use std::io;
 +use std::path::{Path, PathBuf};
 +use test_utils::IS_RUSTC_TEST_SUITE;
 +
 +mod test_utils;
 +
 +// whether to run internal tests or not
 +const RUN_INTERNAL_TESTS: bool = cfg!(feature = "internal");
 +
 +/// All crates used in UI tests are listed here
 +static TEST_DEPENDENCIES: &[&str] = &[
 +    "clippy_utils",
 +    "derive_new",
 +    "futures",
 +    "if_chain",
 +    "itertools",
 +    "quote",
 +    "regex",
 +    "serde",
 +    "serde_derive",
 +    "syn",
 +    "tokio",
 +    "parking_lot",
 +];
 +
 +// Test dependencies may need an `extern crate` here to ensure that they show up
 +// in the depinfo file (otherwise cargo thinks they are unused)
 +#[allow(unused_extern_crates)]
 +extern crate clippy_utils;
 +#[allow(unused_extern_crates)]
 +extern crate derive_new;
 +#[allow(unused_extern_crates)]
 +extern crate futures;
 +#[allow(unused_extern_crates)]
 +extern crate if_chain;
 +#[allow(unused_extern_crates)]
 +extern crate itertools;
 +#[allow(unused_extern_crates)]
 +extern crate parking_lot;
 +#[allow(unused_extern_crates)]
 +extern crate quote;
 +#[allow(unused_extern_crates)]
 +extern crate syn;
 +#[allow(unused_extern_crates)]
 +extern crate tokio;
 +
 +/// Produces a string with an `--extern` flag for all UI test crate
 +/// dependencies.
 +///
 +/// The dependency files are located by parsing the depinfo file for this test
 +/// module. This assumes the `-Z binary-dep-depinfo` flag is enabled. All test
 +/// dependencies must be added to Cargo.toml at the project root. Test
 +/// dependencies that are not *directly* used by this test module require an
 +/// `extern crate` declaration.
 +fn extern_flags() -> String {
 +    let current_exe_depinfo = {
 +        let mut path = env::current_exe().unwrap();
 +        path.set_extension("d");
 +        std::fs::read_to_string(path).unwrap()
 +    };
 +    let mut crates: HashMap<&str, &str> = HashMap::with_capacity(TEST_DEPENDENCIES.len());
 +    for line in current_exe_depinfo.lines() {
 +        // each dependency is expected to have a Makefile rule like `/path/to/crate-hash.rlib:`
 +        let parse_name_path = || {
 +            if line.starts_with(char::is_whitespace) {
 +                return None;
 +            }
 +            let path_str = line.strip_suffix(':')?;
 +            let path = Path::new(path_str);
 +            if !matches!(path.extension()?.to_str()?, "rlib" | "so" | "dylib" | "dll") {
 +                return None;
 +            }
 +            let (name, _hash) = path.file_stem()?.to_str()?.rsplit_once('-')?;
 +            // the "lib" prefix is not present for dll files
 +            let name = name.strip_prefix("lib").unwrap_or(name);
 +            Some((name, path_str))
 +        };
 +        if let Some((name, path)) = parse_name_path() {
 +            if TEST_DEPENDENCIES.contains(&name) {
 +                // A dependency may be listed twice if it is available in sysroot,
 +                // and the sysroot dependencies are listed first. As of the writing,
 +                // this only seems to apply to if_chain.
 +                crates.insert(name, path);
 +            }
 +        }
 +    }
 +    let not_found: Vec<&str> = TEST_DEPENDENCIES
 +        .iter()
 +        .copied()
 +        .filter(|n| !crates.contains_key(n))
 +        .collect();
 +    assert!(
 +        not_found.is_empty(),
 +        "dependencies not found in depinfo: {:?}\n\
 +        help: Make sure the `-Z binary-dep-depinfo` rust flag is enabled\n\
 +        help: Try adding to dev-dependencies in Cargo.toml",
 +        not_found
 +    );
 +    crates
 +        .into_iter()
 +        .map(|(name, path)| format!(" --extern {}={}", name, path))
 +        .collect()
 +}
 +
 +fn default_config() -> compiletest::Config {
 +    let mut config = compiletest::Config {
 +        edition: Some("2021".into()),
 +        ..compiletest::Config::default()
 +    };
 +
 +    if let Ok(filters) = env::var("TESTNAME") {
 +        config.filters = filters.split(',').map(std::string::ToString::to_string).collect();
 +    }
 +
 +    if let Some(path) = option_env!("RUSTC_LIB_PATH") {
 +        let path = PathBuf::from(path);
 +        config.run_lib_path = path.clone();
 +        config.compile_lib_path = path;
 +    }
 +    let current_exe_path = std::env::current_exe().unwrap();
 +    let deps_path = current_exe_path.parent().unwrap();
 +    let profile_path = deps_path.parent().unwrap();
 +
 +    // Using `-L dependency={}` enforces that external dependencies are added with `--extern`.
 +    // This is valuable because a) it allows us to monitor what external dependencies are used
 +    // and b) it ensures that conflicting rlibs are resolved properly.
 +    let host_libs = option_env!("HOST_LIBS")
 +        .map(|p| format!(" -L dependency={}", Path::new(p).join("deps").display()))
 +        .unwrap_or_default();
 +    config.target_rustcflags = Some(format!(
 +        "--emit=metadata -Dwarnings -Zui-testing -L dependency={}{}{}",
 +        deps_path.display(),
 +        host_libs,
 +        extern_flags(),
 +    ));
 +
 +    config.build_base = profile_path.join("test");
 +    config.rustc_path = profile_path.join(if cfg!(windows) {
 +        "clippy-driver.exe"
 +    } else {
 +        "clippy-driver"
 +    });
 +    config
 +}
 +
 +fn run_ui(cfg: &mut compiletest::Config) {
 +    cfg.mode = TestMode::Ui;
 +    cfg.src_base = Path::new("tests").join("ui");
 +    // use tests/clippy.toml
 +    let _g = VarGuard::set("CARGO_MANIFEST_DIR", std::fs::canonicalize("tests").unwrap());
 +    compiletest::run_tests(cfg);
 +}
 +
 +fn run_ui_test(cfg: &mut compiletest::Config) {
 +    cfg.mode = TestMode::Ui;
 +    cfg.src_base = Path::new("tests").join("ui_test");
 +    let _g = VarGuard::set("CARGO_MANIFEST_DIR", std::fs::canonicalize("tests").unwrap());
 +    let rustcflags = cfg.target_rustcflags.get_or_insert_with(Default::default);
 +    let len = rustcflags.len();
 +    rustcflags.push_str(" --test");
 +    compiletest::run_tests(cfg);
 +    if let Some(ref mut flags) = &mut cfg.target_rustcflags {
 +        flags.truncate(len);
 +    }
 +}
 +
 +fn run_internal_tests(cfg: &mut compiletest::Config) {
 +    // only run internal tests with the internal-tests feature
 +    if !RUN_INTERNAL_TESTS {
 +        return;
 +    }
 +    cfg.mode = TestMode::Ui;
 +    cfg.src_base = Path::new("tests").join("ui-internal");
 +    compiletest::run_tests(cfg);
 +}
 +
 +fn run_ui_toml(config: &mut compiletest::Config) {
 +    fn run_tests(config: &compiletest::Config, mut tests: Vec<tester::TestDescAndFn>) -> Result<bool, io::Error> {
 +        let mut result = true;
 +        let opts = compiletest::test_opts(config);
 +        for dir in fs::read_dir(&config.src_base)? {
 +            let dir = dir?;
 +            if !dir.file_type()?.is_dir() {
 +                continue;
 +            }
 +            let dir_path = dir.path();
 +            let _g = VarGuard::set("CARGO_MANIFEST_DIR", &dir_path);
 +            for file in fs::read_dir(&dir_path)? {
 +                let file = file?;
 +                let file_path = file.path();
 +                if file.file_type()?.is_dir() {
 +                    continue;
 +                }
 +                if file_path.extension() != Some(OsStr::new("rs")) {
 +                    continue;
 +                }
 +                let paths = compiletest::common::TestPaths {
 +                    file: file_path,
 +                    base: config.src_base.clone(),
 +                    relative_dir: dir_path.file_name().unwrap().into(),
 +                };
 +                let test_name = compiletest::make_test_name(config, &paths);
 +                let index = tests
 +                    .iter()
 +                    .position(|test| test.desc.name == test_name)
 +                    .expect("The test should be in there");
 +                result &= tester::run_tests_console(&opts, vec![tests.swap_remove(index)])?;
 +            }
 +        }
 +        Ok(result)
 +    }
 +
 +    config.mode = TestMode::Ui;
 +    config.src_base = Path::new("tests").join("ui-toml").canonicalize().unwrap();
 +
 +    let tests = compiletest::make_tests(config);
 +
 +    let res = run_tests(config, tests);
 +    match res {
 +        Ok(true) => {},
 +        Ok(false) => panic!("Some tests failed"),
 +        Err(e) => {
 +            panic!("I/O failure during tests: {:?}", e);
 +        },
 +    }
 +}
 +
 +fn run_ui_cargo(config: &mut compiletest::Config) {
 +    fn run_tests(
 +        config: &compiletest::Config,
 +        filters: &[String],
 +        mut tests: Vec<tester::TestDescAndFn>,
 +    ) -> Result<bool, io::Error> {
 +        let mut result = true;
 +        let opts = compiletest::test_opts(config);
 +
 +        for dir in fs::read_dir(&config.src_base)? {
 +            let dir = dir?;
 +            if !dir.file_type()?.is_dir() {
 +                continue;
 +            }
 +
 +            // Use the filter if provided
 +            let dir_path = dir.path();
 +            for filter in filters {
 +                if !dir_path.ends_with(filter) {
 +                    continue;
 +                }
 +            }
 +
 +            for case in fs::read_dir(&dir_path)? {
 +                let case = case?;
 +                if !case.file_type()?.is_dir() {
 +                    continue;
 +                }
 +
 +                let src_path = case.path().join("src");
 +
 +                // When switching between branches, if the previous branch had a test
 +                // that the current branch does not have, the directory is not removed
 +                // because an ignored Cargo.lock file exists.
 +                if !src_path.exists() {
 +                    continue;
 +                }
 +
 +                env::set_current_dir(&src_path)?;
 +                for file in fs::read_dir(&src_path)? {
 +                    let file = file?;
 +                    if file.file_type()?.is_dir() {
 +                        continue;
 +                    }
 +
 +                    // Search for the main file to avoid running a test for each file in the project
 +                    let file_path = file.path();
 +                    match file_path.file_name().and_then(OsStr::to_str) {
 +                        Some("main.rs") => {},
 +                        _ => continue,
 +                    }
 +                    let _g = VarGuard::set("CLIPPY_CONF_DIR", case.path());
 +                    let paths = compiletest::common::TestPaths {
 +                        file: file_path,
 +                        base: config.src_base.clone(),
 +                        relative_dir: src_path.strip_prefix(&config.src_base).unwrap().into(),
 +                    };
 +                    let test_name = compiletest::make_test_name(config, &paths);
 +                    let index = tests
 +                        .iter()
 +                        .position(|test| test.desc.name == test_name)
 +                        .expect("The test should be in there");
 +                    result &= tester::run_tests_console(&opts, vec![tests.swap_remove(index)])?;
 +                }
 +            }
 +        }
 +        Ok(result)
 +    }
 +
 +    if IS_RUSTC_TEST_SUITE {
 +        return;
 +    }
 +
 +    config.mode = TestMode::Ui;
 +    config.src_base = Path::new("tests").join("ui-cargo").canonicalize().unwrap();
 +
 +    let tests = compiletest::make_tests(config);
 +
 +    let current_dir = env::current_dir().unwrap();
 +    let res = run_tests(config, &config.filters, tests);
 +    env::set_current_dir(current_dir).unwrap();
 +
 +    match res {
 +        Ok(true) => {},
 +        Ok(false) => panic!("Some tests failed"),
 +        Err(e) => {
 +            panic!("I/O failure during tests: {:?}", e);
 +        },
 +    }
 +}
 +
-     prepare_env();
 +#[test]
 +fn compile_test() {
++    set_var("CLIPPY_DISABLE_DOCS_LINKS", "true");
 +    let mut config = default_config();
 +    run_ui(&mut config);
 +    run_ui_test(&mut config);
 +    run_ui_toml(&mut config);
 +    run_ui_cargo(&mut config);
 +    run_internal_tests(&mut config);
 +}
 +
 +/// Restores an env var on drop
 +#[must_use]
 +struct VarGuard {
 +    key: &'static str,
 +    value: Option<OsString>,
 +}
 +
 +impl VarGuard {
 +    fn set(key: &'static str, val: impl AsRef<OsStr>) -> Self {
 +        let value = var_os(key);
 +        set_var(key, val);
 +        Self { key, value }
 +    }
 +}
 +
 +impl Drop for VarGuard {
 +    fn drop(&mut self) {
 +        match self.value.as_deref() {
 +            None => remove_var(self.key),
 +            Some(value) => set_var(self.key, value),
 +        }
 +    }
 +}
index 8e104926524e16fab2789cd6c7f0826f31aacc70,0000000000000000000000000000000000000000..1e3ec123a3c8b0b430eb253f739da3fd41868b71
mode 100644,000000..100644
--- /dev/null
@@@ -1,78 -1,0 +1,98 @@@
- #![allow(clippy::redundant_clone)]
- #![warn(clippy::manual_non_exhaustive)]
++#![allow(clippy::redundant_clone, clippy::unnecessary_operation)]
++#![warn(clippy::manual_non_exhaustive, clippy::borrow_as_ptr, clippy::manual_bits)]
 +
++use std::mem::{size_of, size_of_val};
 +use std::ops::Deref;
 +
 +mod enums {
 +    enum E {
 +        A,
 +        B,
 +        #[doc(hidden)]
 +        _C,
 +    }
 +
 +    // user forgot to remove the marker
 +    #[non_exhaustive]
 +    enum Ep {
 +        A,
 +        B,
 +        #[doc(hidden)]
 +        _C,
 +    }
 +}
 +
 +fn option_as_ref_deref() {
 +    let mut opt = Some(String::from("123"));
 +
 +    let _ = opt.as_ref().map(String::as_str);
 +    let _ = opt.as_ref().map(|x| x.as_str());
 +    let _ = opt.as_mut().map(String::as_mut_str);
 +    let _ = opt.as_mut().map(|x| x.as_mut_str());
 +}
 +
 +fn match_like_matches() {
 +    let _y = match Some(5) {
 +        Some(0) => true,
 +        _ => false,
 +    };
 +}
 +
 +fn match_same_arms() {
 +    match (1, 2, 3) {
 +        (1, .., 3) => 42,
 +        (.., 3) => 42, //~ ERROR match arms have same body
 +        _ => 0,
 +    };
 +}
 +
 +fn match_same_arms2() {
 +    let _ = match Some(42) {
 +        Some(_) => 24,
 +        None => 24, //~ ERROR match arms have same body
 +    };
 +}
 +
 +fn manual_strip_msrv() {
 +    let s = "hello, world!";
 +    if s.starts_with("hello, ") {
 +        assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");
 +    }
 +}
 +
 +fn check_index_refutable_slice() {
 +    // This shouldn't trigger `clippy::index_refutable_slice` as the suggestion
 +    // would only be valid from 1.42.0 onward
 +    let slice: Option<&[u32]> = Some(&[1]);
 +    if let Some(slice) = slice {
 +        println!("{}", slice[0]);
 +    }
 +}
 +
++fn map_clone_suggest_copied() {
++    // This should still trigger the lint but suggest `cloned()` instead of `copied()`
++    let _: Option<u64> = Some(&16).map(|b| *b);
++}
++
++fn borrow_as_ptr() {
++    let val = 1;
++    let _p = &val as *const i32;
++
++    let mut val_mut = 1;
++    let _p_mut = &mut val_mut as *mut i32;
++}
++
++fn manual_bits() {
++    size_of::<i8>() * 8;
++    size_of_val(&0u32) * 8;
++}
++
 +fn main() {
 +    option_as_ref_deref();
 +    match_like_matches();
 +    match_same_arms();
 +    match_same_arms2();
 +    manual_strip_msrv();
 +    check_index_refutable_slice();
++    borrow_as_ptr();
 +}
index 0000000000000000000000000000000000000000,0000000000000000000000000000000000000000..a1e7361c0cb32fe4bbe9e9c5a09320691b3b123a
new file mode 100644 (file)
--- /dev/null
--- /dev/null
@@@ -1,0 -1,0 +1,10 @@@
++error: you are using an explicit closure for copying elements
++  --> $DIR/min_rust_version.rs:74:26
++   |
++LL |     let _: Option<u64> = Some(&16).map(|b| *b);
++   |                          ^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `cloned` method: `Some(&16).cloned()`
++   |
++   = note: `-D clippy::map-clone` implied by `-D warnings`
++
++error: aborting due to previous error
++
index 4327f12c37c8eb82576eaff0d74cdf595194a93e,0000000000000000000000000000000000000000..eefeb1decb69e604519618c9567ab6ee990b3a81
mode 100644,000000..100644
--- /dev/null
@@@ -1,108 -1,0 +1,104 @@@
- #![allow(
-     clippy::declare_interior_mutable_const,
-     clippy::ref_in_deref,
-     clippy::needless_borrow
- )]
 +#![warn(clippy::borrow_interior_mutable_const)]
++#![allow(clippy::declare_interior_mutable_const, clippy::needless_borrow)]
 +#![allow(const_item_mutation)]
 +
 +use std::borrow::Cow;
 +use std::cell::{Cell, UnsafeCell};
 +use std::fmt::Display;
 +use std::sync::atomic::{AtomicUsize, Ordering};
 +use std::sync::Once;
 +
 +const ATOMIC: AtomicUsize = AtomicUsize::new(5);
 +const CELL: Cell<usize> = Cell::new(6);
 +const ATOMIC_TUPLE: ([AtomicUsize; 1], Vec<AtomicUsize>, u8) = ([ATOMIC], Vec::new(), 7);
 +const INTEGER: u8 = 8;
 +const STRING: String = String::new();
 +const STR: &str = "012345";
 +const COW: Cow<str> = Cow::Borrowed("abcdef");
 +const NO_ANN: &dyn Display = &70;
 +static STATIC_TUPLE: (AtomicUsize, String) = (ATOMIC, STRING);
 +const ONCE_INIT: Once = Once::new();
 +
 +// This is just a pointer that can be safely dereferenced,
 +// it's semantically the same as `&'static T`;
 +// but it isn't allowed to make a static reference from an arbitrary integer value at the moment.
 +// For more information, please see the issue #5918.
 +pub struct StaticRef<T> {
 +    ptr: *const T,
 +}
 +
 +impl<T> StaticRef<T> {
 +    /// Create a new `StaticRef` from a raw pointer
 +    ///
 +    /// ## Safety
 +    ///
 +    /// Callers must pass in a reference to statically allocated memory which
 +    /// does not overlap with other values.
 +    pub const unsafe fn new(ptr: *const T) -> StaticRef<T> {
 +        StaticRef { ptr }
 +    }
 +}
 +
 +impl<T> std::ops::Deref for StaticRef<T> {
 +    type Target = T;
 +
 +    fn deref(&self) -> &'static T {
 +        unsafe { &*self.ptr }
 +    }
 +}
 +
 +// use a tuple to make sure referencing a field behind a pointer isn't linted.
 +const CELL_REF: StaticRef<(UnsafeCell<u32>,)> = unsafe { StaticRef::new(std::ptr::null()) };
 +
 +fn main() {
 +    ATOMIC.store(1, Ordering::SeqCst); //~ ERROR interior mutability
 +    assert_eq!(ATOMIC.load(Ordering::SeqCst), 5); //~ ERROR interior mutability
 +
 +    let _once = ONCE_INIT;
 +    let _once_ref = &ONCE_INIT; //~ ERROR interior mutability
 +    let _once_ref_2 = &&ONCE_INIT; //~ ERROR interior mutability
 +    let _once_ref_4 = &&&&ONCE_INIT; //~ ERROR interior mutability
 +    let _once_mut = &mut ONCE_INIT; //~ ERROR interior mutability
 +    let _atomic_into_inner = ATOMIC.into_inner();
 +    // these should be all fine.
 +    let _twice = (ONCE_INIT, ONCE_INIT);
 +    let _ref_twice = &(ONCE_INIT, ONCE_INIT);
 +    let _ref_once = &(ONCE_INIT, ONCE_INIT).0;
 +    let _array_twice = [ONCE_INIT, ONCE_INIT];
 +    let _ref_array_twice = &[ONCE_INIT, ONCE_INIT];
 +    let _ref_array_once = &[ONCE_INIT, ONCE_INIT][0];
 +
 +    // referencing projection is still bad.
 +    let _ = &ATOMIC_TUPLE; //~ ERROR interior mutability
 +    let _ = &ATOMIC_TUPLE.0; //~ ERROR interior mutability
 +    let _ = &(&&&&ATOMIC_TUPLE).0; //~ ERROR interior mutability
 +    let _ = &ATOMIC_TUPLE.0[0]; //~ ERROR interior mutability
 +    let _ = ATOMIC_TUPLE.0[0].load(Ordering::SeqCst); //~ ERROR interior mutability
 +    let _ = &*ATOMIC_TUPLE.1;
 +    let _ = &ATOMIC_TUPLE.2;
 +    let _ = (&&&&ATOMIC_TUPLE).0;
 +    let _ = (&&&&ATOMIC_TUPLE).2;
 +    let _ = ATOMIC_TUPLE.0;
 +    let _ = ATOMIC_TUPLE.0[0]; //~ ERROR interior mutability
 +    let _ = ATOMIC_TUPLE.1.into_iter();
 +    let _ = ATOMIC_TUPLE.2;
 +    let _ = &{ ATOMIC_TUPLE };
 +
 +    CELL.set(2); //~ ERROR interior mutability
 +    assert_eq!(CELL.get(), 6); //~ ERROR interior mutability
 +
 +    assert_eq!(INTEGER, 8);
 +    assert!(STRING.is_empty());
 +
 +    let a = ATOMIC;
 +    a.store(4, Ordering::SeqCst);
 +    assert_eq!(a.load(Ordering::SeqCst), 4);
 +
 +    STATIC_TUPLE.0.store(3, Ordering::SeqCst);
 +    assert_eq!(STATIC_TUPLE.0.load(Ordering::SeqCst), 3);
 +    assert!(STATIC_TUPLE.1.is_empty());
 +
 +    assert_eq!(NO_ANN.to_string(), "70"); // should never lint this.
 +
 +    let _ = &CELL_REF.0;
 +}
index f146b97cf61161f0c96b320c8bc1c6759d09fa5f,0000000000000000000000000000000000000000..9a908cf30e945cc100e1a98126448250704031f0
mode 100644,000000..100644
--- /dev/null
@@@ -1,115 -1,0 +1,115 @@@
-   --> $DIR/others.rs:58:5
 +error: a `const` item with interior mutability should not be borrowed
-   --> $DIR/others.rs:59:16
++  --> $DIR/others.rs:54:5
 +   |
 +LL |     ATOMIC.store(1, Ordering::SeqCst); //~ ERROR interior mutability
 +   |     ^^^^^^
 +   |
 +   = note: `-D clippy::borrow-interior-mutable-const` implied by `-D warnings`
 +   = help: assign this const to a local or static variable, and use the variable here
 +
 +error: a `const` item with interior mutability should not be borrowed
-   --> $DIR/others.rs:62:22
++  --> $DIR/others.rs:55:16
 +   |
 +LL |     assert_eq!(ATOMIC.load(Ordering::SeqCst), 5); //~ ERROR interior mutability
 +   |                ^^^^^^
 +   |
 +   = help: assign this const to a local or static variable, and use the variable here
 +
 +error: a `const` item with interior mutability should not be borrowed
-   --> $DIR/others.rs:63:25
++  --> $DIR/others.rs:58:22
 +   |
 +LL |     let _once_ref = &ONCE_INIT; //~ ERROR interior mutability
 +   |                      ^^^^^^^^^
 +   |
 +   = help: assign this const to a local or static variable, and use the variable here
 +
 +error: a `const` item with interior mutability should not be borrowed
-   --> $DIR/others.rs:64:27
++  --> $DIR/others.rs:59:25
 +   |
 +LL |     let _once_ref_2 = &&ONCE_INIT; //~ ERROR interior mutability
 +   |                         ^^^^^^^^^
 +   |
 +   = help: assign this const to a local or static variable, and use the variable here
 +
 +error: a `const` item with interior mutability should not be borrowed
-   --> $DIR/others.rs:65:26
++  --> $DIR/others.rs:60:27
 +   |
 +LL |     let _once_ref_4 = &&&&ONCE_INIT; //~ ERROR interior mutability
 +   |                           ^^^^^^^^^
 +   |
 +   = help: assign this const to a local or static variable, and use the variable here
 +
 +error: a `const` item with interior mutability should not be borrowed
-   --> $DIR/others.rs:76:14
++  --> $DIR/others.rs:61:26
 +   |
 +LL |     let _once_mut = &mut ONCE_INIT; //~ ERROR interior mutability
 +   |                          ^^^^^^^^^
 +   |
 +   = help: assign this const to a local or static variable, and use the variable here
 +
 +error: a `const` item with interior mutability should not be borrowed
-   --> $DIR/others.rs:77:14
++  --> $DIR/others.rs:72:14
 +   |
 +LL |     let _ = &ATOMIC_TUPLE; //~ ERROR interior mutability
 +   |              ^^^^^^^^^^^^
 +   |
 +   = help: assign this const to a local or static variable, and use the variable here
 +
 +error: a `const` item with interior mutability should not be borrowed
-   --> $DIR/others.rs:78:19
++  --> $DIR/others.rs:73:14
 +   |
 +LL |     let _ = &ATOMIC_TUPLE.0; //~ ERROR interior mutability
 +   |              ^^^^^^^^^^^^
 +   |
 +   = help: assign this const to a local or static variable, and use the variable here
 +
 +error: a `const` item with interior mutability should not be borrowed
-   --> $DIR/others.rs:79:14
++  --> $DIR/others.rs:74:19
 +   |
 +LL |     let _ = &(&&&&ATOMIC_TUPLE).0; //~ ERROR interior mutability
 +   |                   ^^^^^^^^^^^^
 +   |
 +   = help: assign this const to a local or static variable, and use the variable here
 +
 +error: a `const` item with interior mutability should not be borrowed
-   --> $DIR/others.rs:80:13
++  --> $DIR/others.rs:75:14
 +   |
 +LL |     let _ = &ATOMIC_TUPLE.0[0]; //~ ERROR interior mutability
 +   |              ^^^^^^^^^^^^
 +   |
 +   = help: assign this const to a local or static variable, and use the variable here
 +
 +error: a `const` item with interior mutability should not be borrowed
-   --> $DIR/others.rs:86:13
++  --> $DIR/others.rs:76:13
 +   |
 +LL |     let _ = ATOMIC_TUPLE.0[0].load(Ordering::SeqCst); //~ ERROR interior mutability
 +   |             ^^^^^^^^^^^^
 +   |
 +   = help: assign this const to a local or static variable, and use the variable here
 +
 +error: a `const` item with interior mutability should not be borrowed
-   --> $DIR/others.rs:91:5
++  --> $DIR/others.rs:82:13
 +   |
 +LL |     let _ = ATOMIC_TUPLE.0[0]; //~ ERROR interior mutability
 +   |             ^^^^^^^^^^^^
 +   |
 +   = help: assign this const to a local or static variable, and use the variable here
 +
 +error: a `const` item with interior mutability should not be borrowed
-   --> $DIR/others.rs:92:16
++  --> $DIR/others.rs:87:5
 +   |
 +LL |     CELL.set(2); //~ ERROR interior mutability
 +   |     ^^^^
 +   |
 +   = help: assign this const to a local or static variable, and use the variable here
 +
 +error: a `const` item with interior mutability should not be borrowed
++  --> $DIR/others.rs:88:16
 +   |
 +LL |     assert_eq!(CELL.get(), 6); //~ ERROR interior mutability
 +   |                ^^^^
 +   |
 +   = help: assign this const to a local or static variable, and use the variable here
 +
 +error: aborting due to 14 previous errors
 +
index c724ee21be310b4a8d9d3376eeb36797304bcd65,0000000000000000000000000000000000000000..d3ad26921bffa8d4d15db41f488b73d30f8681d7
mode 100644,000000..100644
--- /dev/null
@@@ -1,24 -1,0 +1,26 @@@
++#![allow(clippy::needless_borrow)]
++
 +#[deny(clippy::naive_bytecount)]
 +fn main() {
 +    let x = vec![0_u8; 16];
 +
 +    let _ = x.iter().filter(|&&a| a == 0).count(); // naive byte count
 +
 +    let _ = (&x[..]).iter().filter(|&a| *a == 0).count(); // naive byte count
 +
 +    let _ = x.iter().filter(|a| **a > 0).count(); // not an equality count, OK.
 +
 +    let _ = x.iter().map(|a| a + 1).filter(|&a| a < 15).count(); // not a slice
 +
 +    let b = 0;
 +
 +    let _ = x.iter().filter(|_| b > 0).count(); // woah there
 +
 +    let _ = x.iter().filter(|_a| b == b + 1).count(); // nothing to see here, move along
 +
 +    let _ = x.iter().filter(|a| b + 1 == **a).count(); // naive byte count
 +
 +    let y = vec![0_u16; 3];
 +
 +    let _ = y.iter().filter(|&&a| a == 0).count(); // naive count, but not bytes
 +}
index 1dc37fc8b259f576d046aeec7090a998465cabd0,0000000000000000000000000000000000000000..68d838c1f828aa550a01573b87a0dc75d76425cc
mode 100644,000000..100644
--- /dev/null
@@@ -1,26 -1,0 +1,26 @@@
-   --> $DIR/bytecount.rs:5:13
 +error: you appear to be counting bytes the naive way
-   --> $DIR/bytecount.rs:1:8
++  --> $DIR/bytecount.rs:7:13
 +   |
 +LL |     let _ = x.iter().filter(|&&a| a == 0).count(); // naive byte count
 +   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using the bytecount crate: `bytecount::count(x, 0)`
 +   |
 +note: the lint level is defined here
-   --> $DIR/bytecount.rs:7:13
++  --> $DIR/bytecount.rs:3:8
 +   |
 +LL | #[deny(clippy::naive_bytecount)]
 +   |        ^^^^^^^^^^^^^^^^^^^^^^^
 +
 +error: you appear to be counting bytes the naive way
-   --> $DIR/bytecount.rs:19:13
++  --> $DIR/bytecount.rs:9:13
 +   |
 +LL |     let _ = (&x[..]).iter().filter(|&a| *a == 0).count(); // naive byte count
 +   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using the bytecount crate: `bytecount::count((&x[..]), 0)`
 +
 +error: you appear to be counting bytes the naive way
++  --> $DIR/bytecount.rs:21:13
 +   |
 +LL |     let _ = x.iter().filter(|a| b + 1 == **a).count(); // naive byte count
 +   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using the bytecount crate: `bytecount::count(x, b + 1)`
 +
 +error: aborting due to 3 previous errors
 +
index 8d43f64768d417f3b7323ce95dcfe4bf490b2279,0000000000000000000000000000000000000000..dc062762604e063a4d1dac5f9554a7276898e65e
mode 100644,000000..100644
--- /dev/null
@@@ -1,73 -1,0 +1,74 @@@
-     clippy::toplevel_ref_arg
 +// run-rustfix
 +
 +#![allow(
 +    unused,
 +    clippy::redundant_clone,
 +    clippy::deref_addrof,
 +    clippy::no_effect,
 +    clippy::unnecessary_operation,
 +    clippy::vec_init_then_push,
++    clippy::toplevel_ref_arg,
++    clippy::needless_borrow
 +)]
 +
 +use std::cell::RefCell;
 +use std::rc::{self, Rc};
 +use std::sync::{self, Arc};
 +
 +fn main() {}
 +
 +fn is_ascii(ch: char) -> bool {
 +    ch.is_ascii()
 +}
 +
 +fn clone_on_copy() {
 +    42;
 +
 +    vec![1].clone(); // ok, not a Copy type
 +    Some(vec![1]).clone(); // ok, not a Copy type
 +    *(&42);
 +
 +    let rc = RefCell::new(0);
 +    *rc.borrow();
 +
 +    let x = 0u32;
 +    x.rotate_left(1);
 +
 +    #[derive(Clone, Copy)]
 +    struct Foo;
 +    impl Foo {
 +        fn clone(&self) -> u32 {
 +            0
 +        }
 +    }
 +    Foo.clone(); // ok, this is not the clone trait
 +
 +    macro_rules! m {
 +        ($e:expr) => {{ $e }};
 +    }
 +    m!(42);
 +
 +    struct Wrap([u32; 2]);
 +    impl core::ops::Deref for Wrap {
 +        type Target = [u32; 2];
 +        fn deref(&self) -> &[u32; 2] {
 +            &self.0
 +        }
 +    }
 +    let x = Wrap([0, 0]);
 +    (*x)[0];
 +
 +    let x = 42;
 +    let ref y = x.clone(); // ok, binds by reference
 +    let ref mut y = x.clone(); // ok, binds by reference
 +
 +    // Issue #4348
 +    let mut x = 43;
 +    let _ = &x.clone(); // ok, getting a ref
 +    'a'.clone().make_ascii_uppercase(); // ok, clone and then mutate
 +    is_ascii('z');
 +
 +    // Issue #5436
 +    let mut vec = Vec::new();
 +    vec.push(42);
 +}
index f15501f71844f0ceb1b9f4a59acd5e5952e30540,0000000000000000000000000000000000000000..8c39d0d55dd8bdbf23e48a37bdd194bbd930cc6b
mode 100644,000000..100644
--- /dev/null
@@@ -1,73 -1,0 +1,74 @@@
-     clippy::toplevel_ref_arg
 +// run-rustfix
 +
 +#![allow(
 +    unused,
 +    clippy::redundant_clone,
 +    clippy::deref_addrof,
 +    clippy::no_effect,
 +    clippy::unnecessary_operation,
 +    clippy::vec_init_then_push,
++    clippy::toplevel_ref_arg,
++    clippy::needless_borrow
 +)]
 +
 +use std::cell::RefCell;
 +use std::rc::{self, Rc};
 +use std::sync::{self, Arc};
 +
 +fn main() {}
 +
 +fn is_ascii(ch: char) -> bool {
 +    ch.is_ascii()
 +}
 +
 +fn clone_on_copy() {
 +    42.clone();
 +
 +    vec![1].clone(); // ok, not a Copy type
 +    Some(vec![1]).clone(); // ok, not a Copy type
 +    (&42).clone();
 +
 +    let rc = RefCell::new(0);
 +    rc.borrow().clone();
 +
 +    let x = 0u32;
 +    x.clone().rotate_left(1);
 +
 +    #[derive(Clone, Copy)]
 +    struct Foo;
 +    impl Foo {
 +        fn clone(&self) -> u32 {
 +            0
 +        }
 +    }
 +    Foo.clone(); // ok, this is not the clone trait
 +
 +    macro_rules! m {
 +        ($e:expr) => {{ $e }};
 +    }
 +    m!(42).clone();
 +
 +    struct Wrap([u32; 2]);
 +    impl core::ops::Deref for Wrap {
 +        type Target = [u32; 2];
 +        fn deref(&self) -> &[u32; 2] {
 +            &self.0
 +        }
 +    }
 +    let x = Wrap([0, 0]);
 +    x.clone()[0];
 +
 +    let x = 42;
 +    let ref y = x.clone(); // ok, binds by reference
 +    let ref mut y = x.clone(); // ok, binds by reference
 +
 +    // Issue #4348
 +    let mut x = 43;
 +    let _ = &x.clone(); // ok, getting a ref
 +    'a'.clone().make_ascii_uppercase(); // ok, clone and then mutate
 +    is_ascii('z'.clone());
 +
 +    // Issue #5436
 +    let mut vec = Vec::new();
 +    vec.push(42.clone());
 +}
index e7d28b4320bc862691b54709ed4e8bbe605d04ac,0000000000000000000000000000000000000000..861543d0aa904566aac464ca4071ddd23aee4153
mode 100644,000000..100644
--- /dev/null
@@@ -1,52 -1,0 +1,52 @@@
-   --> $DIR/clone_on_copy.rs:24:5
 +error: using `clone` on type `i32` which implements the `Copy` trait
-   --> $DIR/clone_on_copy.rs:28:5
++  --> $DIR/clone_on_copy.rs:25:5
 +   |
 +LL |     42.clone();
 +   |     ^^^^^^^^^^ help: try removing the `clone` call: `42`
 +   |
 +   = note: `-D clippy::clone-on-copy` implied by `-D warnings`
 +
 +error: using `clone` on type `i32` which implements the `Copy` trait
-   --> $DIR/clone_on_copy.rs:31:5
++  --> $DIR/clone_on_copy.rs:29:5
 +   |
 +LL |     (&42).clone();
 +   |     ^^^^^^^^^^^^^ help: try dereferencing it: `*(&42)`
 +
 +error: using `clone` on type `i32` which implements the `Copy` trait
-   --> $DIR/clone_on_copy.rs:34:5
++  --> $DIR/clone_on_copy.rs:32:5
 +   |
 +LL |     rc.borrow().clone();
 +   |     ^^^^^^^^^^^^^^^^^^^ help: try dereferencing it: `*rc.borrow()`
 +
 +error: using `clone` on type `u32` which implements the `Copy` trait
-   --> $DIR/clone_on_copy.rs:48:5
++  --> $DIR/clone_on_copy.rs:35:5
 +   |
 +LL |     x.clone().rotate_left(1);
 +   |     ^^^^^^^^^ help: try removing the `clone` call: `x`
 +
 +error: using `clone` on type `i32` which implements the `Copy` trait
-   --> $DIR/clone_on_copy.rs:58:5
++  --> $DIR/clone_on_copy.rs:49:5
 +   |
 +LL |     m!(42).clone();
 +   |     ^^^^^^^^^^^^^^ help: try removing the `clone` call: `m!(42)`
 +
 +error: using `clone` on type `[u32; 2]` which implements the `Copy` trait
-   --> $DIR/clone_on_copy.rs:68:14
++  --> $DIR/clone_on_copy.rs:59:5
 +   |
 +LL |     x.clone()[0];
 +   |     ^^^^^^^^^ help: try dereferencing it: `(*x)`
 +
 +error: using `clone` on type `char` which implements the `Copy` trait
-   --> $DIR/clone_on_copy.rs:72:14
++  --> $DIR/clone_on_copy.rs:69:14
 +   |
 +LL |     is_ascii('z'.clone());
 +   |              ^^^^^^^^^^^ help: try removing the `clone` call: `'z'`
 +
 +error: using `clone` on type `i32` which implements the `Copy` trait
++  --> $DIR/clone_on_copy.rs:73:14
 +   |
 +LL |     vec.push(42.clone());
 +   |              ^^^^^^^^^^ help: try removing the `clone` call: `42`
 +
 +error: aborting due to 8 previous errors
 +
index ee5c7863effcb84b34a893e18dbc7710be5673b0,0000000000000000000000000000000000000000..d92b8998e8805c2b0da6e1648ede17b1c0e71578
mode 100644,000000..100644
--- /dev/null
@@@ -1,29 -1,0 +1,29 @@@
- #![allow(dead_code)]
 +// run-rustfix
++#![allow(dead_code, clippy::needless_borrow)]
 +#![warn(clippy::duration_subsec)]
 +
 +use std::time::Duration;
 +
 +fn main() {
 +    let dur = Duration::new(5, 0);
 +
 +    let bad_millis_1 = dur.subsec_millis();
 +    let bad_millis_2 = dur.subsec_millis();
 +    let good_millis = dur.subsec_millis();
 +    assert_eq!(bad_millis_1, good_millis);
 +    assert_eq!(bad_millis_2, good_millis);
 +
 +    let bad_micros = dur.subsec_micros();
 +    let good_micros = dur.subsec_micros();
 +    assert_eq!(bad_micros, good_micros);
 +
 +    // Handle refs
 +    let _ = (&dur).subsec_micros();
 +
 +    // Handle constants
 +    const NANOS_IN_MICRO: u32 = 1_000;
 +    let _ = dur.subsec_micros();
 +
 +    // Other literals aren't linted
 +    let _ = dur.subsec_nanos() / 699;
 +}
index 3c9d2a286211017854d57039166bf80bb18976b7,0000000000000000000000000000000000000000..08da804996d1b5660db6a9bb91c6e6a4141c6b72
mode 100644,000000..100644
--- /dev/null
@@@ -1,29 -1,0 +1,29 @@@
- #![allow(dead_code)]
 +// run-rustfix
++#![allow(dead_code, clippy::needless_borrow)]
 +#![warn(clippy::duration_subsec)]
 +
 +use std::time::Duration;
 +
 +fn main() {
 +    let dur = Duration::new(5, 0);
 +
 +    let bad_millis_1 = dur.subsec_micros() / 1_000;
 +    let bad_millis_2 = dur.subsec_nanos() / 1_000_000;
 +    let good_millis = dur.subsec_millis();
 +    assert_eq!(bad_millis_1, good_millis);
 +    assert_eq!(bad_millis_2, good_millis);
 +
 +    let bad_micros = dur.subsec_nanos() / 1_000;
 +    let good_micros = dur.subsec_micros();
 +    assert_eq!(bad_micros, good_micros);
 +
 +    // Handle refs
 +    let _ = (&dur).subsec_nanos() / 1_000;
 +
 +    // Handle constants
 +    const NANOS_IN_MICRO: u32 = 1_000;
 +    let _ = dur.subsec_nanos() / NANOS_IN_MICRO;
 +
 +    // Other literals aren't linted
 +    let _ = dur.subsec_nanos() / 699;
 +}
index d3662a0a213d2cc4b276a974efd8a111e318b509,0000000000000000000000000000000000000000..b2bf7c4e360a0246b2459934e3c1b843eb5568d1
mode 100644,000000..100644
--- /dev/null
@@@ -1,154 -1,0 +1,161 @@@
 +#![warn(clippy::enum_variant_names)]
 +#![allow(non_camel_case_types, clippy::upper_case_acronyms)]
 +
 +enum FakeCallType {
 +    CALL,
 +    CREATE,
 +}
 +
 +enum FakeCallType2 {
 +    CALL,
 +    CREATELL,
 +}
 +
 +enum Foo {
 +    cFoo,
 +    cBar,
 +    cBaz,
 +}
 +
 +enum Fooo {
 +    cFoo, // no error, threshold is 3 variants by default
 +    cBar,
 +}
 +
 +enum Food {
 +    FoodGood,
 +    FoodMiddle,
 +    FoodBad,
 +}
 +
 +enum Stuff {
 +    StuffBad, // no error
 +}
 +
 +enum BadCallType {
 +    CallTypeCall,
 +    CallTypeCreate,
 +    CallTypeDestroy,
 +}
 +
 +enum TwoCallType {
 +    // no error
 +    CallTypeCall,
 +    CallTypeCreate,
 +}
 +
 +enum Consts {
 +    ConstantInt,
 +    ConstantCake,
 +    ConstantLie,
 +}
 +
 +enum Two {
 +    // no error here
 +    ConstantInt,
 +    ConstantInfer,
 +}
 +
 +enum Something {
 +    CCall,
 +    CCreate,
 +    CCryogenize,
 +}
 +
 +enum Seal {
 +    With,
 +    Without,
 +}
 +
 +enum Seall {
 +    With,
 +    WithOut,
 +    Withbroken,
 +}
 +
 +enum Sealll {
 +    With,
 +    WithOut,
 +}
 +
 +enum Seallll {
 +    WithOutCake,
 +    WithOutTea,
 +    WithOut,
 +}
 +
 +enum NonCaps {
 +    Prefix的,
 +    PrefixTea,
 +    PrefixCake,
 +}
 +
 +pub enum PubSeall {
 +    WithOutCake,
 +    WithOutTea,
 +    WithOut,
 +}
 +
 +#[allow(clippy::enum_variant_names)]
 +pub mod allowed {
 +    pub enum PubAllowed {
 +        SomeThis,
 +        SomeThat,
 +        SomeOtherWhat,
 +    }
 +}
 +
 +// should not lint
 +enum Pat {
 +    Foo,
 +    Bar,
 +    Path,
 +}
 +
 +// should not lint
 +enum N {
 +    Pos,
 +    Neg,
 +    Float,
 +}
 +
 +// should not lint
 +enum Peek {
 +    Peek1,
 +    Peek2,
 +    Peek3,
 +}
 +
 +// should not lint
 +pub enum NetworkLayer {
 +    Layer2,
 +    Layer3,
 +}
 +
 +// should lint suggesting `IData`, not only `Data` (see #4639)
 +enum IDataRequest {
 +    PutIData(String),
 +    GetIData(String),
 +    DeleteUnpubIData(String),
 +}
 +
 +enum HIDataRequest {
 +    PutHIData(String),
 +    GetHIData(String),
 +    DeleteUnpubHIData(String),
 +}
 +
 +enum North {
 +    Normal,
 +    NoLeft,
 +    NoRight,
 +}
 +
++// #8324
++enum Phase {
++    PreLookup,
++    Lookup,
++    PostLookup,
++}
++
 +fn main() {}
index f938f7106884416bb1d748f94f90a85a85ac131d,0000000000000000000000000000000000000000..618f80cdcf84923d9ca035b35e177c9cc22079e4
mode 100644,000000..100644
--- /dev/null
@@@ -1,261 -1,0 +1,258 @@@
-     clippy::option_map_unit_fn
- )]
- #![warn(
-     clippy::redundant_closure,
-     clippy::redundant_closure_for_method_calls,
 +// run-rustfix
 +
 +#![allow(
 +    unused,
 +    clippy::no_effect,
 +    clippy::redundant_closure_call,
 +    clippy::needless_pass_by_value,
-     all(&[1, 2, 3], &2, below); //is adjusted
++    clippy::option_map_unit_fn,
 +    clippy::needless_borrow
 +)]
++#![warn(clippy::redundant_closure, clippy::redundant_closure_for_method_calls)]
 +
 +use std::path::{Path, PathBuf};
 +
 +macro_rules! mac {
 +    () => {
 +        foobar()
 +    };
 +}
 +
 +macro_rules! closure_mac {
 +    () => {
 +        |n| foo(n)
 +    };
 +}
 +
 +fn main() {
 +    let a = Some(1u8).map(foo);
 +    let c = Some(1u8).map(|a| {1+2; foo}(a));
 +    true.then(|| mac!()); // don't lint function in macro expansion
 +    Some(1).map(closure_mac!()); // don't lint closure in macro expansion
 +    let _: Option<Vec<u8>> = true.then(std::vec::Vec::new); // special case vec!
 +    let d = Some(1u8).map(|a| foo(foo2(a))); //is adjusted?
++    all(&[1, 2, 3], &&2, below); //is adjusted
 +    unsafe {
 +        Some(1u8).map(|a| unsafe_fn(a)); // unsafe fn
 +    }
 +
 +    // See #815
 +    let e = Some(1u8).map(divergent);
 +    let e = Some(1u8).map(generic);
 +    let e = Some(1u8).map(generic);
 +    // See #515
 +    let a: Option<Box<dyn (::std::ops::Deref<Target = [i32]>)>> =
 +        Some(vec![1i32, 2]).map(|v| -> Box<dyn (::std::ops::Deref<Target = [i32]>)> { Box::new(v) });
 +
 +    // issue #7224
 +    let _: Option<Vec<u32>> = Some(0).map(|_| vec![]);
 +}
 +
 +trait TestTrait {
 +    fn trait_foo(self) -> bool;
 +    fn trait_foo_ref(&self) -> bool;
 +}
 +
 +struct TestStruct<'a> {
 +    some_ref: &'a i32,
 +}
 +
 +impl<'a> TestStruct<'a> {
 +    fn foo(self) -> bool {
 +        false
 +    }
 +    unsafe fn foo_unsafe(self) -> bool {
 +        true
 +    }
 +}
 +
 +impl<'a> TestTrait for TestStruct<'a> {
 +    fn trait_foo(self) -> bool {
 +        false
 +    }
 +    fn trait_foo_ref(&self) -> bool {
 +        false
 +    }
 +}
 +
 +impl<'a> std::ops::Deref for TestStruct<'a> {
 +    type Target = char;
 +    fn deref(&self) -> &char {
 +        &'a'
 +    }
 +}
 +
 +fn test_redundant_closures_containing_method_calls() {
 +    let i = 10;
 +    let e = Some(TestStruct { some_ref: &i }).map(TestStruct::foo);
 +    let e = Some(TestStruct { some_ref: &i }).map(TestTrait::trait_foo);
 +    let e = Some(TestStruct { some_ref: &i }).map(|a| a.trait_foo_ref());
 +    let e = Some(&mut vec![1, 2, 3]).map(std::vec::Vec::clear);
 +    unsafe {
 +        let e = Some(TestStruct { some_ref: &i }).map(|a| a.foo_unsafe());
 +    }
 +    let e = Some("str").map(std::string::ToString::to_string);
 +    let e = Some('a').map(char::to_uppercase);
 +    let e: std::vec::Vec<usize> = vec!['a', 'b', 'c'].iter().map(|c| c.len_utf8()).collect();
 +    let e: std::vec::Vec<char> = vec!['a', 'b', 'c'].iter().map(char::to_ascii_uppercase).collect();
 +    let e = Some(PathBuf::new()).as_ref().and_then(|s| s.to_str());
 +    let c = Some(TestStruct { some_ref: &i })
 +        .as_ref()
 +        .map(|c| c.to_ascii_uppercase());
 +
 +    fn test_different_borrow_levels<T>(t: &[&T])
 +    where
 +        T: TestTrait,
 +    {
 +        t.iter().filter(|x| x.trait_foo_ref());
 +        t.iter().map(|x| x.trait_foo_ref());
 +    }
 +}
 +
 +struct Thunk<T>(Box<dyn FnMut() -> T>);
 +
 +impl<T> Thunk<T> {
 +    fn new<F: 'static + FnOnce() -> T>(f: F) -> Thunk<T> {
 +        let mut option = Some(f);
 +        // This should not trigger redundant_closure (#1439)
 +        Thunk(Box::new(move || option.take().unwrap()()))
 +    }
 +
 +    fn unwrap(self) -> T {
 +        let Thunk(mut f) = self;
 +        f()
 +    }
 +}
 +
 +fn foobar() {
 +    let thunk = Thunk::new(|| println!("Hello, world!"));
 +    thunk.unwrap()
 +}
 +
 +fn foo(_: u8) {}
 +
 +fn foo2(_: u8) -> u8 {
 +    1u8
 +}
 +
 +fn all<X, F>(x: &[X], y: &X, f: F) -> bool
 +where
 +    F: Fn(&X, &X) -> bool,
 +{
 +    x.iter().all(|e| f(e, y))
 +}
 +
 +fn below(x: &u8, y: &u8) -> bool {
 +    x < y
 +}
 +
 +unsafe fn unsafe_fn(_: u8) {}
 +
 +fn divergent(_: u8) -> ! {
 +    unimplemented!()
 +}
 +
 +fn generic<T>(_: T) -> u8 {
 +    0
 +}
 +
 +fn passes_fn_mut(mut x: Box<dyn FnMut()>) {
 +    requires_fn_once(x);
 +}
 +fn requires_fn_once<T: FnOnce()>(_: T) {}
 +
 +fn test_redundant_closure_with_function_pointer() {
 +    type FnPtrType = fn(u8);
 +    let foo_ptr: FnPtrType = foo;
 +    let a = Some(1u8).map(foo_ptr);
 +}
 +
 +fn test_redundant_closure_with_another_closure() {
 +    let closure = |a| println!("{}", a);
 +    let a = Some(1u8).map(closure);
 +}
 +
 +fn make_lazy(f: impl Fn() -> fn(u8) -> u8) -> impl Fn(u8) -> u8 {
 +    // Currently f is called when result of make_lazy is called.
 +    // If the closure is removed, f will be called when make_lazy itself is
 +    // called. This changes semantics, so the closure must stay.
 +    Box::new(move |x| f()(x))
 +}
 +
 +fn call<F: FnOnce(&mut String) -> String>(f: F) -> String {
 +    f(&mut "Hello".to_owned())
 +}
 +fn test_difference_in_mutability() {
 +    call(|s| s.clone());
 +}
 +
 +struct Bar;
 +impl std::ops::Deref for Bar {
 +    type Target = str;
 +    fn deref(&self) -> &str {
 +        "hi"
 +    }
 +}
 +
 +fn test_deref_with_trait_method() {
 +    let _ = [Bar].iter().map(|s| s.to_string()).collect::<Vec<_>>();
 +}
 +
 +fn mutable_closure_used_again(x: Vec<i32>, y: Vec<i32>, z: Vec<i32>) {
 +    let mut res = Vec::new();
 +    let mut add_to_res = |n| res.push(n);
 +    x.into_iter().for_each(&mut add_to_res);
 +    y.into_iter().for_each(&mut add_to_res);
 +    z.into_iter().for_each(add_to_res);
 +}
 +
 +fn mutable_closure_in_loop() {
 +    let mut value = 0;
 +    let mut closure = |n| value += n;
 +    for _ in 0..5 {
 +        Some(1).map(&mut closure);
 +    }
 +}
 +
 +fn late_bound_lifetimes() {
 +    fn take_asref_path<P: AsRef<Path>>(path: P) {}
 +
 +    fn map_str<F>(thunk: F)
 +    where
 +        F: FnOnce(&str),
 +    {
 +    }
 +
 +    fn map_str_to_path<F>(thunk: F)
 +    where
 +        F: FnOnce(&str) -> &Path,
 +    {
 +    }
 +    map_str(|s| take_asref_path(s));
 +    map_str_to_path(std::convert::AsRef::as_ref);
 +}
 +
 +mod type_param_bound {
 +    trait Trait {
 +        fn fun();
 +    }
 +
 +    fn take<T: 'static>(_: T) {}
 +
 +    fn test<X: Trait>() {
 +        // don't lint, but it's questionable that rust requires a cast
 +        take(|| X::fun());
 +        take(X::fun as fn());
 +    }
 +}
 +
 +// #8073 Don't replace closure with `Arc<F>` or `Rc<F>`
 +fn arc_fp() {
 +    let rc = std::rc::Rc::new(|| 7);
 +    let arc = std::sync::Arc::new(|n| n + 1);
 +    let ref_arc = &std::sync::Arc::new(|_| 5);
 +
 +    true.then(|| rc());
 +    (0..5).map(|n| arc(n));
 +    Some(4).map(|n| ref_arc(n));
 +}
index 075bbc74922f91fa18b1ace10ec3689212e00a72,0000000000000000000000000000000000000000..a759e6eb514b42bacb0254c704fe251902711890
mode 100644,000000..100644
--- /dev/null
@@@ -1,261 -1,0 +1,258 @@@
-     clippy::option_map_unit_fn
- )]
- #![warn(
-     clippy::redundant_closure,
-     clippy::redundant_closure_for_method_calls,
 +// run-rustfix
 +
 +#![allow(
 +    unused,
 +    clippy::no_effect,
 +    clippy::redundant_closure_call,
 +    clippy::needless_pass_by_value,
++    clippy::option_map_unit_fn,
 +    clippy::needless_borrow
 +)]
++#![warn(clippy::redundant_closure, clippy::redundant_closure_for_method_calls)]
 +
 +use std::path::{Path, PathBuf};
 +
 +macro_rules! mac {
 +    () => {
 +        foobar()
 +    };
 +}
 +
 +macro_rules! closure_mac {
 +    () => {
 +        |n| foo(n)
 +    };
 +}
 +
 +fn main() {
 +    let a = Some(1u8).map(|a| foo(a));
 +    let c = Some(1u8).map(|a| {1+2; foo}(a));
 +    true.then(|| mac!()); // don't lint function in macro expansion
 +    Some(1).map(closure_mac!()); // don't lint closure in macro expansion
 +    let _: Option<Vec<u8>> = true.then(|| vec![]); // special case vec!
 +    let d = Some(1u8).map(|a| foo((|b| foo2(b))(a))); //is adjusted?
 +    all(&[1, 2, 3], &&2, |x, y| below(x, y)); //is adjusted
 +    unsafe {
 +        Some(1u8).map(|a| unsafe_fn(a)); // unsafe fn
 +    }
 +
 +    // See #815
 +    let e = Some(1u8).map(|a| divergent(a));
 +    let e = Some(1u8).map(|a| generic(a));
 +    let e = Some(1u8).map(generic);
 +    // See #515
 +    let a: Option<Box<dyn (::std::ops::Deref<Target = [i32]>)>> =
 +        Some(vec![1i32, 2]).map(|v| -> Box<dyn (::std::ops::Deref<Target = [i32]>)> { Box::new(v) });
 +
 +    // issue #7224
 +    let _: Option<Vec<u32>> = Some(0).map(|_| vec![]);
 +}
 +
 +trait TestTrait {
 +    fn trait_foo(self) -> bool;
 +    fn trait_foo_ref(&self) -> bool;
 +}
 +
 +struct TestStruct<'a> {
 +    some_ref: &'a i32,
 +}
 +
 +impl<'a> TestStruct<'a> {
 +    fn foo(self) -> bool {
 +        false
 +    }
 +    unsafe fn foo_unsafe(self) -> bool {
 +        true
 +    }
 +}
 +
 +impl<'a> TestTrait for TestStruct<'a> {
 +    fn trait_foo(self) -> bool {
 +        false
 +    }
 +    fn trait_foo_ref(&self) -> bool {
 +        false
 +    }
 +}
 +
 +impl<'a> std::ops::Deref for TestStruct<'a> {
 +    type Target = char;
 +    fn deref(&self) -> &char {
 +        &'a'
 +    }
 +}
 +
 +fn test_redundant_closures_containing_method_calls() {
 +    let i = 10;
 +    let e = Some(TestStruct { some_ref: &i }).map(|a| a.foo());
 +    let e = Some(TestStruct { some_ref: &i }).map(|a| a.trait_foo());
 +    let e = Some(TestStruct { some_ref: &i }).map(|a| a.trait_foo_ref());
 +    let e = Some(&mut vec![1, 2, 3]).map(|v| v.clear());
 +    unsafe {
 +        let e = Some(TestStruct { some_ref: &i }).map(|a| a.foo_unsafe());
 +    }
 +    let e = Some("str").map(|s| s.to_string());
 +    let e = Some('a').map(|s| s.to_uppercase());
 +    let e: std::vec::Vec<usize> = vec!['a', 'b', 'c'].iter().map(|c| c.len_utf8()).collect();
 +    let e: std::vec::Vec<char> = vec!['a', 'b', 'c'].iter().map(|c| c.to_ascii_uppercase()).collect();
 +    let e = Some(PathBuf::new()).as_ref().and_then(|s| s.to_str());
 +    let c = Some(TestStruct { some_ref: &i })
 +        .as_ref()
 +        .map(|c| c.to_ascii_uppercase());
 +
 +    fn test_different_borrow_levels<T>(t: &[&T])
 +    where
 +        T: TestTrait,
 +    {
 +        t.iter().filter(|x| x.trait_foo_ref());
 +        t.iter().map(|x| x.trait_foo_ref());
 +    }
 +}
 +
 +struct Thunk<T>(Box<dyn FnMut() -> T>);
 +
 +impl<T> Thunk<T> {
 +    fn new<F: 'static + FnOnce() -> T>(f: F) -> Thunk<T> {
 +        let mut option = Some(f);
 +        // This should not trigger redundant_closure (#1439)
 +        Thunk(Box::new(move || option.take().unwrap()()))
 +    }
 +
 +    fn unwrap(self) -> T {
 +        let Thunk(mut f) = self;
 +        f()
 +    }
 +}
 +
 +fn foobar() {
 +    let thunk = Thunk::new(|| println!("Hello, world!"));
 +    thunk.unwrap()
 +}
 +
 +fn foo(_: u8) {}
 +
 +fn foo2(_: u8) -> u8 {
 +    1u8
 +}
 +
 +fn all<X, F>(x: &[X], y: &X, f: F) -> bool
 +where
 +    F: Fn(&X, &X) -> bool,
 +{
 +    x.iter().all(|e| f(e, y))
 +}
 +
 +fn below(x: &u8, y: &u8) -> bool {
 +    x < y
 +}
 +
 +unsafe fn unsafe_fn(_: u8) {}
 +
 +fn divergent(_: u8) -> ! {
 +    unimplemented!()
 +}
 +
 +fn generic<T>(_: T) -> u8 {
 +    0
 +}
 +
 +fn passes_fn_mut(mut x: Box<dyn FnMut()>) {
 +    requires_fn_once(|| x());
 +}
 +fn requires_fn_once<T: FnOnce()>(_: T) {}
 +
 +fn test_redundant_closure_with_function_pointer() {
 +    type FnPtrType = fn(u8);
 +    let foo_ptr: FnPtrType = foo;
 +    let a = Some(1u8).map(|a| foo_ptr(a));
 +}
 +
 +fn test_redundant_closure_with_another_closure() {
 +    let closure = |a| println!("{}", a);
 +    let a = Some(1u8).map(|a| closure(a));
 +}
 +
 +fn make_lazy(f: impl Fn() -> fn(u8) -> u8) -> impl Fn(u8) -> u8 {
 +    // Currently f is called when result of make_lazy is called.
 +    // If the closure is removed, f will be called when make_lazy itself is
 +    // called. This changes semantics, so the closure must stay.
 +    Box::new(move |x| f()(x))
 +}
 +
 +fn call<F: FnOnce(&mut String) -> String>(f: F) -> String {
 +    f(&mut "Hello".to_owned())
 +}
 +fn test_difference_in_mutability() {
 +    call(|s| s.clone());
 +}
 +
 +struct Bar;
 +impl std::ops::Deref for Bar {
 +    type Target = str;
 +    fn deref(&self) -> &str {
 +        "hi"
 +    }
 +}
 +
 +fn test_deref_with_trait_method() {
 +    let _ = [Bar].iter().map(|s| s.to_string()).collect::<Vec<_>>();
 +}
 +
 +fn mutable_closure_used_again(x: Vec<i32>, y: Vec<i32>, z: Vec<i32>) {
 +    let mut res = Vec::new();
 +    let mut add_to_res = |n| res.push(n);
 +    x.into_iter().for_each(|x| add_to_res(x));
 +    y.into_iter().for_each(|x| add_to_res(x));
 +    z.into_iter().for_each(|x| add_to_res(x));
 +}
 +
 +fn mutable_closure_in_loop() {
 +    let mut value = 0;
 +    let mut closure = |n| value += n;
 +    for _ in 0..5 {
 +        Some(1).map(|n| closure(n));
 +    }
 +}
 +
 +fn late_bound_lifetimes() {
 +    fn take_asref_path<P: AsRef<Path>>(path: P) {}
 +
 +    fn map_str<F>(thunk: F)
 +    where
 +        F: FnOnce(&str),
 +    {
 +    }
 +
 +    fn map_str_to_path<F>(thunk: F)
 +    where
 +        F: FnOnce(&str) -> &Path,
 +    {
 +    }
 +    map_str(|s| take_asref_path(s));
 +    map_str_to_path(|s| s.as_ref());
 +}
 +
 +mod type_param_bound {
 +    trait Trait {
 +        fn fun();
 +    }
 +
 +    fn take<T: 'static>(_: T) {}
 +
 +    fn test<X: Trait>() {
 +        // don't lint, but it's questionable that rust requires a cast
 +        take(|| X::fun());
 +        take(X::fun as fn());
 +    }
 +}
 +
 +// #8073 Don't replace closure with `Arc<F>` or `Rc<F>`
 +fn arc_fp() {
 +    let rc = std::rc::Rc::new(|| 7);
 +    let arc = std::sync::Arc::new(|n| n + 1);
 +    let ref_arc = &std::sync::Arc::new(|_| 5);
 +
 +    true.then(|| rc());
 +    (0..5).map(|n| arc(n));
 +    Some(4).map(|n| ref_arc(n));
 +}
index 8092f04c3fc3d28215844fdb850e19196da77bd3,0000000000000000000000000000000000000000..cda84982c9b7508020113a57acf2474077147971
mode 100644,000000..100644
--- /dev/null
@@@ -1,134 -1,0 +1,126 @@@
-   --> $DIR/eta.rs:31:27
 +error: redundant closure
-   --> $DIR/eta.rs:35:40
++  --> $DIR/eta.rs:28:27
 +   |
 +LL |     let a = Some(1u8).map(|a| foo(a));
 +   |                           ^^^^^^^^^^ help: replace the closure with the function itself: `foo`
 +   |
 +   = note: `-D clippy::redundant-closure` implied by `-D warnings`
 +
 +error: redundant closure
-   --> $DIR/eta.rs:36:35
++  --> $DIR/eta.rs:32:40
 +   |
 +LL |     let _: Option<Vec<u8>> = true.then(|| vec![]); // special case vec!
 +   |                                        ^^^^^^^^^ help: replace the closure with `Vec::new`: `std::vec::Vec::new`
 +
 +error: redundant closure
- error: this expression borrows a reference (`&u8`) that is immediately dereferenced by the compiler
-   --> $DIR/eta.rs:37:21
-    |
- LL |     all(&[1, 2, 3], &&2, |x, y| below(x, y)); //is adjusted
-    |                     ^^^ help: change this to: `&2`
-    |
-    = note: `-D clippy::needless-borrow` implied by `-D warnings`
++  --> $DIR/eta.rs:33:35
 +   |
 +LL |     let d = Some(1u8).map(|a| foo((|b| foo2(b))(a))); //is adjusted?
 +   |                                   ^^^^^^^^^^^^^ help: replace the closure with the function itself: `foo2`
 +
-   --> $DIR/eta.rs:37:26
 +error: redundant closure
-   --> $DIR/eta.rs:43:27
++  --> $DIR/eta.rs:34:26
 +   |
 +LL |     all(&[1, 2, 3], &&2, |x, y| below(x, y)); //is adjusted
 +   |                          ^^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `below`
 +
 +error: redundant closure
-   --> $DIR/eta.rs:44:27
++  --> $DIR/eta.rs:40:27
 +   |
 +LL |     let e = Some(1u8).map(|a| divergent(a));
 +   |                           ^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `divergent`
 +
 +error: redundant closure
-   --> $DIR/eta.rs:90:51
++  --> $DIR/eta.rs:41:27
 +   |
 +LL |     let e = Some(1u8).map(|a| generic(a));
 +   |                           ^^^^^^^^^^^^^^ help: replace the closure with the function itself: `generic`
 +
 +error: redundant closure
-   --> $DIR/eta.rs:91:51
++  --> $DIR/eta.rs:87:51
 +   |
 +LL |     let e = Some(TestStruct { some_ref: &i }).map(|a| a.foo());
 +   |                                                   ^^^^^^^^^^^ help: replace the closure with the method itself: `TestStruct::foo`
 +   |
 +   = note: `-D clippy::redundant-closure-for-method-calls` implied by `-D warnings`
 +
 +error: redundant closure
-   --> $DIR/eta.rs:93:42
++  --> $DIR/eta.rs:88:51
 +   |
 +LL |     let e = Some(TestStruct { some_ref: &i }).map(|a| a.trait_foo());
 +   |                                                   ^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `TestTrait::trait_foo`
 +
 +error: redundant closure
-   --> $DIR/eta.rs:97:29
++  --> $DIR/eta.rs:90:42
 +   |
 +LL |     let e = Some(&mut vec![1, 2, 3]).map(|v| v.clear());
 +   |                                          ^^^^^^^^^^^^^ help: replace the closure with the method itself: `std::vec::Vec::clear`
 +
 +error: redundant closure
-   --> $DIR/eta.rs:98:27
++  --> $DIR/eta.rs:94:29
 +   |
 +LL |     let e = Some("str").map(|s| s.to_string());
 +   |                             ^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `std::string::ToString::to_string`
 +
 +error: redundant closure
-   --> $DIR/eta.rs:100:65
++  --> $DIR/eta.rs:95:27
 +   |
 +LL |     let e = Some('a').map(|s| s.to_uppercase());
 +   |                           ^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `char::to_uppercase`
 +
 +error: redundant closure
-   --> $DIR/eta.rs:163:22
++  --> $DIR/eta.rs:97:65
 +   |
 +LL |     let e: std::vec::Vec<char> = vec!['a', 'b', 'c'].iter().map(|c| c.to_ascii_uppercase()).collect();
 +   |                                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `char::to_ascii_uppercase`
 +
 +error: redundant closure
-   --> $DIR/eta.rs:170:27
++  --> $DIR/eta.rs:160:22
 +   |
 +LL |     requires_fn_once(|| x());
 +   |                      ^^^^^^ help: replace the closure with the function itself: `x`
 +
 +error: redundant closure
-   --> $DIR/eta.rs:175:27
++  --> $DIR/eta.rs:167:27
 +   |
 +LL |     let a = Some(1u8).map(|a| foo_ptr(a));
 +   |                           ^^^^^^^^^^^^^^ help: replace the closure with the function itself: `foo_ptr`
 +
 +error: redundant closure
-   --> $DIR/eta.rs:207:28
++  --> $DIR/eta.rs:172:27
 +   |
 +LL |     let a = Some(1u8).map(|a| closure(a));
 +   |                           ^^^^^^^^^^^^^^ help: replace the closure with the function itself: `closure`
 +
 +error: redundant closure
-   --> $DIR/eta.rs:208:28
++  --> $DIR/eta.rs:204:28
 +   |
 +LL |     x.into_iter().for_each(|x| add_to_res(x));
 +   |                            ^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `&mut add_to_res`
 +
 +error: redundant closure
-   --> $DIR/eta.rs:209:28
++  --> $DIR/eta.rs:205:28
 +   |
 +LL |     y.into_iter().for_each(|x| add_to_res(x));
 +   |                            ^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `&mut add_to_res`
 +
 +error: redundant closure
-   --> $DIR/eta.rs:216:21
++  --> $DIR/eta.rs:206:28
 +   |
 +LL |     z.into_iter().for_each(|x| add_to_res(x));
 +   |                            ^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `add_to_res`
 +
 +error: redundant closure
-   --> $DIR/eta.rs:235:21
++  --> $DIR/eta.rs:213:21
 +   |
 +LL |         Some(1).map(|n| closure(n));
 +   |                     ^^^^^^^^^^^^^^ help: replace the closure with the function itself: `&mut closure`
 +
 +error: redundant closure
- error: aborting due to 21 previous errors
++  --> $DIR/eta.rs:232:21
 +   |
 +LL |     map_str_to_path(|s| s.as_ref());
 +   |                     ^^^^^^^^^^^^^^ help: replace the closure with the method itself: `std::convert::AsRef::as_ref`
 +
++error: aborting due to 20 previous errors
 +
index 48e2aae75d0bf62893c56b4a375d7f9054e5f6c9,0000000000000000000000000000000000000000..3de2a51ffa5f326c516154723da1b8ff99c53f21
mode 100644,000000..100644
--- /dev/null
@@@ -1,95 -1,0 +1,95 @@@
- #![allow(unused_variables, clippy::clone_double_ref)]
 +// run-rustfix
 +
++#![allow(unused_variables, clippy::clone_double_ref, clippy::needless_borrow)]
 +#![warn(clippy::explicit_deref_methods)]
 +
 +use std::ops::{Deref, DerefMut};
 +
 +fn concat(deref_str: &str) -> String {
 +    format!("{}bar", deref_str)
 +}
 +
 +fn just_return(deref_str: &str) -> &str {
 +    deref_str
 +}
 +
 +struct CustomVec(Vec<u8>);
 +impl Deref for CustomVec {
 +    type Target = Vec<u8>;
 +
 +    fn deref(&self) -> &Vec<u8> {
 +        &self.0
 +    }
 +}
 +
 +fn main() {
 +    let a: &mut String = &mut String::from("foo");
 +
 +    // these should require linting
 +
 +    let b: &str = &*a;
 +
 +    let b: &mut str = &mut **a;
 +
 +    // both derefs should get linted here
 +    let b: String = format!("{}, {}", &*a, &*a);
 +
 +    println!("{}", &*a);
 +
 +    #[allow(clippy::match_single_binding)]
 +    match &*a {
 +        _ => (),
 +    }
 +
 +    let b: String = concat(&*a);
 +
 +    let b = just_return(a);
 +
 +    let b: String = concat(just_return(a));
 +
 +    let b: &str = &**a;
 +
 +    let opt_a = Some(a.clone());
 +    let b = &*opt_a.unwrap();
 +
 +    // following should not require linting
 +
 +    let cv = CustomVec(vec![0, 42]);
 +    let c = cv.deref()[0];
 +
 +    let b: &str = &*a.deref();
 +
 +    let b: String = a.deref().clone();
 +
 +    let b: usize = a.deref_mut().len();
 +
 +    let b: &usize = &a.deref().len();
 +
 +    let b: &str = &*a;
 +
 +    let b: &mut str = &mut *a;
 +
 +    macro_rules! expr_deref {
 +        ($body:expr) => {
 +            $body.deref()
 +        };
 +    }
 +    let b: &str = expr_deref!(a);
 +
 +    let b: &str = expr_deref!(&*a);
 +
 +    // The struct does not implement Deref trait
 +    #[derive(Copy, Clone)]
 +    struct NoLint(u32);
 +    impl NoLint {
 +        pub fn deref(self) -> u32 {
 +            self.0
 +        }
 +        pub fn deref_mut(self) -> u32 {
 +            self.0
 +        }
 +    }
 +    let no_lint = NoLint(42);
 +    let b = no_lint.deref();
 +    let b = no_lint.deref_mut();
 +}
index d8c8c0c5ca329c52d703180117d472391d1888b0,0000000000000000000000000000000000000000..a08d75964220a06adcf52b519b4f9029f1bc3a19
mode 100644,000000..100644
--- /dev/null
@@@ -1,95 -1,0 +1,95 @@@
- #![allow(unused_variables, clippy::clone_double_ref)]
 +// run-rustfix
 +
++#![allow(unused_variables, clippy::clone_double_ref, clippy::needless_borrow)]
 +#![warn(clippy::explicit_deref_methods)]
 +
 +use std::ops::{Deref, DerefMut};
 +
 +fn concat(deref_str: &str) -> String {
 +    format!("{}bar", deref_str)
 +}
 +
 +fn just_return(deref_str: &str) -> &str {
 +    deref_str
 +}
 +
 +struct CustomVec(Vec<u8>);
 +impl Deref for CustomVec {
 +    type Target = Vec<u8>;
 +
 +    fn deref(&self) -> &Vec<u8> {
 +        &self.0
 +    }
 +}
 +
 +fn main() {
 +    let a: &mut String = &mut String::from("foo");
 +
 +    // these should require linting
 +
 +    let b: &str = a.deref();
 +
 +    let b: &mut str = a.deref_mut();
 +
 +    // both derefs should get linted here
 +    let b: String = format!("{}, {}", a.deref(), a.deref());
 +
 +    println!("{}", a.deref());
 +
 +    #[allow(clippy::match_single_binding)]
 +    match a.deref() {
 +        _ => (),
 +    }
 +
 +    let b: String = concat(a.deref());
 +
 +    let b = just_return(a).deref();
 +
 +    let b: String = concat(just_return(a).deref());
 +
 +    let b: &str = a.deref().deref();
 +
 +    let opt_a = Some(a.clone());
 +    let b = opt_a.unwrap().deref();
 +
 +    // following should not require linting
 +
 +    let cv = CustomVec(vec![0, 42]);
 +    let c = cv.deref()[0];
 +
 +    let b: &str = &*a.deref();
 +
 +    let b: String = a.deref().clone();
 +
 +    let b: usize = a.deref_mut().len();
 +
 +    let b: &usize = &a.deref().len();
 +
 +    let b: &str = &*a;
 +
 +    let b: &mut str = &mut *a;
 +
 +    macro_rules! expr_deref {
 +        ($body:expr) => {
 +            $body.deref()
 +        };
 +    }
 +    let b: &str = expr_deref!(a);
 +
 +    let b: &str = expr_deref!(a.deref());
 +
 +    // The struct does not implement Deref trait
 +    #[derive(Copy, Clone)]
 +    struct NoLint(u32);
 +    impl NoLint {
 +        pub fn deref(self) -> u32 {
 +            self.0
 +        }
 +        pub fn deref_mut(self) -> u32 {
 +            self.0
 +        }
 +    }
 +    let no_lint = NoLint(42);
 +    let b = no_lint.deref();
 +    let b = no_lint.deref_mut();
 +}
index f373e905d05cad19c78608b6dd8008db6d4224e2,0000000000000000000000000000000000000000..aa69781d15a6bc40f6222382fb0fe4d85c1a8b1f
mode 100644,000000..100644
--- /dev/null
@@@ -1,304 -1,0 +1,309 @@@
- #[allow(clippy::linkedlist, clippy::unnecessary_mut_passed, clippy::similar_names)]
 +// run-rustfix
 +
 +#![allow(dead_code, unused)]
 +
 +use std::collections::*;
 +
 +#[warn(clippy::all)]
 +struct Unrelated(Vec<u8>);
 +impl Unrelated {
 +    fn next(&self) -> std::slice::Iter<u8> {
 +        self.0.iter()
 +    }
 +
 +    fn iter(&self) -> std::slice::Iter<u8> {
 +        self.0.iter()
 +    }
 +}
 +
 +#[warn(
 +    clippy::needless_range_loop,
 +    clippy::explicit_iter_loop,
 +    clippy::explicit_into_iter_loop,
 +    clippy::iter_next_loop,
 +    clippy::for_kv_map
 +)]
++#[allow(
++    clippy::linkedlist,
++    clippy::unnecessary_mut_passed,
++    clippy::similar_names,
++    clippy::needless_borrow
++)]
 +#[allow(unused_variables)]
 +fn main() {
 +    let mut vec = vec![1, 2, 3, 4];
 +
 +    // See #601
 +    for i in 0..10 {
 +        // no error, id_col does not exist outside the loop
 +        let mut id_col = vec![0f64; 10];
 +        id_col[i] = 1f64;
 +    }
 +
 +    for _v in &vec {}
 +
 +    for _v in &mut vec {}
 +
 +    let out_vec = vec![1, 2, 3];
 +    for _v in out_vec {}
 +
 +    for _v in &vec {} // these are fine
 +    for _v in &mut vec {} // these are fine
 +
 +    for _v in &[1, 2, 3] {}
 +
 +    for _v in (&mut [1, 2, 3]).iter() {} // no error
 +
 +    for _v in &[0; 32] {}
 +
 +    for _v in [0; 33].iter() {} // no error
 +
 +    let ll: LinkedList<()> = LinkedList::new();
 +    for _v in &ll {}
 +
 +    let vd: VecDeque<()> = VecDeque::new();
 +    for _v in &vd {}
 +
 +    let bh: BinaryHeap<()> = BinaryHeap::new();
 +    for _v in &bh {}
 +
 +    let hm: HashMap<(), ()> = HashMap::new();
 +    for _v in &hm {}
 +
 +    let bt: BTreeMap<(), ()> = BTreeMap::new();
 +    for _v in &bt {}
 +
 +    let hs: HashSet<()> = HashSet::new();
 +    for _v in &hs {}
 +
 +    let bs: BTreeSet<()> = BTreeSet::new();
 +    for _v in &bs {}
 +
 +    let u = Unrelated(vec![]);
 +    for _v in u.next() {} // no error
 +    for _v in u.iter() {} // no error
 +
 +    let mut out = vec![];
 +    vec.iter().cloned().map(|x| out.push(x)).collect::<Vec<_>>();
 +    let _y = vec.iter().cloned().map(|x| out.push(x)).collect::<Vec<_>>(); // this is fine
 +
 +    // Loop with explicit counter variable
 +
 +    // Potential false positives
 +    let mut _index = 0;
 +    _index = 1;
 +    for _v in &vec {
 +        _index += 1
 +    }
 +
 +    let mut _index = 0;
 +    _index += 1;
 +    for _v in &vec {
 +        _index += 1
 +    }
 +
 +    let mut _index = 0;
 +    if true {
 +        _index = 1
 +    }
 +    for _v in &vec {
 +        _index += 1
 +    }
 +
 +    let mut _index = 0;
 +    let mut _index = 1;
 +    for _v in &vec {
 +        _index += 1
 +    }
 +
 +    let mut _index = 0;
 +    for _v in &vec {
 +        _index += 1;
 +        _index += 1
 +    }
 +
 +    let mut _index = 0;
 +    for _v in &vec {
 +        _index *= 2;
 +        _index += 1
 +    }
 +
 +    let mut _index = 0;
 +    for _v in &vec {
 +        _index = 1;
 +        _index += 1
 +    }
 +
 +    let mut _index = 0;
 +
 +    for _v in &vec {
 +        let mut _index = 0;
 +        _index += 1
 +    }
 +
 +    let mut _index = 0;
 +    for _v in &vec {
 +        _index += 1;
 +        _index = 0;
 +    }
 +
 +    let mut _index = 0;
 +    for _v in &vec {
 +        for _x in 0..1 {
 +            _index += 1;
 +        }
 +        _index += 1
 +    }
 +
 +    let mut _index = 0;
 +    for x in &vec {
 +        if *x == 1 {
 +            _index += 1
 +        }
 +    }
 +
 +    let mut _index = 0;
 +    if true {
 +        _index = 1
 +    };
 +    for _v in &vec {
 +        _index += 1
 +    }
 +
 +    let mut _index = 1;
 +    if false {
 +        _index = 0
 +    };
 +    for _v in &vec {
 +        _index += 1
 +    }
 +
 +    let mut index = 0;
 +    {
 +        let mut _x = &mut index;
 +    }
 +    for _v in &vec {
 +        _index += 1
 +    }
 +
 +    let mut index = 0;
 +    for _v in &vec {
 +        index += 1
 +    }
 +    println!("index: {}", index);
 +
 +    fn f<T>(_: &T, _: &T) -> bool {
 +        unimplemented!()
 +    }
 +    fn g<T>(_: &mut [T], _: usize, _: usize) {
 +        unimplemented!()
 +    }
 +    for i in 1..vec.len() {
 +        if f(&vec[i - 1], &vec[i]) {
 +            g(&mut vec, i - 1, i);
 +        }
 +    }
 +
 +    for mid in 1..vec.len() {
 +        let (_, _) = vec.split_at(mid);
 +    }
 +}
 +
 +fn partition<T: PartialOrd + Send>(v: &mut [T]) -> usize {
 +    let pivot = v.len() - 1;
 +    let mut i = 0;
 +    for j in 0..pivot {
 +        if v[j] <= v[pivot] {
 +            v.swap(i, j);
 +            i += 1;
 +        }
 +    }
 +    v.swap(i, pivot);
 +    i
 +}
 +
 +#[warn(clippy::needless_range_loop)]
 +pub fn manual_copy_same_destination(dst: &mut [i32], d: usize, s: usize) {
 +    // Same source and destination - don't trigger lint
 +    for i in 0..dst.len() {
 +        dst[d + i] = dst[s + i];
 +    }
 +}
 +
 +mod issue_2496 {
 +    pub trait Handle {
 +        fn new_for_index(index: usize) -> Self;
 +        fn index(&self) -> usize;
 +    }
 +
 +    pub fn test<H: Handle>() -> H {
 +        for x in 0..5 {
 +            let next_handle = H::new_for_index(x);
 +            println!("{}", next_handle.index());
 +        }
 +        unimplemented!()
 +    }
 +}
 +
 +// explicit_into_iter_loop bad suggestions
 +#[warn(clippy::explicit_into_iter_loop, clippy::explicit_iter_loop)]
 +mod issue_4958 {
 +    fn takes_iterator<T>(iterator: &T)
 +    where
 +        for<'a> &'a T: IntoIterator<Item = &'a String>,
 +    {
 +        for i in iterator {
 +            println!("{}", i);
 +        }
 +    }
 +
 +    struct T;
 +    impl IntoIterator for &T {
 +        type Item = ();
 +        type IntoIter = std::vec::IntoIter<Self::Item>;
 +        fn into_iter(self) -> Self::IntoIter {
 +            vec![].into_iter()
 +        }
 +    }
 +
 +    fn more_tests() {
 +        let t = T;
 +        let r = &t;
 +        let rr = &&t;
 +
 +        // This case is handled by `explicit_iter_loop`. No idea why.
 +        for _ in &t {}
 +
 +        for _ in r {}
 +
 +        // No suggestion for this.
 +        // We'd have to suggest `for _ in *rr {}` which is less clear.
 +        for _ in rr.into_iter() {}
 +    }
 +}
 +
 +// explicit_into_iter_loop
 +#[warn(clippy::explicit_into_iter_loop)]
 +mod issue_6900 {
 +    struct S;
 +    impl S {
 +        #[allow(clippy::should_implement_trait)]
 +        pub fn into_iter<T>(self) -> I<T> {
 +            unimplemented!()
 +        }
 +    }
 +
 +    struct I<T>(T);
 +    impl<T> Iterator for I<T> {
 +        type Item = T;
 +        fn next(&mut self) -> Option<Self::Item> {
 +            unimplemented!()
 +        }
 +    }
 +
 +    fn f() {
 +        for _ in S.into_iter::<u32>() {
 +            unimplemented!()
 +        }
 +    }
 +}
index 3814583bb6ef42d51f9732372d1fb11d2ded5ebb,0000000000000000000000000000000000000000..7c063d99511d81950720ef67753c78f0cba81318
mode 100644,000000..100644
--- /dev/null
@@@ -1,304 -1,0 +1,309 @@@
- #[allow(clippy::linkedlist, clippy::unnecessary_mut_passed, clippy::similar_names)]
 +// run-rustfix
 +
 +#![allow(dead_code, unused)]
 +
 +use std::collections::*;
 +
 +#[warn(clippy::all)]
 +struct Unrelated(Vec<u8>);
 +impl Unrelated {
 +    fn next(&self) -> std::slice::Iter<u8> {
 +        self.0.iter()
 +    }
 +
 +    fn iter(&self) -> std::slice::Iter<u8> {
 +        self.0.iter()
 +    }
 +}
 +
 +#[warn(
 +    clippy::needless_range_loop,
 +    clippy::explicit_iter_loop,
 +    clippy::explicit_into_iter_loop,
 +    clippy::iter_next_loop,
 +    clippy::for_kv_map
 +)]
++#[allow(
++    clippy::linkedlist,
++    clippy::unnecessary_mut_passed,
++    clippy::similar_names,
++    clippy::needless_borrow
++)]
 +#[allow(unused_variables)]
 +fn main() {
 +    let mut vec = vec![1, 2, 3, 4];
 +
 +    // See #601
 +    for i in 0..10 {
 +        // no error, id_col does not exist outside the loop
 +        let mut id_col = vec![0f64; 10];
 +        id_col[i] = 1f64;
 +    }
 +
 +    for _v in vec.iter() {}
 +
 +    for _v in vec.iter_mut() {}
 +
 +    let out_vec = vec![1, 2, 3];
 +    for _v in out_vec.into_iter() {}
 +
 +    for _v in &vec {} // these are fine
 +    for _v in &mut vec {} // these are fine
 +
 +    for _v in [1, 2, 3].iter() {}
 +
 +    for _v in (&mut [1, 2, 3]).iter() {} // no error
 +
 +    for _v in [0; 32].iter() {}
 +
 +    for _v in [0; 33].iter() {} // no error
 +
 +    let ll: LinkedList<()> = LinkedList::new();
 +    for _v in ll.iter() {}
 +
 +    let vd: VecDeque<()> = VecDeque::new();
 +    for _v in vd.iter() {}
 +
 +    let bh: BinaryHeap<()> = BinaryHeap::new();
 +    for _v in bh.iter() {}
 +
 +    let hm: HashMap<(), ()> = HashMap::new();
 +    for _v in hm.iter() {}
 +
 +    let bt: BTreeMap<(), ()> = BTreeMap::new();
 +    for _v in bt.iter() {}
 +
 +    let hs: HashSet<()> = HashSet::new();
 +    for _v in hs.iter() {}
 +
 +    let bs: BTreeSet<()> = BTreeSet::new();
 +    for _v in bs.iter() {}
 +
 +    let u = Unrelated(vec![]);
 +    for _v in u.next() {} // no error
 +    for _v in u.iter() {} // no error
 +
 +    let mut out = vec![];
 +    vec.iter().cloned().map(|x| out.push(x)).collect::<Vec<_>>();
 +    let _y = vec.iter().cloned().map(|x| out.push(x)).collect::<Vec<_>>(); // this is fine
 +
 +    // Loop with explicit counter variable
 +
 +    // Potential false positives
 +    let mut _index = 0;
 +    _index = 1;
 +    for _v in &vec {
 +        _index += 1
 +    }
 +
 +    let mut _index = 0;
 +    _index += 1;
 +    for _v in &vec {
 +        _index += 1
 +    }
 +
 +    let mut _index = 0;
 +    if true {
 +        _index = 1
 +    }
 +    for _v in &vec {
 +        _index += 1
 +    }
 +
 +    let mut _index = 0;
 +    let mut _index = 1;
 +    for _v in &vec {
 +        _index += 1
 +    }
 +
 +    let mut _index = 0;
 +    for _v in &vec {
 +        _index += 1;
 +        _index += 1
 +    }
 +
 +    let mut _index = 0;
 +    for _v in &vec {
 +        _index *= 2;
 +        _index += 1
 +    }
 +
 +    let mut _index = 0;
 +    for _v in &vec {
 +        _index = 1;
 +        _index += 1
 +    }
 +
 +    let mut _index = 0;
 +
 +    for _v in &vec {
 +        let mut _index = 0;
 +        _index += 1
 +    }
 +
 +    let mut _index = 0;
 +    for _v in &vec {
 +        _index += 1;
 +        _index = 0;
 +    }
 +
 +    let mut _index = 0;
 +    for _v in &vec {
 +        for _x in 0..1 {
 +            _index += 1;
 +        }
 +        _index += 1
 +    }
 +
 +    let mut _index = 0;
 +    for x in &vec {
 +        if *x == 1 {
 +            _index += 1
 +        }
 +    }
 +
 +    let mut _index = 0;
 +    if true {
 +        _index = 1
 +    };
 +    for _v in &vec {
 +        _index += 1
 +    }
 +
 +    let mut _index = 1;
 +    if false {
 +        _index = 0
 +    };
 +    for _v in &vec {
 +        _index += 1
 +    }
 +
 +    let mut index = 0;
 +    {
 +        let mut _x = &mut index;
 +    }
 +    for _v in &vec {
 +        _index += 1
 +    }
 +
 +    let mut index = 0;
 +    for _v in &vec {
 +        index += 1
 +    }
 +    println!("index: {}", index);
 +
 +    fn f<T>(_: &T, _: &T) -> bool {
 +        unimplemented!()
 +    }
 +    fn g<T>(_: &mut [T], _: usize, _: usize) {
 +        unimplemented!()
 +    }
 +    for i in 1..vec.len() {
 +        if f(&vec[i - 1], &vec[i]) {
 +            g(&mut vec, i - 1, i);
 +        }
 +    }
 +
 +    for mid in 1..vec.len() {
 +        let (_, _) = vec.split_at(mid);
 +    }
 +}
 +
 +fn partition<T: PartialOrd + Send>(v: &mut [T]) -> usize {
 +    let pivot = v.len() - 1;
 +    let mut i = 0;
 +    for j in 0..pivot {
 +        if v[j] <= v[pivot] {
 +            v.swap(i, j);
 +            i += 1;
 +        }
 +    }
 +    v.swap(i, pivot);
 +    i
 +}
 +
 +#[warn(clippy::needless_range_loop)]
 +pub fn manual_copy_same_destination(dst: &mut [i32], d: usize, s: usize) {
 +    // Same source and destination - don't trigger lint
 +    for i in 0..dst.len() {
 +        dst[d + i] = dst[s + i];
 +    }
 +}
 +
 +mod issue_2496 {
 +    pub trait Handle {
 +        fn new_for_index(index: usize) -> Self;
 +        fn index(&self) -> usize;
 +    }
 +
 +    pub fn test<H: Handle>() -> H {
 +        for x in 0..5 {
 +            let next_handle = H::new_for_index(x);
 +            println!("{}", next_handle.index());
 +        }
 +        unimplemented!()
 +    }
 +}
 +
 +// explicit_into_iter_loop bad suggestions
 +#[warn(clippy::explicit_into_iter_loop, clippy::explicit_iter_loop)]
 +mod issue_4958 {
 +    fn takes_iterator<T>(iterator: &T)
 +    where
 +        for<'a> &'a T: IntoIterator<Item = &'a String>,
 +    {
 +        for i in iterator.into_iter() {
 +            println!("{}", i);
 +        }
 +    }
 +
 +    struct T;
 +    impl IntoIterator for &T {
 +        type Item = ();
 +        type IntoIter = std::vec::IntoIter<Self::Item>;
 +        fn into_iter(self) -> Self::IntoIter {
 +            vec![].into_iter()
 +        }
 +    }
 +
 +    fn more_tests() {
 +        let t = T;
 +        let r = &t;
 +        let rr = &&t;
 +
 +        // This case is handled by `explicit_iter_loop`. No idea why.
 +        for _ in t.into_iter() {}
 +
 +        for _ in r.into_iter() {}
 +
 +        // No suggestion for this.
 +        // We'd have to suggest `for _ in *rr {}` which is less clear.
 +        for _ in rr.into_iter() {}
 +    }
 +}
 +
 +// explicit_into_iter_loop
 +#[warn(clippy::explicit_into_iter_loop)]
 +mod issue_6900 {
 +    struct S;
 +    impl S {
 +        #[allow(clippy::should_implement_trait)]
 +        pub fn into_iter<T>(self) -> I<T> {
 +            unimplemented!()
 +        }
 +    }
 +
 +    struct I<T>(T);
 +    impl<T> Iterator for I<T> {
 +        type Item = T;
 +        fn next(&mut self) -> Option<Self::Item> {
 +            unimplemented!()
 +        }
 +    }
 +
 +    fn f() {
 +        for _ in S.into_iter::<u32>() {
 +            unimplemented!()
 +        }
 +    }
 +}
index 009dbe1a0bfaf49f2a967696b471e5e4b541475e,0000000000000000000000000000000000000000..ddfe66d675f91efbc8f070116c570ef9eda5a496
mode 100644,000000..100644
--- /dev/null
@@@ -1,96 -1,0 +1,96 @@@
-   --> $DIR/for_loop_fixable.rs:38:15
 +error: it is more concise to loop over references to containers instead of using explicit iteration methods
-   --> $DIR/for_loop_fixable.rs:40:15
++  --> $DIR/for_loop_fixable.rs:43:15
 +   |
 +LL |     for _v in vec.iter() {}
 +   |               ^^^^^^^^^^ help: to write this more concisely, try: `&vec`
 +   |
 +   = note: `-D clippy::explicit-iter-loop` implied by `-D warnings`
 +
 +error: it is more concise to loop over references to containers instead of using explicit iteration methods
-   --> $DIR/for_loop_fixable.rs:43:15
++  --> $DIR/for_loop_fixable.rs:45:15
 +   |
 +LL |     for _v in vec.iter_mut() {}
 +   |               ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&mut vec`
 +
 +error: it is more concise to loop over containers instead of using explicit iteration methods
-   --> $DIR/for_loop_fixable.rs:48:15
++  --> $DIR/for_loop_fixable.rs:48:15
 +   |
 +LL |     for _v in out_vec.into_iter() {}
 +   |               ^^^^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `out_vec`
 +   |
 +   = note: `-D clippy::explicit-into-iter-loop` implied by `-D warnings`
 +
 +error: it is more concise to loop over references to containers instead of using explicit iteration methods
-   --> $DIR/for_loop_fixable.rs:52:15
++  --> $DIR/for_loop_fixable.rs:53:15
 +   |
 +LL |     for _v in [1, 2, 3].iter() {}
 +   |               ^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `&[1, 2, 3]`
 +
 +error: it is more concise to loop over references to containers instead of using explicit iteration methods
-   --> $DIR/for_loop_fixable.rs:57:15
++  --> $DIR/for_loop_fixable.rs:57:15
 +   |
 +LL |     for _v in [0; 32].iter() {}
 +   |               ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&[0; 32]`
 +
 +error: it is more concise to loop over references to containers instead of using explicit iteration methods
-   --> $DIR/for_loop_fixable.rs:60:15
++  --> $DIR/for_loop_fixable.rs:62:15
 +   |
 +LL |     for _v in ll.iter() {}
 +   |               ^^^^^^^^^ help: to write this more concisely, try: `&ll`
 +
 +error: it is more concise to loop over references to containers instead of using explicit iteration methods
-   --> $DIR/for_loop_fixable.rs:63:15
++  --> $DIR/for_loop_fixable.rs:65:15
 +   |
 +LL |     for _v in vd.iter() {}
 +   |               ^^^^^^^^^ help: to write this more concisely, try: `&vd`
 +
 +error: it is more concise to loop over references to containers instead of using explicit iteration methods
-   --> $DIR/for_loop_fixable.rs:66:15
++  --> $DIR/for_loop_fixable.rs:68:15
 +   |
 +LL |     for _v in bh.iter() {}
 +   |               ^^^^^^^^^ help: to write this more concisely, try: `&bh`
 +
 +error: it is more concise to loop over references to containers instead of using explicit iteration methods
-   --> $DIR/for_loop_fixable.rs:69:15
++  --> $DIR/for_loop_fixable.rs:71:15
 +   |
 +LL |     for _v in hm.iter() {}
 +   |               ^^^^^^^^^ help: to write this more concisely, try: `&hm`
 +
 +error: it is more concise to loop over references to containers instead of using explicit iteration methods
-   --> $DIR/for_loop_fixable.rs:72:15
++  --> $DIR/for_loop_fixable.rs:74:15
 +   |
 +LL |     for _v in bt.iter() {}
 +   |               ^^^^^^^^^ help: to write this more concisely, try: `&bt`
 +
 +error: it is more concise to loop over references to containers instead of using explicit iteration methods
-   --> $DIR/for_loop_fixable.rs:75:15
++  --> $DIR/for_loop_fixable.rs:77:15
 +   |
 +LL |     for _v in hs.iter() {}
 +   |               ^^^^^^^^^ help: to write this more concisely, try: `&hs`
 +
 +error: it is more concise to loop over references to containers instead of using explicit iteration methods
-   --> $DIR/for_loop_fixable.rs:250:18
++  --> $DIR/for_loop_fixable.rs:80:15
 +   |
 +LL |     for _v in bs.iter() {}
 +   |               ^^^^^^^^^ help: to write this more concisely, try: `&bs`
 +
 +error: it is more concise to loop over containers instead of using explicit iteration methods
-   --> $DIR/for_loop_fixable.rs:270:18
++  --> $DIR/for_loop_fixable.rs:255:18
 +   |
 +LL |         for i in iterator.into_iter() {
 +   |                  ^^^^^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `iterator`
 +
 +error: it is more concise to loop over references to containers instead of using explicit iteration methods
-   --> $DIR/for_loop_fixable.rs:272:18
++  --> $DIR/for_loop_fixable.rs:275:18
 +   |
 +LL |         for _ in t.into_iter() {}
 +   |                  ^^^^^^^^^^^^^ help: to write this more concisely, try: `&t`
 +
 +error: it is more concise to loop over containers instead of using explicit iteration methods
++  --> $DIR/for_loop_fixable.rs:277:18
 +   |
 +LL |         for _ in r.into_iter() {}
 +   |                  ^^^^^^^^^^^^^ help: to write this more concisely, try: `r`
 +
 +error: aborting due to 15 previous errors
 +
index 78d2bfd474e4a18cbd9f687e488a69fd03ef076d,0000000000000000000000000000000000000000..d08f8f52495adf56f677098a395f10eb94fd5fca
mode 100644,000000..100644
--- /dev/null
@@@ -1,82 -1,0 +1,87 @@@
- #![allow(clippy::print_literal, clippy::redundant_clone, clippy::to_string_in_format_args)]
 +// run-rustfix
 +
++#![allow(
++    clippy::print_literal,
++    clippy::redundant_clone,
++    clippy::to_string_in_format_args,
++    clippy::needless_borrow
++)]
 +#![warn(clippy::useless_format)]
 +
 +struct Foo(pub String);
 +
 +macro_rules! foo {
 +    ($($t:tt)*) => (Foo(format!($($t)*)))
 +}
 +
 +fn main() {
 +    "foo".to_string();
 +    "{}".to_string();
 +    "{} abc {}".to_string();
 +    r##"foo {}
 +" bar"##.to_string();
 +
 +    let _ = String::new();
 +
 +    "foo".to_string();
 +    format!("{:?}", "foo"); // Don't warn about `Debug`.
 +    format!("{:8}", "foo");
 +    format!("{:width$}", "foo", width = 8);
 +    "foo".to_string(); // Warn when the format makes no difference.
 +    "foo".to_string(); // Warn when the format makes no difference.
 +    format!("foo {}", "bar");
 +    format!("{} bar", "foo");
 +
 +    let arg: String = "".to_owned();
 +    arg.to_string();
 +    format!("{:?}", arg); // Don't warn about debug.
 +    format!("{:8}", arg);
 +    format!("{:width$}", arg, width = 8);
 +    arg.to_string(); // Warn when the format makes no difference.
 +    arg.to_string(); // Warn when the format makes no difference.
 +    format!("foo {}", arg);
 +    format!("{} bar", arg);
 +
 +    // We don’t want to warn for non-string args; see issue #697.
 +    format!("{}", 42);
 +    format!("{:?}", 42);
 +    format!("{:+}", 42);
 +    format!("foo {}", 42);
 +    format!("{} bar", 42);
 +
 +    // We only want to warn about `format!` itself.
 +    println!("foo");
 +    println!("{}", "foo");
 +    println!("foo {}", "foo");
 +    println!("{}", 42);
 +    println!("foo {}", 42);
 +
 +    // A `format!` inside a macro should not trigger a warning.
 +    foo!("should not warn");
 +
 +    // Precision on string means slicing without panicking on size.
 +    format!("{:.1}", "foo"); // Could be `"foo"[..1]`
 +    format!("{:.10}", "foo"); // Could not be `"foo"[..10]`
 +    format!("{:.prec$}", "foo", prec = 1);
 +    format!("{:.prec$}", "foo", prec = 10);
 +
 +    42.to_string();
 +    let x = std::path::PathBuf::from("/bar/foo/qux");
 +    x.display().to_string();
 +
 +    // False positive
 +    let a = "foo".to_string();
 +    let _ = Some(a + "bar");
 +
 +    // Wrap it with braces
 +    let v: Vec<String> = vec!["foo".to_string(), "bar".to_string()];
 +    let _s: String = (&*v.join("\n")).to_string();
 +
 +    format!("prepend {:+}", "s");
 +
 +    // Issue #8290
 +    let x = "foo";
 +    let _ = x.to_string();
 +    let _ = format!("{x:?}"); // Don't lint on debug
 +    let _ = x.to_string();
 +}
index 009c1aa216fcd8b6e89f1de0b383c486ce038ec8,0000000000000000000000000000000000000000..4a10b580d2600171fed59d008a687756fcfef0aa
mode 100644,000000..100644
--- /dev/null
@@@ -1,84 -1,0 +1,89 @@@
- #![allow(clippy::print_literal, clippy::redundant_clone, clippy::to_string_in_format_args)]
 +// run-rustfix
 +
++#![allow(
++    clippy::print_literal,
++    clippy::redundant_clone,
++    clippy::to_string_in_format_args,
++    clippy::needless_borrow
++)]
 +#![warn(clippy::useless_format)]
 +
 +struct Foo(pub String);
 +
 +macro_rules! foo {
 +    ($($t:tt)*) => (Foo(format!($($t)*)))
 +}
 +
 +fn main() {
 +    format!("foo");
 +    format!("{{}}");
 +    format!("{{}} abc {{}}");
 +    format!(
 +        r##"foo {{}}
 +" bar"##
 +    );
 +
 +    let _ = format!("");
 +
 +    format!("{}", "foo");
 +    format!("{:?}", "foo"); // Don't warn about `Debug`.
 +    format!("{:8}", "foo");
 +    format!("{:width$}", "foo", width = 8);
 +    format!("{:+}", "foo"); // Warn when the format makes no difference.
 +    format!("{:<}", "foo"); // Warn when the format makes no difference.
 +    format!("foo {}", "bar");
 +    format!("{} bar", "foo");
 +
 +    let arg: String = "".to_owned();
 +    format!("{}", arg);
 +    format!("{:?}", arg); // Don't warn about debug.
 +    format!("{:8}", arg);
 +    format!("{:width$}", arg, width = 8);
 +    format!("{:+}", arg); // Warn when the format makes no difference.
 +    format!("{:<}", arg); // Warn when the format makes no difference.
 +    format!("foo {}", arg);
 +    format!("{} bar", arg);
 +
 +    // We don’t want to warn for non-string args; see issue #697.
 +    format!("{}", 42);
 +    format!("{:?}", 42);
 +    format!("{:+}", 42);
 +    format!("foo {}", 42);
 +    format!("{} bar", 42);
 +
 +    // We only want to warn about `format!` itself.
 +    println!("foo");
 +    println!("{}", "foo");
 +    println!("foo {}", "foo");
 +    println!("{}", 42);
 +    println!("foo {}", 42);
 +
 +    // A `format!` inside a macro should not trigger a warning.
 +    foo!("should not warn");
 +
 +    // Precision on string means slicing without panicking on size.
 +    format!("{:.1}", "foo"); // Could be `"foo"[..1]`
 +    format!("{:.10}", "foo"); // Could not be `"foo"[..10]`
 +    format!("{:.prec$}", "foo", prec = 1);
 +    format!("{:.prec$}", "foo", prec = 10);
 +
 +    format!("{}", 42.to_string());
 +    let x = std::path::PathBuf::from("/bar/foo/qux");
 +    format!("{}", x.display().to_string());
 +
 +    // False positive
 +    let a = "foo".to_string();
 +    let _ = Some(format!("{}", a + "bar"));
 +
 +    // Wrap it with braces
 +    let v: Vec<String> = vec!["foo".to_string(), "bar".to_string()];
 +    let _s: String = format!("{}", &*v.join("\n"));
 +
 +    format!("prepend {:+}", "s");
 +
 +    // Issue #8290
 +    let x = "foo";
 +    let _ = format!("{x}");
 +    let _ = format!("{x:?}"); // Don't lint on debug
 +    let _ = format!("{y}", y = x);
 +}
index 660be57585e3710f3839e5f07ab2cea93091e27b,0000000000000000000000000000000000000000..f25c7fb1ff1cbc8fda16579ded43a98d6f7775dc
mode 100644,000000..100644
--- /dev/null
@@@ -1,115 -1,0 +1,115 @@@
-   --> $DIR/format.rs:13:5
 +error: useless use of `format!`
-   --> $DIR/format.rs:14:5
++  --> $DIR/format.rs:18:5
 +   |
 +LL |     format!("foo");
 +   |     ^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"foo".to_string()`
 +   |
 +   = note: `-D clippy::useless-format` implied by `-D warnings`
 +
 +error: useless use of `format!`
-   --> $DIR/format.rs:15:5
++  --> $DIR/format.rs:19:5
 +   |
 +LL |     format!("{{}}");
 +   |     ^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"{}".to_string()`
 +
 +error: useless use of `format!`
-   --> $DIR/format.rs:16:5
++  --> $DIR/format.rs:20:5
 +   |
 +LL |     format!("{{}} abc {{}}");
 +   |     ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"{} abc {}".to_string()`
 +
 +error: useless use of `format!`
-   --> $DIR/format.rs:21:13
++  --> $DIR/format.rs:21:5
 +   |
 +LL | /     format!(
 +LL | |         r##"foo {{}}
 +LL | | " bar"##
 +LL | |     );
 +   | |_____^
 +   |
 +help: consider using `.to_string()`
 +   |
 +LL ~     r##"foo {}
 +LL ~ " bar"##.to_string();
 +   |
 +
 +error: useless use of `format!`
-   --> $DIR/format.rs:23:5
++  --> $DIR/format.rs:26:13
 +   |
 +LL |     let _ = format!("");
 +   |             ^^^^^^^^^^^ help: consider using `String::new()`: `String::new()`
 +
 +error: useless use of `format!`
-   --> $DIR/format.rs:27:5
++  --> $DIR/format.rs:28:5
 +   |
 +LL |     format!("{}", "foo");
 +   |     ^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"foo".to_string()`
 +
 +error: useless use of `format!`
-   --> $DIR/format.rs:28:5
++  --> $DIR/format.rs:32:5
 +   |
 +LL |     format!("{:+}", "foo"); // Warn when the format makes no difference.
 +   |     ^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"foo".to_string()`
 +
 +error: useless use of `format!`
-   --> $DIR/format.rs:33:5
++  --> $DIR/format.rs:33:5
 +   |
 +LL |     format!("{:<}", "foo"); // Warn when the format makes no difference.
 +   |     ^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"foo".to_string()`
 +
 +error: useless use of `format!`
-   --> $DIR/format.rs:37:5
++  --> $DIR/format.rs:38:5
 +   |
 +LL |     format!("{}", arg);
 +   |     ^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `arg.to_string()`
 +
 +error: useless use of `format!`
-   --> $DIR/format.rs:38:5
++  --> $DIR/format.rs:42:5
 +   |
 +LL |     format!("{:+}", arg); // Warn when the format makes no difference.
 +   |     ^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `arg.to_string()`
 +
 +error: useless use of `format!`
-   --> $DIR/format.rs:65:5
++  --> $DIR/format.rs:43:5
 +   |
 +LL |     format!("{:<}", arg); // Warn when the format makes no difference.
 +   |     ^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `arg.to_string()`
 +
 +error: useless use of `format!`
-   --> $DIR/format.rs:67:5
++  --> $DIR/format.rs:70:5
 +   |
 +LL |     format!("{}", 42.to_string());
 +   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `42.to_string()`
 +
 +error: useless use of `format!`
-   --> $DIR/format.rs:71:18
++  --> $DIR/format.rs:72:5
 +   |
 +LL |     format!("{}", x.display().to_string());
 +   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `x.display().to_string()`
 +
 +error: useless use of `format!`
-   --> $DIR/format.rs:75:22
++  --> $DIR/format.rs:76:18
 +   |
 +LL |     let _ = Some(format!("{}", a + "bar"));
 +   |                  ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `a + "bar"`
 +
 +error: useless use of `format!`
-   --> $DIR/format.rs:81:13
++  --> $DIR/format.rs:80:22
 +   |
 +LL |     let _s: String = format!("{}", &*v.join("/n"));
 +   |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `(&*v.join("/n")).to_string()`
 +
 +error: useless use of `format!`
-   --> $DIR/format.rs:83:13
++  --> $DIR/format.rs:86:13
 +   |
 +LL |     let _ = format!("{x}");
 +   |             ^^^^^^^^^^^^^^ help: consider using `.to_string()`: `x.to_string()`
 +
 +error: useless use of `format!`
++  --> $DIR/format.rs:88:13
 +   |
 +LL |     let _ = format!("{y}", y = x);
 +   |             ^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `x.to_string()`
 +
 +error: aborting due to 17 previous errors
 +
index 9e37fb9255984fd5421bcff122e237c30d98abaf,0000000000000000000000000000000000000000..b856f1375d303ad11520922ae7a78fc9e359c0be
mode 100644,000000..100644
--- /dev/null
@@@ -1,71 -1,0 +1,98 @@@
 +// run-rustfix
 +
 +#[warn(clippy::all, clippy::needless_borrow)]
 +#[allow(unused_variables, clippy::unnecessary_mut_passed)]
 +fn main() {
 +    let a = 5;
 +    let ref_a = &a;
 +    let _ = x(&a); // no warning
 +    let _ = x(&a); // warn
 +
 +    let mut b = 5;
 +    mut_ref(&mut b); // no warning
 +    mut_ref(&mut b); // warn
 +
 +    let s = &String::from("hi");
 +    let s_ident = f(&s); // should not error, because `&String` implements Copy, but `String` does not
 +    let g_val = g(&Vec::new()); // should not error, because `&Vec<T>` derefs to `&[T]`
 +    let vec = Vec::new();
 +    let vec_val = g(&vec); // should not error, because `&Vec<T>` derefs to `&[T]`
 +    h(&"foo"); // should not error, because the `&&str` is required, due to `&Trait`
 +    let garbl = match 42 {
 +        44 => &a,
 +        45 => {
 +            println!("foo");
 +            &a
 +        },
 +        46 => &a,
 +        47 => {
 +            println!("foo");
 +            loop {
 +                println!("{}", a);
 +                if a == 25 {
 +                    break ref_a;
 +                }
 +            }
 +        },
 +        _ => panic!(),
 +    };
 +
 +    let _ = x(&a);
 +    let _ = x(&a);
 +    let _ = x(&mut b);
 +    let _ = x(ref_a);
 +    {
 +        let b = &mut b;
 +        x(b);
 +    }
++
++    // Issue #8191
++    let mut x = 5;
++    let mut x = &mut x;
++
++    mut_ref(x);
++    mut_ref(x);
++    let y: &mut i32 = x;
++    let y: &mut i32 = x;
++
++    let y = match 0 {
++        // Don't lint. Removing the borrow would move 'x'
++        0 => &mut x,
++        _ => &mut *x,
++    };
++
++    *x = 5;
++
++    let s = String::new();
++    let _ = s.len();
++    let _ = s.capacity();
++    let _ = s.capacity();
++
++    let x = (1, 2);
++    let _ = x.0;
++    let x = &x as *const (i32, i32);
++    let _ = unsafe { (*x).0 };
 +}
 +
 +#[allow(clippy::needless_borrowed_reference)]
 +fn x(y: &i32) -> i32 {
 +    *y
 +}
 +
 +fn mut_ref(y: &mut i32) {
 +    *y = 5;
 +}
 +
 +fn f<T: Copy>(y: &T) -> T {
 +    *y
 +}
 +
 +fn g(y: &[u8]) -> u8 {
 +    y[0]
 +}
 +
 +trait Trait {}
 +
 +impl<'a> Trait for &'a str {}
 +
 +fn h(_: &dyn Trait) {}
index 093277784beb2ea6225ecea6087ff98bd9a5130f,0000000000000000000000000000000000000000..0bfe222a3dc170ee85bf20f1e2fadb2766891560
mode 100644,000000..100644
--- /dev/null
@@@ -1,71 -1,0 +1,98 @@@
 +// run-rustfix
 +
 +#[warn(clippy::all, clippy::needless_borrow)]
 +#[allow(unused_variables, clippy::unnecessary_mut_passed)]
 +fn main() {
 +    let a = 5;
 +    let ref_a = &a;
 +    let _ = x(&a); // no warning
 +    let _ = x(&&a); // warn
 +
 +    let mut b = 5;
 +    mut_ref(&mut b); // no warning
 +    mut_ref(&mut &mut b); // warn
 +
 +    let s = &String::from("hi");
 +    let s_ident = f(&s); // should not error, because `&String` implements Copy, but `String` does not
 +    let g_val = g(&Vec::new()); // should not error, because `&Vec<T>` derefs to `&[T]`
 +    let vec = Vec::new();
 +    let vec_val = g(&vec); // should not error, because `&Vec<T>` derefs to `&[T]`
 +    h(&"foo"); // should not error, because the `&&str` is required, due to `&Trait`
 +    let garbl = match 42 {
 +        44 => &a,
 +        45 => {
 +            println!("foo");
 +            &&a
 +        },
 +        46 => &&a,
 +        47 => {
 +            println!("foo");
 +            loop {
 +                println!("{}", a);
 +                if a == 25 {
 +                    break &ref_a;
 +                }
 +            }
 +        },
 +        _ => panic!(),
 +    };
 +
 +    let _ = x(&&&a);
 +    let _ = x(&mut &&a);
 +    let _ = x(&&&mut b);
 +    let _ = x(&&ref_a);
 +    {
 +        let b = &mut b;
 +        x(&b);
 +    }
++
++    // Issue #8191
++    let mut x = 5;
++    let mut x = &mut x;
++
++    mut_ref(&mut x);
++    mut_ref(&mut &mut x);
++    let y: &mut i32 = &mut x;
++    let y: &mut i32 = &mut &mut x;
++
++    let y = match 0 {
++        // Don't lint. Removing the borrow would move 'x'
++        0 => &mut x,
++        _ => &mut *x,
++    };
++
++    *x = 5;
++
++    let s = String::new();
++    let _ = (&s).len();
++    let _ = (&s).capacity();
++    let _ = (&&s).capacity();
++
++    let x = (1, 2);
++    let _ = (&x).0;
++    let x = &x as *const (i32, i32);
++    let _ = unsafe { (&*x).0 };
 +}
 +
 +#[allow(clippy::needless_borrowed_reference)]
 +fn x(y: &i32) -> i32 {
 +    *y
 +}
 +
 +fn mut_ref(y: &mut i32) {
 +    *y = 5;
 +}
 +
 +fn f<T: Copy>(y: &T) -> T {
 +    *y
 +}
 +
 +fn g(y: &[u8]) -> u8 {
 +    y[0]
 +}
 +
 +trait Trait {}
 +
 +impl<'a> Trait for &'a str {}
 +
 +fn h(_: &dyn Trait) {}
index 03a5b3d260e6a984179d5cbece2b9cb666393c77,0000000000000000000000000000000000000000..b90e8448db0a3ac377949addf360f56441a5b401
mode 100644,000000..100644
--- /dev/null
@@@ -1,64 -1,0 +1,118 @@@
- error: this expression borrows a reference (`&i32`) that is immediately dereferenced by the compiler
++error: this expression creates a reference which is immediately dereferenced by the compiler
 +  --> $DIR/needless_borrow.rs:9:15
 +   |
 +LL |     let _ = x(&&a); // warn
 +   |               ^^^ help: change this to: `&a`
 +   |
 +   = note: `-D clippy::needless-borrow` implied by `-D warnings`
 +
- error: this expression borrows a reference (`&mut i32`) that is immediately dereferenced by the compiler
++error: this expression creates a reference which is immediately dereferenced by the compiler
 +  --> $DIR/needless_borrow.rs:13:13
 +   |
 +LL |     mut_ref(&mut &mut b); // warn
 +   |             ^^^^^^^^^^^ help: change this to: `&mut b`
 +
- error: this expression borrows a reference (`&i32`) that is immediately dereferenced by the compiler
++error: this expression creates a reference which is immediately dereferenced by the compiler
 +  --> $DIR/needless_borrow.rs:25:13
 +   |
 +LL |             &&a
 +   |             ^^^ help: change this to: `&a`
 +
- error: this expression borrows a reference (`&i32`) that is immediately dereferenced by the compiler
++error: this expression creates a reference which is immediately dereferenced by the compiler
 +  --> $DIR/needless_borrow.rs:27:15
 +   |
 +LL |         46 => &&a,
 +   |               ^^^ help: change this to: `&a`
 +
- error: this expression borrows a reference (`&i32`) that is immediately dereferenced by the compiler
++error: this expression creates a reference which is immediately dereferenced by the compiler
 +  --> $DIR/needless_borrow.rs:33:27
 +   |
 +LL |                     break &ref_a;
 +   |                           ^^^^^^ help: change this to: `ref_a`
 +
- error: this expression borrows a reference (`&i32`) that is immediately dereferenced by the compiler
++error: this expression creates a reference which is immediately dereferenced by the compiler
 +  --> $DIR/needless_borrow.rs:40:15
 +   |
 +LL |     let _ = x(&&&a);
 +   |               ^^^^ help: change this to: `&a`
 +
- error: this expression borrows a reference (`&i32`) that is immediately dereferenced by the compiler
++error: this expression creates a reference which is immediately dereferenced by the compiler
 +  --> $DIR/needless_borrow.rs:41:15
 +   |
 +LL |     let _ = x(&mut &&a);
 +   |               ^^^^^^^^ help: change this to: `&a`
 +
- error: this expression borrows a reference (`&mut i32`) that is immediately dereferenced by the compiler
++error: this expression creates a reference which is immediately dereferenced by the compiler
 +  --> $DIR/needless_borrow.rs:42:15
 +   |
 +LL |     let _ = x(&&&mut b);
 +   |               ^^^^^^^^ help: change this to: `&mut b`
 +
- error: this expression borrows a reference (`&i32`) that is immediately dereferenced by the compiler
++error: this expression creates a reference which is immediately dereferenced by the compiler
 +  --> $DIR/needless_borrow.rs:43:15
 +   |
 +LL |     let _ = x(&&ref_a);
 +   |               ^^^^^^^ help: change this to: `ref_a`
 +
- error: this expression borrows a reference (`&mut i32`) that is immediately dereferenced by the compiler
++error: this expression creates a reference which is immediately dereferenced by the compiler
 +  --> $DIR/needless_borrow.rs:46:11
 +   |
 +LL |         x(&b);
 +   |           ^^ help: change this to: `b`
 +
- error: aborting due to 10 previous errors
++error: this expression creates a reference which is immediately dereferenced by the compiler
++  --> $DIR/needless_borrow.rs:53:13
++   |
++LL |     mut_ref(&mut x);
++   |             ^^^^^^ help: change this to: `x`
++
++error: this expression creates a reference which is immediately dereferenced by the compiler
++  --> $DIR/needless_borrow.rs:54:13
++   |
++LL |     mut_ref(&mut &mut x);
++   |             ^^^^^^^^^^^ help: change this to: `x`
++
++error: this expression creates a reference which is immediately dereferenced by the compiler
++  --> $DIR/needless_borrow.rs:55:23
++   |
++LL |     let y: &mut i32 = &mut x;
++   |                       ^^^^^^ help: change this to: `x`
++
++error: this expression creates a reference which is immediately dereferenced by the compiler
++  --> $DIR/needless_borrow.rs:56:23
++   |
++LL |     let y: &mut i32 = &mut &mut x;
++   |                       ^^^^^^^^^^^ help: change this to: `x`
++
++error: this expression borrows a value the compiler would automatically borrow
++  --> $DIR/needless_borrow.rs:67:13
++   |
++LL |     let _ = (&s).len();
++   |             ^^^^ help: change this to: `s`
++
++error: this expression borrows a value the compiler would automatically borrow
++  --> $DIR/needless_borrow.rs:68:13
++   |
++LL |     let _ = (&s).capacity();
++   |             ^^^^ help: change this to: `s`
++
++error: this expression creates a reference which is immediately dereferenced by the compiler
++  --> $DIR/needless_borrow.rs:69:13
++   |
++LL |     let _ = (&&s).capacity();
++   |             ^^^^^ help: change this to: `s`
++
++error: this expression borrows a value the compiler would automatically borrow
++  --> $DIR/needless_borrow.rs:72:13
++   |
++LL |     let _ = (&x).0;
++   |             ^^^^ help: change this to: `x`
++
++error: this expression borrows a value the compiler would automatically borrow
++  --> $DIR/needless_borrow.rs:74:22
++   |
++LL |     let _ = unsafe { (&*x).0 };
++   |                      ^^^^^ help: change this to: `(*x)`
++
++error: aborting due to 19 previous errors
 +
index b07c4a2381031f2f4c617c4e355e904c8243f9a6,0000000000000000000000000000000000000000..f3eafe8e9279e2167bb2d7dfe7f94dd5deb3b15a
mode 100644,000000..100644
--- /dev/null
@@@ -1,372 -1,0 +1,421 @@@
- #![allow(dead_code, clippy::needless_pass_by_value, clippy::unnecessary_wraps, dyn_drop)]
 +#![warn(clippy::needless_lifetimes)]
++#![allow(
++    dead_code,
++    clippy::boxed_local,
++    clippy::needless_pass_by_value,
++    clippy::unnecessary_wraps,
++    dyn_drop
++)]
 +
 +fn distinct_lifetimes<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: u8) {}
 +
 +fn distinct_and_static<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: &'static u8) {}
 +
 +// No error; same lifetime on two params.
 +fn same_lifetime_on_input<'a>(_x: &'a u8, _y: &'a u8) {}
 +
 +// No error; static involved.
 +fn only_static_on_input(_x: &u8, _y: &u8, _z: &'static u8) {}
 +
 +fn mut_and_static_input(_x: &mut u8, _y: &'static str) {}
 +
 +fn in_and_out<'a>(x: &'a u8, _y: u8) -> &'a u8 {
 +    x
 +}
 +
 +// No error; multiple input refs.
 +fn multiple_in_and_out_1<'a>(x: &'a u8, _y: &'a u8) -> &'a u8 {
 +    x
 +}
 +
 +// No error; multiple input refs.
 +fn multiple_in_and_out_2<'a, 'b>(x: &'a u8, _y: &'b u8) -> &'a u8 {
 +    x
 +}
 +
 +// No error; multiple input refs
 +async fn func<'a>(args: &[&'a str]) -> Option<&'a str> {
 +    args.get(0).cloned()
 +}
 +
 +// No error; static involved.
 +fn in_static_and_out<'a>(x: &'a u8, _y: &'static u8) -> &'a u8 {
 +    x
 +}
 +
 +// No error.
 +fn deep_reference_1<'a, 'b>(x: &'a u8, _y: &'b u8) -> Result<&'a u8, ()> {
 +    Ok(x)
 +}
 +
 +// No error; two input refs.
 +fn deep_reference_2<'a>(x: Result<&'a u8, &'a u8>) -> &'a u8 {
 +    x.unwrap()
 +}
 +
 +fn deep_reference_3<'a>(x: &'a u8, _y: u8) -> Result<&'a u8, ()> {
 +    Ok(x)
 +}
 +
 +// Where-clause, but without lifetimes.
 +fn where_clause_without_lt<'a, T>(x: &'a u8, _y: u8) -> Result<&'a u8, ()>
 +where
 +    T: Copy,
 +{
 +    Ok(x)
 +}
 +
 +type Ref<'r> = &'r u8;
 +
 +// No error; same lifetime on two params.
 +fn lifetime_param_1<'a>(_x: Ref<'a>, _y: &'a u8) {}
 +
 +fn lifetime_param_2<'a, 'b>(_x: Ref<'a>, _y: &'b u8) {}
 +
 +// No error; bounded lifetime.
 +fn lifetime_param_3<'a, 'b: 'a>(_x: Ref<'a>, _y: &'b u8) {}
 +
 +// No error; bounded lifetime.
 +fn lifetime_param_4<'a, 'b>(_x: Ref<'a>, _y: &'b u8)
 +where
 +    'b: 'a,
 +{
 +}
 +
 +struct Lt<'a, I: 'static> {
 +    x: &'a I,
 +}
 +
 +// No error; fn bound references `'a`.
 +fn fn_bound<'a, F, I>(_m: Lt<'a, I>, _f: F) -> Lt<'a, I>
 +where
 +    F: Fn(Lt<'a, I>) -> Lt<'a, I>,
 +{
 +    unreachable!()
 +}
 +
 +fn fn_bound_2<'a, F, I>(_m: Lt<'a, I>, _f: F) -> Lt<'a, I>
 +where
 +    for<'x> F: Fn(Lt<'x, I>) -> Lt<'x, I>,
 +{
 +    unreachable!()
 +}
 +
 +// No error; see below.
 +fn fn_bound_3<'a, F: FnOnce(&'a i32)>(x: &'a i32, f: F) {
 +    f(x);
 +}
 +
 +fn fn_bound_3_cannot_elide() {
 +    let x = 42;
 +    let p = &x;
 +    let mut q = &x;
 +    // This will fail if we elide lifetimes of `fn_bound_3`.
 +    fn_bound_3(p, |y| q = y);
 +}
 +
 +// No error; multiple input refs.
 +fn fn_bound_4<'a, F: FnOnce() -> &'a ()>(cond: bool, x: &'a (), f: F) -> &'a () {
 +    if cond { x } else { f() }
 +}
 +
 +struct X {
 +    x: u8,
 +}
 +
 +impl X {
 +    fn self_and_out<'s>(&'s self) -> &'s u8 {
 +        &self.x
 +    }
 +
 +    // No error; multiple input refs.
 +    fn self_and_in_out<'s, 't>(&'s self, _x: &'t u8) -> &'s u8 {
 +        &self.x
 +    }
 +
 +    fn distinct_self_and_in<'s, 't>(&'s self, _x: &'t u8) {}
 +
 +    // No error; same lifetimes on two params.
 +    fn self_and_same_in<'s>(&'s self, _x: &'s u8) {}
 +}
 +
 +struct Foo<'a>(&'a u8);
 +
 +impl<'a> Foo<'a> {
 +    // No error; lifetime `'a` not defined in method.
 +    fn self_shared_lifetime(&self, _: &'a u8) {}
 +    // No error; bounds exist.
 +    fn self_bound_lifetime<'b: 'a>(&self, _: &'b u8) {}
 +}
 +
 +fn already_elided<'a>(_: &u8, _: &'a u8) -> &'a u8 {
 +    unimplemented!()
 +}
 +
 +fn struct_with_lt<'a>(_foo: Foo<'a>) -> &'a str {
 +    unimplemented!()
 +}
 +
 +// No warning; two input lifetimes (named on the reference, anonymous on `Foo`).
 +fn struct_with_lt2<'a>(_foo: &'a Foo) -> &'a str {
 +    unimplemented!()
 +}
 +
 +// No warning; two input lifetimes (anonymous on the reference, named on `Foo`).
 +fn struct_with_lt3<'a>(_foo: &Foo<'a>) -> &'a str {
 +    unimplemented!()
 +}
 +
 +// No warning; two input lifetimes.
 +fn struct_with_lt4<'a, 'b>(_foo: &'a Foo<'b>) -> &'a str {
 +    unimplemented!()
 +}
 +
 +trait WithLifetime<'a> {}
 +
 +type WithLifetimeAlias<'a> = dyn WithLifetime<'a>;
 +
 +// Should not warn because it won't build without the lifetime.
 +fn trait_obj_elided<'a>(_arg: &'a dyn WithLifetime) -> &'a str {
 +    unimplemented!()
 +}
 +
 +// Should warn because there is no lifetime on `Drop`, so this would be
 +// unambiguous if we elided the lifetime.
 +fn trait_obj_elided2<'a>(_arg: &'a dyn Drop) -> &'a str {
 +    unimplemented!()
 +}
 +
 +type FooAlias<'a> = Foo<'a>;
 +
 +fn alias_with_lt<'a>(_foo: FooAlias<'a>) -> &'a str {
 +    unimplemented!()
 +}
 +
 +// No warning; two input lifetimes (named on the reference, anonymous on `FooAlias`).
 +fn alias_with_lt2<'a>(_foo: &'a FooAlias) -> &'a str {
 +    unimplemented!()
 +}
 +
 +// No warning; two input lifetimes (anonymous on the reference, named on `FooAlias`).
 +fn alias_with_lt3<'a>(_foo: &FooAlias<'a>) -> &'a str {
 +    unimplemented!()
 +}
 +
 +// No warning; two input lifetimes.
 +fn alias_with_lt4<'a, 'b>(_foo: &'a FooAlias<'b>) -> &'a str {
 +    unimplemented!()
 +}
 +
 +fn named_input_elided_output<'a>(_arg: &'a str) -> &str {
 +    unimplemented!()
 +}
 +
 +fn elided_input_named_output<'a>(_arg: &str) -> &'a str {
 +    unimplemented!()
 +}
 +
 +fn trait_bound_ok<'a, T: WithLifetime<'static>>(_: &'a u8, _: T) {
 +    unimplemented!()
 +}
 +fn trait_bound<'a, T: WithLifetime<'a>>(_: &'a u8, _: T) {
 +    unimplemented!()
 +}
 +
 +// Don't warn on these; see issue #292.
 +fn trait_bound_bug<'a, T: WithLifetime<'a>>() {
 +    unimplemented!()
 +}
 +
 +// See issue #740.
 +struct Test {
 +    vec: Vec<usize>,
 +}
 +
 +impl Test {
 +    fn iter<'a>(&'a self) -> Box<dyn Iterator<Item = usize> + 'a> {
 +        unimplemented!()
 +    }
 +}
 +
 +trait LintContext<'a> {}
 +
 +fn f<'a, T: LintContext<'a>>(_: &T) {}
 +
 +fn test<'a>(x: &'a [u8]) -> u8 {
 +    let y: &'a u8 = &x[5];
 +    *y
 +}
 +
 +// Issue #3284: give hint regarding lifetime in return type.
 +struct Cow<'a> {
 +    x: &'a str,
 +}
 +fn out_return_type_lts<'a>(e: &'a str) -> Cow<'a> {
 +    unimplemented!()
 +}
 +
 +// Make sure we still warn on implementations
 +mod issue4291 {
 +    trait BadTrait {
 +        fn needless_lt<'a>(x: &'a u8) {}
 +    }
 +
 +    impl BadTrait for () {
 +        fn needless_lt<'a>(_x: &'a u8) {}
 +    }
 +}
 +
 +mod issue2944 {
 +    trait Foo {}
 +    struct Bar {}
 +    struct Baz<'a> {
 +        bar: &'a Bar,
 +    }
 +
 +    impl<'a> Foo for Baz<'a> {}
 +    impl Bar {
 +        fn baz<'a>(&'a self) -> impl Foo + 'a {
 +            Baz { bar: self }
 +        }
 +    }
 +}
 +
 +mod nested_elision_sites {
 +    // issue #issue2944
 +
 +    // closure trait bounds subject to nested elision
 +    // don't lint because they refer to outer lifetimes
 +    fn trait_fn<'a>(i: &'a i32) -> impl Fn() -> &'a i32 {
 +        move || i
 +    }
 +    fn trait_fn_mut<'a>(i: &'a i32) -> impl FnMut() -> &'a i32 {
 +        move || i
 +    }
 +    fn trait_fn_once<'a>(i: &'a i32) -> impl FnOnce() -> &'a i32 {
 +        move || i
 +    }
 +
 +    // don't lint
 +    fn impl_trait_in_input_position<'a>(f: impl Fn() -> &'a i32) -> &'a i32 {
 +        f()
 +    }
 +    fn impl_trait_in_output_position<'a>(i: &'a i32) -> impl Fn() -> &'a i32 {
 +        move || i
 +    }
 +    // lint
 +    fn impl_trait_elidable_nested_named_lifetimes<'a>(i: &'a i32, f: impl for<'b> Fn(&'b i32) -> &'b i32) -> &'a i32 {
 +        f(i)
 +    }
 +    fn impl_trait_elidable_nested_anonymous_lifetimes<'a>(i: &'a i32, f: impl Fn(&i32) -> &i32) -> &'a i32 {
 +        f(i)
 +    }
 +
 +    // don't lint
 +    fn generics_not_elidable<'a, T: Fn() -> &'a i32>(f: T) -> &'a i32 {
 +        f()
 +    }
 +    // lint
 +    fn generics_elidable<'a, T: Fn(&i32) -> &i32>(i: &'a i32, f: T) -> &'a i32 {
 +        f(i)
 +    }
 +
 +    // don't lint
 +    fn where_clause_not_elidable<'a, T>(f: T) -> &'a i32
 +    where
 +        T: Fn() -> &'a i32,
 +    {
 +        f()
 +    }
 +    // lint
 +    fn where_clause_elidadable<'a, T>(i: &'a i32, f: T) -> &'a i32
 +    where
 +        T: Fn(&i32) -> &i32,
 +    {
 +        f(i)
 +    }
 +
 +    // don't lint
 +    fn pointer_fn_in_input_position<'a>(f: fn(&'a i32) -> &'a i32, i: &'a i32) -> &'a i32 {
 +        f(i)
 +    }
 +    fn pointer_fn_in_output_position<'a>(_: &'a i32) -> fn(&'a i32) -> &'a i32 {
 +        |i| i
 +    }
 +    // lint
 +    fn pointer_fn_elidable<'a>(i: &'a i32, f: fn(&i32) -> &i32) -> &'a i32 {
 +        f(i)
 +    }
 +
 +    // don't lint
 +    fn nested_fn_pointer_1<'a>(_: &'a i32) -> fn(fn(&'a i32) -> &'a i32) -> i32 {
 +        |f| 42
 +    }
 +    fn nested_fn_pointer_2<'a>(_: &'a i32) -> impl Fn(fn(&'a i32)) {
 +        |f| ()
 +    }
 +
 +    // lint
 +    fn nested_fn_pointer_3<'a>(_: &'a i32) -> fn(fn(&i32) -> &i32) -> i32 {
 +        |f| 42
 +    }
 +    fn nested_fn_pointer_4<'a>(_: &'a i32) -> impl Fn(fn(&i32)) {
 +        |f| ()
 +    }
 +}
 +
 +mod issue6159 {
 +    use std::ops::Deref;
 +    pub fn apply_deref<'a, T, F, R>(x: &'a T, f: F) -> R
 +    where
 +        T: Deref,
 +        F: FnOnce(&'a T::Target) -> R,
 +    {
 +        f(x.deref())
 +    }
 +}
 +
++mod issue7296 {
++    use std::rc::Rc;
++    use std::sync::Arc;
++
++    struct Foo;
++    impl Foo {
++        fn implicit<'a>(&'a self) -> &'a () {
++            &()
++        }
++        fn implicit_mut<'a>(&'a mut self) -> &'a () {
++            &()
++        }
++
++        fn explicit<'a>(self: &'a Arc<Self>) -> &'a () {
++            &()
++        }
++        fn explicit_mut<'a>(self: &'a mut Rc<Self>) -> &'a () {
++            &()
++        }
++
++        fn lifetime_elsewhere<'a>(self: Box<Self>, here: &'a ()) -> &'a () {
++            &()
++        }
++    }
++
++    trait Bar {
++        fn implicit<'a>(&'a self) -> &'a ();
++        fn implicit_provided<'a>(&'a self) -> &'a () {
++            &()
++        }
++
++        fn explicit<'a>(self: &'a Arc<Self>) -> &'a ();
++        fn explicit_provided<'a>(self: &'a Arc<Self>) -> &'a () {
++            &()
++        }
++
++        fn lifetime_elsewhere<'a>(self: Box<Self>, here: &'a ()) -> &'a ();
++        fn lifetime_elsewhere_provided<'a>(self: Box<Self>, here: &'a ()) -> &'a () {
++            &()
++        }
++    }
++}
++
 +fn main() {}
index 4114e6f1832fc694ddbffecd65819900de31df43,0000000000000000000000000000000000000000..ffa152427a97740c108221fccfbfad53096500aa
mode 100644,000000..100644
--- /dev/null
@@@ -1,154 -1,0 +1,196 @@@
-   --> $DIR/needless_lifetimes.rs:4:1
 +error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
-   --> $DIR/needless_lifetimes.rs:6:1
++  --> $DIR/needless_lifetimes.rs:10:1
 +   |
 +LL | fn distinct_lifetimes<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: u8) {}
 +   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 +   |
 +   = note: `-D clippy::needless-lifetimes` implied by `-D warnings`
 +
 +error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
-   --> $DIR/needless_lifetimes.rs:16:1
++  --> $DIR/needless_lifetimes.rs:12:1
 +   |
 +LL | fn distinct_and_static<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: &'static u8) {}
 +   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 +
 +error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
-   --> $DIR/needless_lifetimes.rs:50:1
++  --> $DIR/needless_lifetimes.rs:22:1
 +   |
 +LL | fn in_and_out<'a>(x: &'a u8, _y: u8) -> &'a u8 {
 +   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 +
 +error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
-   --> $DIR/needless_lifetimes.rs:55:1
++  --> $DIR/needless_lifetimes.rs:56:1
 +   |
 +LL | fn deep_reference_3<'a>(x: &'a u8, _y: u8) -> Result<&'a u8, ()> {
 +   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 +
 +error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
-   --> $DIR/needless_lifetimes.rs:67:1
++  --> $DIR/needless_lifetimes.rs:61:1
 +   |
 +LL | fn where_clause_without_lt<'a, T>(x: &'a u8, _y: u8) -> Result<&'a u8, ()>
 +   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 +
 +error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
-   --> $DIR/needless_lifetimes.rs:91:1
++  --> $DIR/needless_lifetimes.rs:73:1
 +   |
 +LL | fn lifetime_param_2<'a, 'b>(_x: Ref<'a>, _y: &'b u8) {}
 +   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 +
 +error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
-   --> $DIR/needless_lifetimes.rs:121:5
++  --> $DIR/needless_lifetimes.rs:97:1
 +   |
 +LL | fn fn_bound_2<'a, F, I>(_m: Lt<'a, I>, _f: F) -> Lt<'a, I>
 +   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 +
 +error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
-   --> $DIR/needless_lifetimes.rs:130:5
++  --> $DIR/needless_lifetimes.rs:127:5
 +   |
 +LL |     fn self_and_out<'s>(&'s self) -> &'s u8 {
 +   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 +
 +error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
-   --> $DIR/needless_lifetimes.rs:149:1
++  --> $DIR/needless_lifetimes.rs:136:5
 +   |
 +LL |     fn distinct_self_and_in<'s, 't>(&'s self, _x: &'t u8) {}
 +   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 +
 +error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
-   --> $DIR/needless_lifetimes.rs:179:1
++  --> $DIR/needless_lifetimes.rs:155:1
 +   |
 +LL | fn struct_with_lt<'a>(_foo: Foo<'a>) -> &'a str {
 +   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 +
 +error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
-   --> $DIR/needless_lifetimes.rs:185:1
++  --> $DIR/needless_lifetimes.rs:185:1
 +   |
 +LL | fn trait_obj_elided2<'a>(_arg: &'a dyn Drop) -> &'a str {
 +   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 +
 +error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
-   --> $DIR/needless_lifetimes.rs:204:1
++  --> $DIR/needless_lifetimes.rs:191:1
 +   |
 +LL | fn alias_with_lt<'a>(_foo: FooAlias<'a>) -> &'a str {
 +   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 +
 +error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
-   --> $DIR/needless_lifetimes.rs:212:1
++  --> $DIR/needless_lifetimes.rs:210:1
 +   |
 +LL | fn named_input_elided_output<'a>(_arg: &'a str) -> &str {
 +   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 +
 +error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
-   --> $DIR/needless_lifetimes.rs:248:1
++  --> $DIR/needless_lifetimes.rs:218:1
 +   |
 +LL | fn trait_bound_ok<'a, T: WithLifetime<'static>>(_: &'a u8, _: T) {
 +   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 +
 +error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
-   --> $DIR/needless_lifetimes.rs:255:9
++  --> $DIR/needless_lifetimes.rs:254:1
 +   |
 +LL | fn out_return_type_lts<'a>(e: &'a str) -> Cow<'a> {
 +   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 +
 +error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
-   --> $DIR/needless_lifetimes.rs:259:9
++  --> $DIR/needless_lifetimes.rs:261:9
 +   |
 +LL |         fn needless_lt<'a>(x: &'a u8) {}
 +   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 +
 +error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
-   --> $DIR/needless_lifetimes.rs:272:9
++  --> $DIR/needless_lifetimes.rs:265:9
 +   |
 +LL |         fn needless_lt<'a>(_x: &'a u8) {}
 +   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 +
 +error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
-   --> $DIR/needless_lifetimes.rs:301:5
++  --> $DIR/needless_lifetimes.rs:278:9
 +   |
 +LL |         fn baz<'a>(&'a self) -> impl Foo + 'a {
 +   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 +
 +error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
-   --> $DIR/needless_lifetimes.rs:304:5
++  --> $DIR/needless_lifetimes.rs:307:5
 +   |
 +LL |     fn impl_trait_elidable_nested_named_lifetimes<'a>(i: &'a i32, f: impl for<'b> Fn(&'b i32) -> &'b i32) -> &'a i32 {
 +   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 +
 +error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
-   --> $DIR/needless_lifetimes.rs:313:5
++  --> $DIR/needless_lifetimes.rs:310:5
 +   |
 +LL |     fn impl_trait_elidable_nested_anonymous_lifetimes<'a>(i: &'a i32, f: impl Fn(&i32) -> &i32) -> &'a i32 {
 +   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 +
 +error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
-   --> $DIR/needless_lifetimes.rs:325:5
++  --> $DIR/needless_lifetimes.rs:319:5
 +   |
 +LL |     fn generics_elidable<'a, T: Fn(&i32) -> &i32>(i: &'a i32, f: T) -> &'a i32 {
 +   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 +
 +error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
-   --> $DIR/needless_lifetimes.rs:340:5
++  --> $DIR/needless_lifetimes.rs:331:5
 +   |
 +LL |     fn where_clause_elidadable<'a, T>(i: &'a i32, f: T) -> &'a i32
 +   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 +
 +error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
-   --> $DIR/needless_lifetimes.rs:353:5
++  --> $DIR/needless_lifetimes.rs:346:5
 +   |
 +LL |     fn pointer_fn_elidable<'a>(i: &'a i32, f: fn(&i32) -> &i32) -> &'a i32 {
 +   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 +
 +error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
-   --> $DIR/needless_lifetimes.rs:356:5
++  --> $DIR/needless_lifetimes.rs:359:5
 +   |
 +LL |     fn nested_fn_pointer_3<'a>(_: &'a i32) -> fn(fn(&i32) -> &i32) -> i32 {
 +   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 +
 +error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
- error: aborting due to 25 previous errors
++  --> $DIR/needless_lifetimes.rs:362:5
 +   |
 +LL |     fn nested_fn_pointer_4<'a>(_: &'a i32) -> impl Fn(fn(&i32)) {
 +   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 +
++error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
++  --> $DIR/needless_lifetimes.rs:384:9
++   |
++LL |         fn implicit<'a>(&'a self) -> &'a () {
++   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
++
++error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
++  --> $DIR/needless_lifetimes.rs:387:9
++   |
++LL |         fn implicit_mut<'a>(&'a mut self) -> &'a () {
++   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
++
++error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
++  --> $DIR/needless_lifetimes.rs:398:9
++   |
++LL |         fn lifetime_elsewhere<'a>(self: Box<Self>, here: &'a ()) -> &'a () {
++   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
++
++error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
++  --> $DIR/needless_lifetimes.rs:404:9
++   |
++LL |         fn implicit<'a>(&'a self) -> &'a ();
++   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
++
++error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
++  --> $DIR/needless_lifetimes.rs:405:9
++   |
++LL |         fn implicit_provided<'a>(&'a self) -> &'a () {
++   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
++
++error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
++  --> $DIR/needless_lifetimes.rs:414:9
++   |
++LL |         fn lifetime_elsewhere<'a>(self: Box<Self>, here: &'a ()) -> &'a ();
++   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
++
++error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
++  --> $DIR/needless_lifetimes.rs:415:9
++   |
++LL |         fn lifetime_elsewhere_provided<'a>(self: Box<Self>, here: &'a ()) -> &'a () {
++   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
++
++error: aborting due to 32 previous errors
 +
index f1fc81aa12b9e7cb6b325f7142a9027602f18483,0000000000000000000000000000000000000000..ba9d15e59d0e45376374c23b07b87c661def3a17
mode 100644,000000..100644
--- /dev/null
@@@ -1,127 -1,0 +1,140 @@@
 +// run-rustfix
 +
 +#![warn(clippy::needless_question_mark)]
 +#![allow(
 +    clippy::needless_return,
 +    clippy::unnecessary_unwrap,
 +    clippy::upper_case_acronyms,
 +    dead_code,
 +    unused_must_use
 +)]
 +#![feature(custom_inner_attributes)]
 +
 +struct TO {
 +    magic: Option<usize>,
 +}
 +
 +struct TR {
 +    magic: Result<usize, bool>,
 +}
 +
 +fn simple_option_bad1(to: TO) -> Option<usize> {
 +    // return as a statement
 +    return to.magic;
 +}
 +
 +// formatting will add a semi-colon, which would make
 +// this identical to the test case above
 +#[rustfmt::skip]
 +fn simple_option_bad2(to: TO) -> Option<usize> {
 +    // return as an expression
 +    return to.magic
 +}
 +
 +fn simple_option_bad3(to: TO) -> Option<usize> {
 +    // block value "return"
 +    to.magic
 +}
 +
 +fn simple_option_bad4(to: Option<TO>) -> Option<usize> {
 +    // single line closure
 +    to.and_then(|t| t.magic)
 +}
 +
 +// formatting this will remove the block brackets, making
 +// this test identical to the one above
 +#[rustfmt::skip]
 +fn simple_option_bad5(to: Option<TO>) -> Option<usize> {
 +    // closure with body
 +    to.and_then(|t| {
 +        t.magic
 +    })
 +}
 +
 +fn simple_result_bad1(tr: TR) -> Result<usize, bool> {
 +    return tr.magic;
 +}
 +
 +// formatting will add a semi-colon, which would make
 +// this identical to the test case above
 +#[rustfmt::skip]
 +fn simple_result_bad2(tr: TR) -> Result<usize, bool> {
 +    return tr.magic
 +}
 +
 +fn simple_result_bad3(tr: TR) -> Result<usize, bool> {
 +    tr.magic
 +}
 +
 +fn simple_result_bad4(tr: Result<TR, bool>) -> Result<usize, bool> {
 +    tr.and_then(|t| t.magic)
 +}
 +
 +// formatting this will remove the block brackets, making
 +// this test identical to the one above
 +#[rustfmt::skip]
 +fn simple_result_bad5(tr: Result<TR, bool>) -> Result<usize, bool> {
 +    tr.and_then(|t| {
 +        t.magic
 +    })
 +}
 +
 +fn also_bad(tr: Result<TR, bool>) -> Result<usize, bool> {
 +    if tr.is_ok() {
 +        let t = tr.unwrap();
 +        return t.magic;
 +    }
 +    Err(false)
 +}
 +
 +fn false_positive_test<U, T>(x: Result<(), U>) -> Result<(), T>
 +where
 +    T: From<U>,
 +{
 +    Ok(x?)
 +}
 +
 +// not quite needless
 +fn deref_ref(s: Option<&String>) -> Option<&str> {
 +    Some(s?)
 +}
 +
 +fn main() {}
 +
 +// #6921 if a macro wraps an expr in Some(  ) and the ? is in the macro use,
 +// the suggestion fails to apply; do not lint
 +macro_rules! some_in_macro {
 +    ($expr:expr) => {
 +        || -> _ { Some($expr) }()
 +    };
 +}
 +
 +pub fn test1() {
 +    let x = Some(3);
 +    let _x = some_in_macro!(x?);
 +}
 +
 +// this one is ok because both the ? and the Some are both inside the macro def
 +macro_rules! some_and_qmark_in_macro {
 +    ($expr:expr) => {
 +        || -> Option<_> { Some($expr) }()
 +    };
 +}
 +
 +pub fn test2() {
 +    let x = Some(3);
 +    let _x = some_and_qmark_in_macro!(x?);
 +}
++
++async fn async_option_bad(to: TO) -> Option<usize> {
++    let _ = Some(3);
++    to.magic
++}
++
++async fn async_deref_ref(s: Option<&String>) -> Option<&str> {
++    Some(s?)
++}
++
++async fn async_result_bad(s: TR) -> Result<usize, bool> {
++    s.magic
++}
index 44a0c5f61b5d5f71c9d6d7ebdc3eea35bb423572,0000000000000000000000000000000000000000..3a6523e8fe872a94b172c851d1c997f9a1ed9350
mode 100644,000000..100644
--- /dev/null
@@@ -1,127 -1,0 +1,140 @@@
 +// run-rustfix
 +
 +#![warn(clippy::needless_question_mark)]
 +#![allow(
 +    clippy::needless_return,
 +    clippy::unnecessary_unwrap,
 +    clippy::upper_case_acronyms,
 +    dead_code,
 +    unused_must_use
 +)]
 +#![feature(custom_inner_attributes)]
 +
 +struct TO {
 +    magic: Option<usize>,
 +}
 +
 +struct TR {
 +    magic: Result<usize, bool>,
 +}
 +
 +fn simple_option_bad1(to: TO) -> Option<usize> {
 +    // return as a statement
 +    return Some(to.magic?);
 +}
 +
 +// formatting will add a semi-colon, which would make
 +// this identical to the test case above
 +#[rustfmt::skip]
 +fn simple_option_bad2(to: TO) -> Option<usize> {
 +    // return as an expression
 +    return Some(to.magic?)
 +}
 +
 +fn simple_option_bad3(to: TO) -> Option<usize> {
 +    // block value "return"
 +    Some(to.magic?)
 +}
 +
 +fn simple_option_bad4(to: Option<TO>) -> Option<usize> {
 +    // single line closure
 +    to.and_then(|t| Some(t.magic?))
 +}
 +
 +// formatting this will remove the block brackets, making
 +// this test identical to the one above
 +#[rustfmt::skip]
 +fn simple_option_bad5(to: Option<TO>) -> Option<usize> {
 +    // closure with body
 +    to.and_then(|t| {
 +        Some(t.magic?)
 +    })
 +}
 +
 +fn simple_result_bad1(tr: TR) -> Result<usize, bool> {
 +    return Ok(tr.magic?);
 +}
 +
 +// formatting will add a semi-colon, which would make
 +// this identical to the test case above
 +#[rustfmt::skip]
 +fn simple_result_bad2(tr: TR) -> Result<usize, bool> {
 +    return Ok(tr.magic?)
 +}
 +
 +fn simple_result_bad3(tr: TR) -> Result<usize, bool> {
 +    Ok(tr.magic?)
 +}
 +
 +fn simple_result_bad4(tr: Result<TR, bool>) -> Result<usize, bool> {
 +    tr.and_then(|t| Ok(t.magic?))
 +}
 +
 +// formatting this will remove the block brackets, making
 +// this test identical to the one above
 +#[rustfmt::skip]
 +fn simple_result_bad5(tr: Result<TR, bool>) -> Result<usize, bool> {
 +    tr.and_then(|t| {
 +        Ok(t.magic?)
 +    })
 +}
 +
 +fn also_bad(tr: Result<TR, bool>) -> Result<usize, bool> {
 +    if tr.is_ok() {
 +        let t = tr.unwrap();
 +        return Ok(t.magic?);
 +    }
 +    Err(false)
 +}
 +
 +fn false_positive_test<U, T>(x: Result<(), U>) -> Result<(), T>
 +where
 +    T: From<U>,
 +{
 +    Ok(x?)
 +}
 +
 +// not quite needless
 +fn deref_ref(s: Option<&String>) -> Option<&str> {
 +    Some(s?)
 +}
 +
 +fn main() {}
 +
 +// #6921 if a macro wraps an expr in Some(  ) and the ? is in the macro use,
 +// the suggestion fails to apply; do not lint
 +macro_rules! some_in_macro {
 +    ($expr:expr) => {
 +        || -> _ { Some($expr) }()
 +    };
 +}
 +
 +pub fn test1() {
 +    let x = Some(3);
 +    let _x = some_in_macro!(x?);
 +}
 +
 +// this one is ok because both the ? and the Some are both inside the macro def
 +macro_rules! some_and_qmark_in_macro {
 +    ($expr:expr) => {
 +        || -> Option<_> { Some(Some($expr)?) }()
 +    };
 +}
 +
 +pub fn test2() {
 +    let x = Some(3);
 +    let _x = some_and_qmark_in_macro!(x?);
 +}
++
++async fn async_option_bad(to: TO) -> Option<usize> {
++    let _ = Some(3);
++    Some(to.magic?)
++}
++
++async fn async_deref_ref(s: Option<&String>) -> Option<&str> {
++    Some(s?)
++}
++
++async fn async_result_bad(s: TR) -> Result<usize, bool> {
++    Ok(s.magic?)
++}
index 57c3d48c7611c2b1cad980070081cce9bb574aa2,0000000000000000000000000000000000000000..f8308e24e7712e62adbf9b248757a3c9b0b32abb
mode 100644,000000..100644
--- /dev/null
@@@ -1,81 -1,0 +1,93 @@@
- error: aborting due to 12 previous errors
 +error: question mark operator is useless here
 +  --> $DIR/needless_question_mark.rs:23:12
 +   |
 +LL |     return Some(to.magic?);
 +   |            ^^^^^^^^^^^^^^^ help: try removing question mark and `Some()`: `to.magic`
 +   |
 +   = note: `-D clippy::needless-question-mark` implied by `-D warnings`
 +
 +error: question mark operator is useless here
 +  --> $DIR/needless_question_mark.rs:31:12
 +   |
 +LL |     return Some(to.magic?)
 +   |            ^^^^^^^^^^^^^^^ help: try removing question mark and `Some()`: `to.magic`
 +
 +error: question mark operator is useless here
 +  --> $DIR/needless_question_mark.rs:36:5
 +   |
 +LL |     Some(to.magic?)
 +   |     ^^^^^^^^^^^^^^^ help: try removing question mark and `Some()`: `to.magic`
 +
 +error: question mark operator is useless here
 +  --> $DIR/needless_question_mark.rs:41:21
 +   |
 +LL |     to.and_then(|t| Some(t.magic?))
 +   |                     ^^^^^^^^^^^^^^ help: try removing question mark and `Some()`: `t.magic`
 +
 +error: question mark operator is useless here
 +  --> $DIR/needless_question_mark.rs:50:9
 +   |
 +LL |         Some(t.magic?)
 +   |         ^^^^^^^^^^^^^^ help: try removing question mark and `Some()`: `t.magic`
 +
 +error: question mark operator is useless here
 +  --> $DIR/needless_question_mark.rs:55:12
 +   |
 +LL |     return Ok(tr.magic?);
 +   |            ^^^^^^^^^^^^^ help: try removing question mark and `Ok()`: `tr.magic`
 +
 +error: question mark operator is useless here
 +  --> $DIR/needless_question_mark.rs:62:12
 +   |
 +LL |     return Ok(tr.magic?)
 +   |            ^^^^^^^^^^^^^ help: try removing question mark and `Ok()`: `tr.magic`
 +
 +error: question mark operator is useless here
 +  --> $DIR/needless_question_mark.rs:66:5
 +   |
 +LL |     Ok(tr.magic?)
 +   |     ^^^^^^^^^^^^^ help: try removing question mark and `Ok()`: `tr.magic`
 +
 +error: question mark operator is useless here
 +  --> $DIR/needless_question_mark.rs:70:21
 +   |
 +LL |     tr.and_then(|t| Ok(t.magic?))
 +   |                     ^^^^^^^^^^^^ help: try removing question mark and `Ok()`: `t.magic`
 +
 +error: question mark operator is useless here
 +  --> $DIR/needless_question_mark.rs:78:9
 +   |
 +LL |         Ok(t.magic?)
 +   |         ^^^^^^^^^^^^ help: try removing question mark and `Ok()`: `t.magic`
 +
 +error: question mark operator is useless here
 +  --> $DIR/needless_question_mark.rs:85:16
 +   |
 +LL |         return Ok(t.magic?);
 +   |                ^^^^^^^^^^^^ help: try removing question mark and `Ok()`: `t.magic`
 +
 +error: question mark operator is useless here
 +  --> $DIR/needless_question_mark.rs:120:27
 +   |
 +LL |         || -> Option<_> { Some(Some($expr)?) }()
 +   |                           ^^^^^^^^^^^^^^^^^^ help: try removing question mark and `Some()`: `Some($expr)`
 +...
 +LL |     let _x = some_and_qmark_in_macro!(x?);
 +   |              ---------------------------- in this macro invocation
 +   |
 +   = note: this error originates in the macro `some_and_qmark_in_macro` (in Nightly builds, run with -Z macro-backtrace for more info)
 +
++error: question mark operator is useless here
++  --> $DIR/needless_question_mark.rs:131:5
++   |
++LL |     Some(to.magic?)
++   |     ^^^^^^^^^^^^^^^ help: try removing question mark and `Some()`: `to.magic`
++
++error: question mark operator is useless here
++  --> $DIR/needless_question_mark.rs:139:5
++   |
++LL |     Ok(s.magic?)
++   |     ^^^^^^^^^^^^ help: try removing question mark and `Ok()`: `s.magic`
++
++error: aborting due to 14 previous errors
 +
index ab9c4d34c88f6200faf8db7ed94946b7d9b724f0,0000000000000000000000000000000000000000..d8bf66603d9f5840f4878552bf4b34f4d62c5379
mode 100644,000000..100644
--- /dev/null
@@@ -1,57 -1,0 +1,94 @@@
- use std::ops::BitAnd;
 +#![allow(unused_variables, clippy::blacklisted_name)]
 +#![warn(clippy::op_ref)]
 +use std::collections::HashSet;
++use std::ops::{BitAnd, Mul};
 +
 +fn main() {
 +    let tracked_fds: HashSet<i32> = HashSet::new();
 +    let new_fds = HashSet::new();
 +    let unwanted = &tracked_fds - &new_fds;
 +
 +    let foo = &5 - &6;
 +
 +    let bar = String::new();
 +    let bar = "foo" == &bar;
 +
 +    let a = "a".to_string();
 +    let b = "a";
 +
 +    if b < &a {
 +        println!("OK");
 +    }
 +
 +    struct X(i32);
 +    impl BitAnd for X {
 +        type Output = X;
 +        fn bitand(self, rhs: X) -> X {
 +            X(self.0 & rhs.0)
 +        }
 +    }
 +    impl<'a> BitAnd<&'a X> for X {
 +        type Output = X;
 +        fn bitand(self, rhs: &'a X) -> X {
 +            X(self.0 & rhs.0)
 +        }
 +    }
 +    let x = X(1);
 +    let y = X(2);
 +    let z = x & &y;
 +
 +    #[derive(Copy, Clone)]
 +    struct Y(i32);
 +    impl BitAnd for Y {
 +        type Output = Y;
 +        fn bitand(self, rhs: Y) -> Y {
 +            Y(self.0 & rhs.0)
 +        }
 +    }
 +    impl<'a> BitAnd<&'a Y> for Y {
 +        type Output = Y;
 +        fn bitand(self, rhs: &'a Y) -> Y {
 +            Y(self.0 & rhs.0)
 +        }
 +    }
 +    let x = Y(1);
 +    let y = Y(2);
 +    let z = x & &y;
 +}
++
++#[derive(Clone, Copy)]
++struct A(i32);
++#[derive(Clone, Copy)]
++struct B(i32);
++
++impl Mul<&A> for B {
++    type Output = i32;
++    fn mul(self, rhs: &A) -> Self::Output {
++        self.0 * rhs.0
++    }
++}
++impl Mul<A> for B {
++    type Output = i32;
++    fn mul(self, rhs: A) -> Self::Output {
++        // Should not lint because removing the reference would lead to unconditional recursion
++        self * &rhs
++    }
++}
++impl Mul<&A> for A {
++    type Output = i32;
++    fn mul(self, rhs: &A) -> Self::Output {
++        self.0 * rhs.0
++    }
++}
++impl Mul<A> for A {
++    type Output = i32;
++    fn mul(self, rhs: A) -> Self::Output {
++        let one = B(1);
++        let two = 2;
++        let three = 3;
++        let _ = one * &self;
++        let _ = two + &three;
++        // Removing the reference would lead to unconditional recursion
++        self * &rhs
++    }
++}
index 992417084bda29499222b3036bcb8a8ca86dd029,0000000000000000000000000000000000000000..fe36c01166ff714c959a9abcdae7f7a1ec6ed51d
mode 100644,000000..100644
--- /dev/null
@@@ -1,22 -1,0 +1,38 @@@
- error: aborting due to 2 previous errors
 +error: needlessly taken reference of both operands
 +  --> $DIR/op_ref.rs:11:15
 +   |
 +LL |     let foo = &5 - &6;
 +   |               ^^^^^^^
 +   |
 +   = note: `-D clippy::op-ref` implied by `-D warnings`
 +help: use the values directly
 +   |
 +LL |     let foo = 5 - 6;
 +   |               ~   ~
 +
 +error: taken reference of right operand
 +  --> $DIR/op_ref.rs:56:13
 +   |
 +LL |     let z = x & &y;
 +   |             ^^^^--
 +   |                 |
 +   |                 help: use the right value directly: `y`
 +
++error: taken reference of right operand
++  --> $DIR/op_ref.rs:89:17
++   |
++LL |         let _ = one * &self;
++   |                 ^^^^^^-----
++   |                       |
++   |                       help: use the right value directly: `self`
++
++error: taken reference of right operand
++  --> $DIR/op_ref.rs:90:17
++   |
++LL |         let _ = two + &three;
++   |                 ^^^^^^------
++   |                       |
++   |                       help: use the right value directly: `three`
++
++error: aborting due to 4 previous errors
 +
index 67bfef06a05e8cdd3e7b73c19fbc629d5e6fbf3e,0000000000000000000000000000000000000000..ed72423780821792ae61ea24d6fb322547465e16
mode 100644,000000..100644
--- /dev/null
@@@ -1,161 -1,0 +1,182 @@@
-     // no error here
 +#![allow(unused, clippy::many_single_char_names, clippy::redundant_clone)]
 +#![warn(clippy::ptr_arg)]
 +
 +use std::borrow::Cow;
 +use std::path::PathBuf;
 +
 +fn do_vec(x: &Vec<i64>) {
 +    //Nothing here
 +}
 +
 +fn do_vec_mut(x: &mut Vec<i64>) {
-     // no error here
 +    //Nothing here
 +}
 +
 +fn do_str(x: &String) {
 +    //Nothing here either
 +}
 +
 +fn do_str_mut(x: &mut String) {
-     // no error here
 +    //Nothing here either
 +}
 +
 +fn do_path(x: &PathBuf) {
 +    //Nothing here either
 +}
 +
 +fn do_path_mut(x: &mut PathBuf) {
-     let h = g.clone(); // Alas, we cannot reliably detect this without following data.
 +    //Nothing here either
 +}
 +
 +fn main() {}
 +
 +trait Foo {
 +    type Item;
 +    fn do_vec(x: &Vec<i64>);
 +    fn do_item(x: &Self::Item);
 +}
 +
 +struct Bar;
 +
 +// no error, in trait impl (#425)
 +impl Foo for Bar {
 +    type Item = Vec<u8>;
 +    fn do_vec(x: &Vec<i64>) {}
 +    fn do_item(x: &Vec<u8>) {}
 +}
 +
 +fn cloned(x: &Vec<u8>) -> Vec<u8> {
 +    let e = x.clone();
 +    let f = e.clone(); // OK
 +    let g = x;
++    let h = g.clone();
 +    let i = (e).clone();
 +    x.clone()
 +}
 +
 +fn str_cloned(x: &String) -> String {
 +    let a = x.clone();
 +    let b = x.clone();
 +    let c = b.clone();
 +    let d = a.clone().clone().clone();
 +    x.clone()
 +}
 +
 +fn path_cloned(x: &PathBuf) -> PathBuf {
 +    let a = x.clone();
 +    let b = x.clone();
 +    let c = b.clone();
 +    let d = a.clone().clone().clone();
 +    x.clone()
 +}
 +
 +fn false_positive_capacity(x: &Vec<u8>, y: &String) {
 +    let a = x.capacity();
 +    let b = y.clone();
 +    let c = y.as_str();
 +}
 +
 +fn false_positive_capacity_too(x: &String) -> String {
 +    if x.capacity() > 1024 {
 +        panic!("Too large!");
 +    }
 +    x.clone()
 +}
 +
 +#[allow(dead_code)]
 +fn test_cow_with_ref(c: &Cow<[i32]>) {}
 +
 +fn test_cow(c: Cow<[i32]>) {
 +    let _c = c;
 +}
 +
 +trait Foo2 {
 +    fn do_string(&self);
 +}
 +
 +// no error for &self references where self is of type String (#2293)
 +impl Foo2 for String {
 +    fn do_string(&self) {}
 +}
 +
 +// Check that the allow attribute on parameters is honored
 +mod issue_5644 {
 +    use std::borrow::Cow;
 +    use std::path::PathBuf;
 +
 +    fn allowed(
 +        #[allow(clippy::ptr_arg)] _v: &Vec<u32>,
 +        #[allow(clippy::ptr_arg)] _s: &String,
 +        #[allow(clippy::ptr_arg)] _p: &PathBuf,
 +        #[allow(clippy::ptr_arg)] _c: &Cow<[i32]>,
 +    ) {
 +    }
 +
 +    struct S {}
 +    impl S {
 +        fn allowed(
 +            #[allow(clippy::ptr_arg)] _v: &Vec<u32>,
 +            #[allow(clippy::ptr_arg)] _s: &String,
 +            #[allow(clippy::ptr_arg)] _p: &PathBuf,
 +            #[allow(clippy::ptr_arg)] _c: &Cow<[i32]>,
 +        ) {
 +        }
 +    }
 +
 +    trait T {
 +        fn allowed(
 +            #[allow(clippy::ptr_arg)] _v: &Vec<u32>,
 +            #[allow(clippy::ptr_arg)] _s: &String,
 +            #[allow(clippy::ptr_arg)] _p: &PathBuf,
 +            #[allow(clippy::ptr_arg)] _c: &Cow<[i32]>,
 +        ) {
 +        }
 +    }
 +}
 +
 +mod issue6509 {
 +    use std::path::PathBuf;
 +
 +    fn foo_vec(vec: &Vec<u8>) {
 +        let _ = vec.clone().pop();
 +        let _ = vec.clone().clone();
 +    }
 +
 +    fn foo_path(path: &PathBuf) {
 +        let _ = path.clone().pop();
 +        let _ = path.clone().clone();
 +    }
 +
 +    fn foo_str(str: &PathBuf) {
 +        let _ = str.clone().pop();
 +        let _ = str.clone().clone();
 +    }
 +}
 +
++fn mut_vec_slice_methods(v: &mut Vec<u32>) {
++    v.copy_within(1..5, 10);
++}
++
++fn mut_vec_vec_methods(v: &mut Vec<u32>) {
++    v.clear();
++}
++
++fn vec_contains(v: &Vec<u32>) -> bool {
++    [vec![], vec![0]].as_slice().contains(v)
++}
++
++fn fn_requires_vec(v: &Vec<u32>) -> bool {
++    vec_contains(v)
++}
++
++fn impl_fn_requires_vec(v: &Vec<u32>, f: impl Fn(&Vec<u32>)) {
++    f(v);
++}
++
++fn dyn_fn_requires_vec(v: &Vec<u32>, f: &dyn Fn(&Vec<u32>)) {
++    f(v);
++}
++
 +// No error for types behind an alias (#7699)
 +type A = Vec<u8>;
 +fn aliased(a: &A) {}
index 64594eb870c2c5067b413095f6eabdeded968ebc,0000000000000000000000000000000000000000..a9613daadde1023cd3953ff27dd9fdbbf4a0a4b0
mode 100644,000000..100644
--- /dev/null
@@@ -1,175 -1,0 +1,159 @@@
- error: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices
++error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
 +  --> $DIR/ptr_arg.rs:7:14
 +   |
 +LL | fn do_vec(x: &Vec<i64>) {
 +   |              ^^^^^^^^^ help: change this to: `&[i64]`
 +   |
 +   = note: `-D clippy::ptr-arg` implied by `-D warnings`
 +
++error: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do
++  --> $DIR/ptr_arg.rs:11:18
++   |
++LL | fn do_vec_mut(x: &mut Vec<i64>) {
++   |                  ^^^^^^^^^^^^^ help: change this to: `&mut [i64]`
++
 +error: writing `&String` instead of `&str` involves a new object where a slice will do
-   --> $DIR/ptr_arg.rs:16:14
++  --> $DIR/ptr_arg.rs:15:14
 +   |
 +LL | fn do_str(x: &String) {
 +   |              ^^^^^^^ help: change this to: `&str`
 +
++error: writing `&mut String` instead of `&mut str` involves a new object where a slice will do
++  --> $DIR/ptr_arg.rs:19:18
++   |
++LL | fn do_str_mut(x: &mut String) {
++   |                  ^^^^^^^^^^^ help: change this to: `&mut str`
++
 +error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do
-   --> $DIR/ptr_arg.rs:25:15
++  --> $DIR/ptr_arg.rs:23:15
 +   |
 +LL | fn do_path(x: &PathBuf) {
 +   |               ^^^^^^^^ help: change this to: `&Path`
 +
- error: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices
-   --> $DIR/ptr_arg.rs:38:18
++error: writing `&mut PathBuf` instead of `&mut Path` involves a new object where a slice will do
++  --> $DIR/ptr_arg.rs:27:19
++   |
++LL | fn do_path_mut(x: &mut PathBuf) {
++   |                   ^^^^^^^^^^^^ help: change this to: `&mut Path`
++
++error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
++  --> $DIR/ptr_arg.rs:35:18
 +   |
 +LL |     fn do_vec(x: &Vec<i64>);
 +   |                  ^^^^^^^^^ help: change this to: `&[i64]`
 +
- error: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices
-   --> $DIR/ptr_arg.rs:51:14
++error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
++  --> $DIR/ptr_arg.rs:48:14
 +   |
 +LL | fn cloned(x: &Vec<u8>) -> Vec<u8> {
 +   |              ^^^^^^^^
 +   |
 +help: change this to
 +   |
- LL | fn cloned(x: &[u8]) -> Vec<u8> {
-    |              ~~~~~
- help: change `x.clone()` to
-    |
- LL |     let e = x.to_owned();
-    |             ~~~~~~~~~~~~
- help: change `x.clone()` to
-    |
- LL |     x.to_owned()
-    |
++LL ~ fn cloned(x: &[u8]) -> Vec<u8> {
++LL ~     let e = x.to_owned();
++LL |     let f = e.clone(); // OK
++LL |     let g = x;
++LL ~     let h = g.to_owned();
++LL |     let i = (e).clone();
++ ...
 +
 +error: writing `&String` instead of `&str` involves a new object where a slice will do
-   --> $DIR/ptr_arg.rs:60:18
++  --> $DIR/ptr_arg.rs:57:18
 +   |
 +LL | fn str_cloned(x: &String) -> String {
 +   |                  ^^^^^^^
 +   |
 +help: change this to
 +   |
- LL | fn str_cloned(x: &str) -> String {
-    |                  ~~~~
- help: change `x.clone()` to
-    |
- LL |     let a = x.to_string();
-    |             ~~~~~~~~~~~~~
- help: change `x.clone()` to
-    |
- LL |     let b = x.to_string();
-    |             ~~~~~~~~~~~~~
- help: change `x.clone()` to
-    |
- LL |     x.to_string()
++LL ~ fn str_cloned(x: &str) -> String {
++LL ~     let a = x.to_owned();
++LL ~     let b = x.to_owned();
++LL |     let c = b.clone();
++LL |     let d = a.clone().clone().clone();
++LL ~     x.to_owned()
 +   |
 +
 +error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do
-   --> $DIR/ptr_arg.rs:68:19
++  --> $DIR/ptr_arg.rs:65:19
 +   |
 +LL | fn path_cloned(x: &PathBuf) -> PathBuf {
 +   |                   ^^^^^^^^
 +   |
 +help: change this to
 +   |
- LL | fn path_cloned(x: &Path) -> PathBuf {
-    |                   ~~~~~
- help: change `x.clone()` to
-    |
- LL |     let a = x.to_path_buf();
-    |             ~~~~~~~~~~~~~~~
- help: change `x.clone()` to
-    |
- LL |     let b = x.to_path_buf();
-    |             ~~~~~~~~~~~~~~~
- help: change `x.clone()` to
-    |
- LL |     x.to_path_buf()
++LL ~ fn path_cloned(x: &Path) -> PathBuf {
++LL ~     let a = x.to_path_buf();
++LL ~     let b = x.to_path_buf();
++LL |     let c = b.clone();
++LL |     let d = a.clone().clone().clone();
++LL ~     x.to_path_buf()
 +   |
 +
 +error: writing `&String` instead of `&str` involves a new object where a slice will do
-   --> $DIR/ptr_arg.rs:76:44
++  --> $DIR/ptr_arg.rs:73:44
 +   |
 +LL | fn false_positive_capacity(x: &Vec<u8>, y: &String) {
 +   |                                            ^^^^^^^
 +   |
 +help: change this to
 +   |
- LL | fn false_positive_capacity(x: &Vec<u8>, y: &str) {
-    |                                            ~~~~
- help: change `y.clone()` to
++LL ~ fn false_positive_capacity(x: &Vec<u8>, y: &str) {
++LL |     let a = x.capacity();
++LL ~     let b = y.to_owned();
++LL ~     let c = y;
 +   |
- LL |     let b = y.to_string();
-    |             ~~~~~~~~~~~~~
- help: change `y.as_str()` to
-    |
- LL |     let c = y;
-    |             ~
 +
 +error: using a reference to `Cow` is not recommended
-   --> $DIR/ptr_arg.rs:90:25
++  --> $DIR/ptr_arg.rs:87:25
 +   |
 +LL | fn test_cow_with_ref(c: &Cow<[i32]>) {}
 +   |                         ^^^^^^^^^^^ help: change this to: `&[i32]`
 +
- error: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices
-   --> $DIR/ptr_arg.rs:143:21
++error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
++  --> $DIR/ptr_arg.rs:140:21
 +   |
 +LL |     fn foo_vec(vec: &Vec<u8>) {
 +   |                     ^^^^^^^^
 +   |
 +help: change this to
 +   |
- LL |     fn foo_vec(vec: &[u8]) {
-    |                     ~~~~~
- help: change `vec.clone()` to
-    |
- LL |         let _ = vec.to_owned().pop();
-    |                 ~~~~~~~~~~~~~~
- help: change `vec.clone()` to
++LL ~     fn foo_vec(vec: &[u8]) {
++LL ~         let _ = vec.to_owned().pop();
++LL ~         let _ = vec.to_owned().clone();
 +   |
- LL |         let _ = vec.to_owned().clone();
-    |                 ~~~~~~~~~~~~~~
 +
 +error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do
-   --> $DIR/ptr_arg.rs:148:23
++  --> $DIR/ptr_arg.rs:145:23
 +   |
 +LL |     fn foo_path(path: &PathBuf) {
 +   |                       ^^^^^^^^
 +   |
 +help: change this to
 +   |
- LL |     fn foo_path(path: &Path) {
-    |                       ~~~~~
- help: change `path.clone()` to
++LL ~     fn foo_path(path: &Path) {
++LL ~         let _ = path.to_path_buf().pop();
++LL ~         let _ = path.to_path_buf().clone();
 +   |
- LL |         let _ = path.to_path_buf().pop();
-    |                 ~~~~~~~~~~~~~~~~~~
- help: change `path.clone()` to
-    |
- LL |         let _ = path.to_path_buf().clone();
-    |                 ~~~~~~~~~~~~~~~~~~
 +
 +error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do
-   --> $DIR/ptr_arg.rs:153:21
++  --> $DIR/ptr_arg.rs:150:21
 +   |
 +LL |     fn foo_str(str: &PathBuf) {
 +   |                     ^^^^^^^^
 +   |
 +help: change this to
 +   |
- LL |     fn foo_str(str: &Path) {
-    |                     ~~~~~
- help: change `str.clone()` to
++LL ~     fn foo_str(str: &Path) {
++LL ~         let _ = str.to_path_buf().pop();
++LL ~         let _ = str.to_path_buf().clone();
 +   |
- LL |         let _ = str.to_path_buf().pop();
-    |                 ~~~~~~~~~~~~~~~~~
- help: change `str.clone()` to
++
++error: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do
++  --> $DIR/ptr_arg.rs:156:29
 +   |
- LL |         let _ = str.to_path_buf().clone();
-    |                 ~~~~~~~~~~~~~~~~~
++LL | fn mut_vec_slice_methods(v: &mut Vec<u32>) {
++   |                             ^^^^^^^^^^^^^ help: change this to: `&mut [u32]`
 +
- error: aborting due to 12 previous errors
++error: aborting due to 16 previous errors
 +
index cc93859269c228c990bb7707bf711f6f0461572f,0000000000000000000000000000000000000000..a89845c1dd32b900c544ab169f6b91cc70640e74
mode 100644,000000..100644
--- /dev/null
@@@ -1,88 -1,0 +1,88 @@@
- #[allow(clippy::deref_addrof, dead_code)]
 +// run-rustfix
 +
 +#![warn(clippy::all)]
 +#![warn(clippy::redundant_pattern_matching)]
 +#![allow(
 +    unused_must_use,
 +    clippy::needless_bool,
 +    clippy::match_like_matches_macro,
 +    clippy::equatable_if_let,
 +    clippy::if_same_then_else
 +)]
 +
 +fn main() {
 +    if None::<()>.is_none() {}
 +
 +    if Some(42).is_some() {}
 +
 +    if Some(42).is_some() {
 +        foo();
 +    } else {
 +        bar();
 +    }
 +
 +    while Some(42).is_some() {}
 +
 +    while Some(42).is_none() {}
 +
 +    while None::<()>.is_none() {}
 +
 +    let mut v = vec![1, 2, 3];
 +    while v.pop().is_some() {
 +        foo();
 +    }
 +
 +    if None::<i32>.is_none() {}
 +
 +    if Some(42).is_some() {}
 +
 +    Some(42).is_some();
 +
 +    None::<()>.is_none();
 +
 +    let _ = None::<()>.is_none();
 +
 +    let opt = Some(false);
 +    let _ = if opt.is_some() { true } else { false };
 +
 +    issue6067();
 +
 +    let _ = if gen_opt().is_some() {
 +        1
 +    } else if gen_opt().is_none() {
 +        2
 +    } else {
 +        3
 +    };
 +}
 +
 +fn gen_opt() -> Option<()> {
 +    None
 +}
 +
 +fn foo() {}
 +
 +fn bar() {}
 +
 +// Methods that are unstable const should not be suggested within a const context, see issue #5697.
 +// However, in Rust 1.48.0 the methods `is_some` and `is_none` of `Option` were stabilized as const,
 +// so the following should be linted.
 +const fn issue6067() {
 +    if Some(42).is_some() {}
 +
 +    if None::<()>.is_none() {}
 +
 +    while Some(42).is_some() {}
 +
 +    while None::<()>.is_none() {}
 +
 +    Some(42).is_some();
 +
 +    None::<()>.is_none();
 +}
 +
++#[allow(clippy::deref_addrof, dead_code, clippy::needless_borrow)]
 +fn issue7921() {
 +    if (&None::<()>).is_none() {}
 +    if (&None::<()>).is_none() {}
 +}
index 280dca40c011d18bda8fa4b18e32bb7c0ede0f6b,0000000000000000000000000000000000000000..d6f44403487efda300ab4b27ed7f7d0b62b6e798
mode 100644,000000..100644
--- /dev/null
@@@ -1,103 -1,0 +1,103 @@@
- #[allow(clippy::deref_addrof, dead_code)]
 +// run-rustfix
 +
 +#![warn(clippy::all)]
 +#![warn(clippy::redundant_pattern_matching)]
 +#![allow(
 +    unused_must_use,
 +    clippy::needless_bool,
 +    clippy::match_like_matches_macro,
 +    clippy::equatable_if_let,
 +    clippy::if_same_then_else
 +)]
 +
 +fn main() {
 +    if let None = None::<()> {}
 +
 +    if let Some(_) = Some(42) {}
 +
 +    if let Some(_) = Some(42) {
 +        foo();
 +    } else {
 +        bar();
 +    }
 +
 +    while let Some(_) = Some(42) {}
 +
 +    while let None = Some(42) {}
 +
 +    while let None = None::<()> {}
 +
 +    let mut v = vec![1, 2, 3];
 +    while let Some(_) = v.pop() {
 +        foo();
 +    }
 +
 +    if None::<i32>.is_none() {}
 +
 +    if Some(42).is_some() {}
 +
 +    match Some(42) {
 +        Some(_) => true,
 +        None => false,
 +    };
 +
 +    match None::<()> {
 +        Some(_) => false,
 +        None => true,
 +    };
 +
 +    let _ = match None::<()> {
 +        Some(_) => false,
 +        None => true,
 +    };
 +
 +    let opt = Some(false);
 +    let _ = if let Some(_) = opt { true } else { false };
 +
 +    issue6067();
 +
 +    let _ = if let Some(_) = gen_opt() {
 +        1
 +    } else if let None = gen_opt() {
 +        2
 +    } else {
 +        3
 +    };
 +}
 +
 +fn gen_opt() -> Option<()> {
 +    None
 +}
 +
 +fn foo() {}
 +
 +fn bar() {}
 +
 +// Methods that are unstable const should not be suggested within a const context, see issue #5697.
 +// However, in Rust 1.48.0 the methods `is_some` and `is_none` of `Option` were stabilized as const,
 +// so the following should be linted.
 +const fn issue6067() {
 +    if let Some(_) = Some(42) {}
 +
 +    if let None = None::<()> {}
 +
 +    while let Some(_) = Some(42) {}
 +
 +    while let None = None::<()> {}
 +
 +    match Some(42) {
 +        Some(_) => true,
 +        None => false,
 +    };
 +
 +    match None::<()> {
 +        Some(_) => false,
 +        None => true,
 +    };
 +}
 +
++#[allow(clippy::deref_addrof, dead_code, clippy::needless_borrow)]
 +fn issue7921() {
 +    if let None = *(&None::<()>) {}
 +    if let None = *&None::<()> {}
 +}
index b9425733a8b27b8d1806b7ec921dee3d9936ca11,0000000000000000000000000000000000000000..8bddec576ed14ceb3eb1448d4f8f509ff4c5ed30
mode 100644,000000..100644
--- /dev/null
@@@ -1,68 -1,0 +1,69 @@@
 +//! Test for Clippy lint renames.
 +// run-rustfix
 +
 +#![allow(dead_code)]
 +// allow the new lint name here, to test if the new name works
 +#![allow(clippy::module_name_repetitions)]
 +#![allow(clippy::new_without_default)]
 +#![allow(clippy::redundant_static_lifetimes)]
 +#![allow(clippy::cognitive_complexity)]
 +#![allow(clippy::bind_instead_of_map)]
 +#![allow(clippy::box_collection)]
 +#![allow(clippy::blocks_in_if_conditions)]
 +#![allow(clippy::map_unwrap_or)]
 +#![allow(clippy::unwrap_used)]
 +#![allow(clippy::expect_used)]
 +#![allow(clippy::for_loops_over_fallibles)]
 +#![allow(clippy::useless_conversion)]
 +#![allow(clippy::invisible_characters)]
 +#![allow(clippy::single_char_add_str)]
 +#![allow(clippy::match_result_ok)]
 +#![allow(clippy::disallowed_types)]
 +#![allow(clippy::disallowed_methods)]
 +// uplifted lints
 +#![allow(invalid_value)]
 +#![allow(array_into_iter)]
 +#![allow(unused_labels)]
 +#![allow(drop_bounds)]
 +#![allow(temporary_cstring_as_ptr)]
 +#![allow(non_fmt_panics)]
 +#![allow(unknown_lints)]
 +#![allow(invalid_atomic_ordering)]
 +#![allow(enum_intrinsics_non_enums)]
 +// warn for the old lint name here, to test if the renaming worked
 +#![warn(clippy::module_name_repetitions)]
 +#![warn(clippy::new_without_default)]
 +#![warn(clippy::redundant_static_lifetimes)]
 +#![warn(clippy::cognitive_complexity)]
 +#![warn(clippy::bind_instead_of_map)]
 +#![warn(clippy::box_collection)]
 +#![warn(clippy::blocks_in_if_conditions)]
 +#![warn(clippy::blocks_in_if_conditions)]
 +#![warn(clippy::map_unwrap_or)]
 +#![warn(clippy::map_unwrap_or)]
 +#![warn(clippy::map_unwrap_or)]
 +#![warn(clippy::unwrap_used)]
 +#![warn(clippy::unwrap_used)]
 +#![warn(clippy::expect_used)]
 +#![warn(clippy::expect_used)]
 +#![warn(clippy::for_loops_over_fallibles)]
 +#![warn(clippy::for_loops_over_fallibles)]
 +#![warn(clippy::useless_conversion)]
 +#![warn(clippy::invisible_characters)]
 +#![warn(clippy::single_char_add_str)]
 +#![warn(clippy::match_result_ok)]
 +#![warn(clippy::disallowed_types)]
 +#![warn(clippy::disallowed_methods)]
++#![warn(clippy::needless_borrow)]
 +// uplifted lints
 +#![warn(invalid_value)]
 +#![warn(array_into_iter)]
 +#![warn(unused_labels)]
 +#![warn(drop_bounds)]
 +#![warn(temporary_cstring_as_ptr)]
 +#![warn(non_fmt_panics)]
 +#![warn(unknown_lints)]
 +#![warn(invalid_atomic_ordering)]
 +#![warn(enum_intrinsics_non_enums)]
 +
 +fn main() {}
index 341c003b9df30548c02e2f07911746cb139089af,0000000000000000000000000000000000000000..d2010d71d2c118681cb7b8f56ddc347af2dfb57e
mode 100644,000000..100644
--- /dev/null
@@@ -1,68 -1,0 +1,69 @@@
 +//! Test for Clippy lint renames.
 +// run-rustfix
 +
 +#![allow(dead_code)]
 +// allow the new lint name here, to test if the new name works
 +#![allow(clippy::module_name_repetitions)]
 +#![allow(clippy::new_without_default)]
 +#![allow(clippy::redundant_static_lifetimes)]
 +#![allow(clippy::cognitive_complexity)]
 +#![allow(clippy::bind_instead_of_map)]
 +#![allow(clippy::box_collection)]
 +#![allow(clippy::blocks_in_if_conditions)]
 +#![allow(clippy::map_unwrap_or)]
 +#![allow(clippy::unwrap_used)]
 +#![allow(clippy::expect_used)]
 +#![allow(clippy::for_loops_over_fallibles)]
 +#![allow(clippy::useless_conversion)]
 +#![allow(clippy::invisible_characters)]
 +#![allow(clippy::single_char_add_str)]
 +#![allow(clippy::match_result_ok)]
 +#![allow(clippy::disallowed_types)]
 +#![allow(clippy::disallowed_methods)]
 +// uplifted lints
 +#![allow(invalid_value)]
 +#![allow(array_into_iter)]
 +#![allow(unused_labels)]
 +#![allow(drop_bounds)]
 +#![allow(temporary_cstring_as_ptr)]
 +#![allow(non_fmt_panics)]
 +#![allow(unknown_lints)]
 +#![allow(invalid_atomic_ordering)]
 +#![allow(enum_intrinsics_non_enums)]
 +// warn for the old lint name here, to test if the renaming worked
 +#![warn(clippy::stutter)]
 +#![warn(clippy::new_without_default_derive)]
 +#![warn(clippy::const_static_lifetime)]
 +#![warn(clippy::cyclomatic_complexity)]
 +#![warn(clippy::option_and_then_some)]
 +#![warn(clippy::box_vec)]
 +#![warn(clippy::block_in_if_condition_expr)]
 +#![warn(clippy::block_in_if_condition_stmt)]
 +#![warn(clippy::option_map_unwrap_or)]
 +#![warn(clippy::option_map_unwrap_or_else)]
 +#![warn(clippy::result_map_unwrap_or_else)]
 +#![warn(clippy::option_unwrap_used)]
 +#![warn(clippy::result_unwrap_used)]
 +#![warn(clippy::option_expect_used)]
 +#![warn(clippy::result_expect_used)]
 +#![warn(clippy::for_loop_over_option)]
 +#![warn(clippy::for_loop_over_result)]
 +#![warn(clippy::identity_conversion)]
 +#![warn(clippy::zero_width_space)]
 +#![warn(clippy::single_char_push_str)]
 +#![warn(clippy::if_let_some_result)]
 +#![warn(clippy::disallowed_type)]
 +#![warn(clippy::disallowed_method)]
++#![warn(clippy::ref_in_deref)]
 +// uplifted lints
 +#![warn(clippy::invalid_ref)]
 +#![warn(clippy::into_iter_on_array)]
 +#![warn(clippy::unused_label)]
 +#![warn(clippy::drop_bounds)]
 +#![warn(clippy::temporary_cstring_as_ptr)]
 +#![warn(clippy::panic_params)]
 +#![warn(clippy::unknown_clippy_lints)]
 +#![warn(clippy::invalid_atomic_ordering)]
 +#![warn(clippy::mem_discriminant_non_enum)]
 +
 +fn main() {}
index cdec2808f1d4142e103fa9a068307c93e3579262,0000000000000000000000000000000000000000..45cb8b786f5f3d89ba5c357d47343d0a4311ee11
mode 100644,000000..100644
--- /dev/null
@@@ -1,196 -1,0 +1,202 @@@
-   --> $DIR/rename.rs:58:9
 +error: lint `clippy::stutter` has been renamed to `clippy::module_name_repetitions`
 +  --> $DIR/rename.rs:34:9
 +   |
 +LL | #![warn(clippy::stutter)]
 +   |         ^^^^^^^^^^^^^^^ help: use the new name: `clippy::module_name_repetitions`
 +   |
 +   = note: `-D renamed-and-removed-lints` implied by `-D warnings`
 +
 +error: lint `clippy::new_without_default_derive` has been renamed to `clippy::new_without_default`
 +  --> $DIR/rename.rs:35:9
 +   |
 +LL | #![warn(clippy::new_without_default_derive)]
 +   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::new_without_default`
 +
 +error: lint `clippy::const_static_lifetime` has been renamed to `clippy::redundant_static_lifetimes`
 +  --> $DIR/rename.rs:36:9
 +   |
 +LL | #![warn(clippy::const_static_lifetime)]
 +   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::redundant_static_lifetimes`
 +
 +error: lint `clippy::cyclomatic_complexity` has been renamed to `clippy::cognitive_complexity`
 +  --> $DIR/rename.rs:37:9
 +   |
 +LL | #![warn(clippy::cyclomatic_complexity)]
 +   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::cognitive_complexity`
 +
 +error: lint `clippy::option_and_then_some` has been renamed to `clippy::bind_instead_of_map`
 +  --> $DIR/rename.rs:38:9
 +   |
 +LL | #![warn(clippy::option_and_then_some)]
 +   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::bind_instead_of_map`
 +
 +error: lint `clippy::box_vec` has been renamed to `clippy::box_collection`
 +  --> $DIR/rename.rs:39:9
 +   |
 +LL | #![warn(clippy::box_vec)]
 +   |         ^^^^^^^^^^^^^^^ help: use the new name: `clippy::box_collection`
 +
 +error: lint `clippy::block_in_if_condition_expr` has been renamed to `clippy::blocks_in_if_conditions`
 +  --> $DIR/rename.rs:40:9
 +   |
 +LL | #![warn(clippy::block_in_if_condition_expr)]
 +   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::blocks_in_if_conditions`
 +
 +error: lint `clippy::block_in_if_condition_stmt` has been renamed to `clippy::blocks_in_if_conditions`
 +  --> $DIR/rename.rs:41:9
 +   |
 +LL | #![warn(clippy::block_in_if_condition_stmt)]
 +   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::blocks_in_if_conditions`
 +
 +error: lint `clippy::option_map_unwrap_or` has been renamed to `clippy::map_unwrap_or`
 +  --> $DIR/rename.rs:42:9
 +   |
 +LL | #![warn(clippy::option_map_unwrap_or)]
 +   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::map_unwrap_or`
 +
 +error: lint `clippy::option_map_unwrap_or_else` has been renamed to `clippy::map_unwrap_or`
 +  --> $DIR/rename.rs:43:9
 +   |
 +LL | #![warn(clippy::option_map_unwrap_or_else)]
 +   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::map_unwrap_or`
 +
 +error: lint `clippy::result_map_unwrap_or_else` has been renamed to `clippy::map_unwrap_or`
 +  --> $DIR/rename.rs:44:9
 +   |
 +LL | #![warn(clippy::result_map_unwrap_or_else)]
 +   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::map_unwrap_or`
 +
 +error: lint `clippy::option_unwrap_used` has been renamed to `clippy::unwrap_used`
 +  --> $DIR/rename.rs:45:9
 +   |
 +LL | #![warn(clippy::option_unwrap_used)]
 +   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::unwrap_used`
 +
 +error: lint `clippy::result_unwrap_used` has been renamed to `clippy::unwrap_used`
 +  --> $DIR/rename.rs:46:9
 +   |
 +LL | #![warn(clippy::result_unwrap_used)]
 +   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::unwrap_used`
 +
 +error: lint `clippy::option_expect_used` has been renamed to `clippy::expect_used`
 +  --> $DIR/rename.rs:47:9
 +   |
 +LL | #![warn(clippy::option_expect_used)]
 +   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::expect_used`
 +
 +error: lint `clippy::result_expect_used` has been renamed to `clippy::expect_used`
 +  --> $DIR/rename.rs:48:9
 +   |
 +LL | #![warn(clippy::result_expect_used)]
 +   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::expect_used`
 +
 +error: lint `clippy::for_loop_over_option` has been renamed to `clippy::for_loops_over_fallibles`
 +  --> $DIR/rename.rs:49:9
 +   |
 +LL | #![warn(clippy::for_loop_over_option)]
 +   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::for_loops_over_fallibles`
 +
 +error: lint `clippy::for_loop_over_result` has been renamed to `clippy::for_loops_over_fallibles`
 +  --> $DIR/rename.rs:50:9
 +   |
 +LL | #![warn(clippy::for_loop_over_result)]
 +   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::for_loops_over_fallibles`
 +
 +error: lint `clippy::identity_conversion` has been renamed to `clippy::useless_conversion`
 +  --> $DIR/rename.rs:51:9
 +   |
 +LL | #![warn(clippy::identity_conversion)]
 +   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::useless_conversion`
 +
 +error: lint `clippy::zero_width_space` has been renamed to `clippy::invisible_characters`
 +  --> $DIR/rename.rs:52:9
 +   |
 +LL | #![warn(clippy::zero_width_space)]
 +   |         ^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::invisible_characters`
 +
 +error: lint `clippy::single_char_push_str` has been renamed to `clippy::single_char_add_str`
 +  --> $DIR/rename.rs:53:9
 +   |
 +LL | #![warn(clippy::single_char_push_str)]
 +   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::single_char_add_str`
 +
 +error: lint `clippy::if_let_some_result` has been renamed to `clippy::match_result_ok`
 +  --> $DIR/rename.rs:54:9
 +   |
 +LL | #![warn(clippy::if_let_some_result)]
 +   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::match_result_ok`
 +
 +error: lint `clippy::disallowed_type` has been renamed to `clippy::disallowed_types`
 +  --> $DIR/rename.rs:55:9
 +   |
 +LL | #![warn(clippy::disallowed_type)]
 +   |         ^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::disallowed_types`
 +
 +error: lint `clippy::disallowed_method` has been renamed to `clippy::disallowed_methods`
 +  --> $DIR/rename.rs:56:9
 +   |
 +LL | #![warn(clippy::disallowed_method)]
 +   |         ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::disallowed_methods`
 +
++error: lint `clippy::ref_in_deref` has been renamed to `clippy::needless_borrow`
++  --> $DIR/rename.rs:57:9
++   |
++LL | #![warn(clippy::ref_in_deref)]
++   |         ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::needless_borrow`
++
 +error: lint `clippy::invalid_ref` has been renamed to `invalid_value`
-   --> $DIR/rename.rs:59:9
++  --> $DIR/rename.rs:59:9
 +   |
 +LL | #![warn(clippy::invalid_ref)]
 +   |         ^^^^^^^^^^^^^^^^^^^ help: use the new name: `invalid_value`
 +
 +error: lint `clippy::into_iter_on_array` has been renamed to `array_into_iter`
-   --> $DIR/rename.rs:60:9
++  --> $DIR/rename.rs:60:9
 +   |
 +LL | #![warn(clippy::into_iter_on_array)]
 +   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `array_into_iter`
 +
 +error: lint `clippy::unused_label` has been renamed to `unused_labels`
-   --> $DIR/rename.rs:61:9
++  --> $DIR/rename.rs:61:9
 +   |
 +LL | #![warn(clippy::unused_label)]
 +   |         ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `unused_labels`
 +
 +error: lint `clippy::drop_bounds` has been renamed to `drop_bounds`
-   --> $DIR/rename.rs:62:9
++  --> $DIR/rename.rs:62:9
 +   |
 +LL | #![warn(clippy::drop_bounds)]
 +   |         ^^^^^^^^^^^^^^^^^^^ help: use the new name: `drop_bounds`
 +
 +error: lint `clippy::temporary_cstring_as_ptr` has been renamed to `temporary_cstring_as_ptr`
-   --> $DIR/rename.rs:63:9
++  --> $DIR/rename.rs:63:9
 +   |
 +LL | #![warn(clippy::temporary_cstring_as_ptr)]
 +   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `temporary_cstring_as_ptr`
 +
 +error: lint `clippy::panic_params` has been renamed to `non_fmt_panics`
-   --> $DIR/rename.rs:64:9
++  --> $DIR/rename.rs:64:9
 +   |
 +LL | #![warn(clippy::panic_params)]
 +   |         ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `non_fmt_panics`
 +
 +error: lint `clippy::unknown_clippy_lints` has been renamed to `unknown_lints`
-   --> $DIR/rename.rs:65:9
++  --> $DIR/rename.rs:65:9
 +   |
 +LL | #![warn(clippy::unknown_clippy_lints)]
 +   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `unknown_lints`
 +
 +error: lint `clippy::invalid_atomic_ordering` has been renamed to `invalid_atomic_ordering`
-   --> $DIR/rename.rs:66:9
++  --> $DIR/rename.rs:66:9
 +   |
 +LL | #![warn(clippy::invalid_atomic_ordering)]
 +   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `invalid_atomic_ordering`
 +
 +error: lint `clippy::mem_discriminant_non_enum` has been renamed to `enum_intrinsics_non_enums`
- error: aborting due to 32 previous errors
++  --> $DIR/rename.rs:67:9
 +   |
 +LL | #![warn(clippy::mem_discriminant_non_enum)]
 +   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `enum_intrinsics_non_enums`
 +
++error: aborting due to 33 previous errors
 +
index 778f4f6fa257e6d9192c8c90ce3a0cea40b00bba,0000000000000000000000000000000000000000..767518ab0c0f5e1c345cd2acbee0921cefead3ee
mode 100644,000000..100644
--- /dev/null
@@@ -1,222 -1,0 +1,222 @@@
-     fn test_string_1(s: &String) -> bool {
 +// run-rustfix
 +#![allow(dead_code)]
 +#![warn(clippy::search_is_some)]
 +
 +fn main() {
 +    let v = vec![3, 2, 1, 0, -1, -2, -3];
 +    let y = &&42;
 +
 +    // Check `find().is_none()`, single-line case.
 +    let _ = v.iter().find(|&x| *x < 0).is_none();
 +    let _ = (0..1).find(|x| **y == *x).is_none(); // one dereference less
 +    let _ = (0..1).find(|x| *x == 0).is_none();
 +    let _ = v.iter().find(|x| **x == 0).is_none();
 +    let _ = (4..5).find(|x| *x == 1 || *x == 3 || *x == 5).is_none();
 +    let _ = (1..3).find(|x| [1, 2, 3].contains(x)).is_none();
 +    let _ = (1..3).find(|x| *x == 0 || [1, 2, 3].contains(x)).is_none();
 +    let _ = (1..3).find(|x| [1, 2, 3].contains(x) || *x == 0).is_none();
 +    let _ = (1..3)
 +        .find(|x| [1, 2, 3].contains(x) || *x == 0 || [4, 5, 6].contains(x) || *x == -1)
 +        .is_none();
 +
 +    // Check `position().is_none()`, single-line case.
 +    let _ = v.iter().position(|&x| x < 0).is_none();
 +
 +    // Check `rposition().is_none()`, single-line case.
 +    let _ = v.iter().rposition(|&x| x < 0).is_none();
 +
 +    let s1 = String::from("hello world");
 +    let s2 = String::from("world");
 +
 +    // caller of `find()` is a `&`static str`
 +    let _ = "hello world".find("world").is_none();
 +    let _ = "hello world".find(&s2).is_none();
 +    let _ = "hello world".find(&s2[2..]).is_none();
 +    // caller of `find()` is a `String`
 +    let _ = s1.find("world").is_none();
 +    let _ = s1.find(&s2).is_none();
 +    let _ = s1.find(&s2[2..]).is_none();
 +    // caller of `find()` is slice of `String`
 +    let _ = s1[2..].find("world").is_none();
 +    let _ = s1[2..].find(&s2).is_none();
 +    let _ = s1[2..].find(&s2[2..]).is_none();
 +}
 +
 +#[allow(clippy::clone_on_copy, clippy::map_clone)]
 +mod issue7392 {
 +    struct Player {
 +        hand: Vec<usize>,
 +    }
 +    fn filter() {
 +        let p = Player {
 +            hand: vec![1, 2, 3, 4, 5],
 +        };
 +        let filter_hand = vec![5];
 +        let _ = p
 +            .hand
 +            .iter()
 +            .filter(|c| filter_hand.iter().find(|cc| c == cc).is_none())
 +            .map(|c| c.clone())
 +            .collect::<Vec<_>>();
 +    }
 +
 +    struct PlayerTuple {
 +        hand: Vec<(usize, char)>,
 +    }
 +    fn filter_tuple() {
 +        let p = PlayerTuple {
 +            hand: vec![(1, 'a'), (2, 'b'), (3, 'c'), (4, 'd'), (5, 'e')],
 +        };
 +        let filter_hand = vec![5];
 +        let _ = p
 +            .hand
 +            .iter()
 +            .filter(|(c, _)| filter_hand.iter().find(|cc| c == *cc).is_none())
 +            .map(|c| c.clone())
 +            .collect::<Vec<_>>();
 +    }
 +
 +    fn field_projection() {
 +        struct Foo {
 +            foo: i32,
 +            bar: u32,
 +        }
 +        let vfoo = vec![Foo { foo: 1, bar: 2 }];
 +        let _ = vfoo.iter().find(|v| v.foo == 1 && v.bar == 2).is_none();
 +
 +        let vfoo = vec![(42, Foo { foo: 1, bar: 2 })];
 +        let _ = vfoo
 +            .iter()
 +            .find(|(i, v)| *i == 42 && v.foo == 1 && v.bar == 2)
 +            .is_none();
 +    }
 +
 +    fn index_projection() {
 +        let vfoo = vec![[0, 1, 2, 3]];
 +        let _ = vfoo.iter().find(|a| a[0] == 42).is_none();
 +    }
 +
 +    #[allow(clippy::match_like_matches_macro)]
 +    fn slice_projection() {
 +        let vfoo = vec![[0, 1, 2, 3, 0, 1, 2, 3]];
 +        let _ = vfoo.iter().find(|sub| sub[1..4].len() == 3).is_none();
 +    }
 +
 +    fn please(x: &u32) -> bool {
 +        *x == 9
 +    }
 +
 +    fn deref_enough(x: u32) -> bool {
 +        x == 78
 +    }
 +
 +    fn arg_no_deref(x: &&u32) -> bool {
 +        **x == 78
 +    }
 +
 +    fn more_projections() {
 +        let x = 19;
 +        let ppx: &u32 = &x;
 +        let _ = [ppx].iter().find(|ppp_x: &&&u32| please(**ppp_x)).is_none();
 +        let _ = [String::from("Hey hey")].iter().find(|s| s.len() == 2).is_none();
 +
 +        let v = vec![3, 2, 1, 0];
 +        let _ = v.iter().find(|x| deref_enough(**x)).is_none();
 +        let _ = v.iter().find(|x: &&u32| deref_enough(**x)).is_none();
 +
 +        #[allow(clippy::redundant_closure)]
 +        let _ = v.iter().find(|x| arg_no_deref(x)).is_none();
 +        #[allow(clippy::redundant_closure)]
 +        let _ = v.iter().find(|x: &&u32| arg_no_deref(x)).is_none();
 +    }
 +
 +    fn field_index_projection() {
 +        struct FooDouble {
 +            bar: Vec<Vec<i32>>,
 +        }
 +        struct Foo {
 +            bar: Vec<i32>,
 +        }
 +        struct FooOuter {
 +            inner: Foo,
 +            inner_double: FooDouble,
 +        }
 +        let vfoo = vec![FooOuter {
 +            inner: Foo { bar: vec![0, 1, 2, 3] },
 +            inner_double: FooDouble {
 +                bar: vec![vec![0, 1, 2, 3]],
 +            },
 +        }];
 +        let _ = vfoo
 +            .iter()
 +            .find(|v| v.inner_double.bar[0][0] == 2 && v.inner.bar[0] == 2)
 +            .is_none();
 +    }
 +
 +    fn index_field_projection() {
 +        struct Foo {
 +            bar: i32,
 +        }
 +        struct FooOuter {
 +            inner: Vec<Foo>,
 +        }
 +        let vfoo = vec![FooOuter {
 +            inner: vec![Foo { bar: 0 }],
 +        }];
 +        let _ = vfoo.iter().find(|v| v.inner[0].bar == 2).is_none();
 +    }
 +
 +    fn double_deref_index_projection() {
 +        let vfoo = vec![&&[0, 1, 2, 3]];
 +        let _ = vfoo.iter().find(|x| (**x)[0] == 9).is_none();
 +    }
 +
 +    fn method_call_by_ref() {
 +        struct Foo {
 +            bar: u32,
 +        }
 +        impl Foo {
 +            pub fn by_ref(&self, x: &u32) -> bool {
 +                *x == self.bar
 +            }
 +        }
 +        let vfoo = vec![Foo { bar: 1 }];
 +        let _ = vfoo.iter().find(|v| v.by_ref(&v.bar)).is_none();
 +    }
 +
 +    fn ref_bindings() {
 +        let _ = [&(&1, 2), &(&3, 4), &(&5, 4)].iter().find(|(&x, y)| x == *y).is_none();
 +        let _ = [&(&1, 2), &(&3, 4), &(&5, 4)].iter().find(|&(&x, y)| x == *y).is_none();
 +    }
 +
++    fn test_string_1(s: &str) -> bool {
 +        s.is_empty()
 +    }
 +
 +    fn test_u32_1(s: &u32) -> bool {
 +        s.is_power_of_two()
 +    }
 +
 +    fn test_u32_2(s: u32) -> bool {
 +        s.is_power_of_two()
 +    }
 +
 +    fn projection_in_args_test() {
 +        // Index projections
 +        let lst = &[String::from("Hello"), String::from("world")];
 +        let v: Vec<&[String]> = vec![lst];
 +        let _ = v.iter().find(|s| s[0].is_empty()).is_none();
 +        let _ = v.iter().find(|s| test_string_1(&s[0])).is_none();
 +
 +        // Field projections
 +        struct FieldProjection<'a> {
 +            field: &'a u32,
 +        }
 +        let field = 123456789;
 +        let instance = FieldProjection { field: &field };
 +        let v = vec![instance];
 +        let _ = v.iter().find(|fp| fp.field.is_power_of_two()).is_none();
 +        let _ = v.iter().find(|fp| test_u32_1(fp.field)).is_none();
 +        let _ = v.iter().find(|fp| test_u32_2(*fp.field)).is_none();
 +    }
 +}
index 7c5e5eb589c1a53d2b9deb1ed33639b383843327,0000000000000000000000000000000000000000..933ce5cf42d2e227f7897e7ce576f38786880abf
mode 100644,000000..100644
--- /dev/null
@@@ -1,293 -1,0 +1,285 @@@
- error: writing `&String` instead of `&str` involves a new object where a slice will do
-   --> $DIR/search_is_some_fixable_none.rs:192:25
-    |
- LL |     fn test_string_1(s: &String) -> bool {
-    |                         ^^^^^^^ help: change this to: `&str`
-    |
-    = note: `-D clippy::ptr-arg` implied by `-D warnings`
 +error: called `is_none()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_none.rs:10:13
 +   |
 +LL |     let _ = v.iter().find(|&x| *x < 0).is_none();
 +   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!v.iter().any(|x| *x < 0)`
 +   |
 +   = note: `-D clippy::search-is-some` implied by `-D warnings`
 +
 +error: called `is_none()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_none.rs:11:13
 +   |
 +LL |     let _ = (0..1).find(|x| **y == *x).is_none(); // one dereference less
 +   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!(0..1).any(|x| **y == x)`
 +
 +error: called `is_none()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_none.rs:12:13
 +   |
 +LL |     let _ = (0..1).find(|x| *x == 0).is_none();
 +   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!(0..1).any(|x| x == 0)`
 +
 +error: called `is_none()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_none.rs:13:13
 +   |
 +LL |     let _ = v.iter().find(|x| **x == 0).is_none();
 +   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!v.iter().any(|x| *x == 0)`
 +
 +error: called `is_none()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_none.rs:14:13
 +   |
 +LL |     let _ = (4..5).find(|x| *x == 1 || *x == 3 || *x == 5).is_none();
 +   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!(4..5).any(|x| x == 1 || x == 3 || x == 5)`
 +
 +error: called `is_none()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_none.rs:15:13
 +   |
 +LL |     let _ = (1..3).find(|x| [1, 2, 3].contains(x)).is_none();
 +   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!(1..3).any(|x| [1, 2, 3].contains(&x))`
 +
 +error: called `is_none()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_none.rs:16:13
 +   |
 +LL |     let _ = (1..3).find(|x| *x == 0 || [1, 2, 3].contains(x)).is_none();
 +   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!(1..3).any(|x| x == 0 || [1, 2, 3].contains(&x))`
 +
 +error: called `is_none()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_none.rs:17:13
 +   |
 +LL |     let _ = (1..3).find(|x| [1, 2, 3].contains(x) || *x == 0).is_none();
 +   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!(1..3).any(|x| [1, 2, 3].contains(&x) || x == 0)`
 +
 +error: called `is_none()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_none.rs:18:13
 +   |
 +LL |       let _ = (1..3)
 +   |  _____________^
 +LL | |         .find(|x| [1, 2, 3].contains(x) || *x == 0 || [4, 5, 6].contains(x) || *x == -1)
 +LL | |         .is_none();
 +   | |__________________^ help: use `!_.any()` instead: `!(1..3).any(|x| [1, 2, 3].contains(&x) || x == 0 || [4, 5, 6].contains(&x) || x == -1)`
 +
 +error: called `is_none()` after searching an `Iterator` with `position`
 +  --> $DIR/search_is_some_fixable_none.rs:23:13
 +   |
 +LL |     let _ = v.iter().position(|&x| x < 0).is_none();
 +   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!v.iter().any(|&x| x < 0)`
 +
 +error: called `is_none()` after searching an `Iterator` with `rposition`
 +  --> $DIR/search_is_some_fixable_none.rs:26:13
 +   |
 +LL |     let _ = v.iter().rposition(|&x| x < 0).is_none();
 +   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!v.iter().any(|&x| x < 0)`
 +
 +error: called `is_none()` after calling `find()` on a string
 +  --> $DIR/search_is_some_fixable_none.rs:32:13
 +   |
 +LL |     let _ = "hello world".find("world").is_none();
 +   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.contains()` instead: `!"hello world".contains("world")`
 +
 +error: called `is_none()` after calling `find()` on a string
 +  --> $DIR/search_is_some_fixable_none.rs:33:13
 +   |
 +LL |     let _ = "hello world".find(&s2).is_none();
 +   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.contains()` instead: `!"hello world".contains(&s2)`
 +
 +error: called `is_none()` after calling `find()` on a string
 +  --> $DIR/search_is_some_fixable_none.rs:34:13
 +   |
 +LL |     let _ = "hello world".find(&s2[2..]).is_none();
 +   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.contains()` instead: `!"hello world".contains(&s2[2..])`
 +
 +error: called `is_none()` after calling `find()` on a string
 +  --> $DIR/search_is_some_fixable_none.rs:36:13
 +   |
 +LL |     let _ = s1.find("world").is_none();
 +   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.contains()` instead: `!s1.contains("world")`
 +
 +error: called `is_none()` after calling `find()` on a string
 +  --> $DIR/search_is_some_fixable_none.rs:37:13
 +   |
 +LL |     let _ = s1.find(&s2).is_none();
 +   |             ^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.contains()` instead: `!s1.contains(&s2)`
 +
 +error: called `is_none()` after calling `find()` on a string
 +  --> $DIR/search_is_some_fixable_none.rs:38:13
 +   |
 +LL |     let _ = s1.find(&s2[2..]).is_none();
 +   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.contains()` instead: `!s1.contains(&s2[2..])`
 +
 +error: called `is_none()` after calling `find()` on a string
 +  --> $DIR/search_is_some_fixable_none.rs:40:13
 +   |
 +LL |     let _ = s1[2..].find("world").is_none();
 +   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.contains()` instead: `!s1[2..].contains("world")`
 +
 +error: called `is_none()` after calling `find()` on a string
 +  --> $DIR/search_is_some_fixable_none.rs:41:13
 +   |
 +LL |     let _ = s1[2..].find(&s2).is_none();
 +   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.contains()` instead: `!s1[2..].contains(&s2)`
 +
 +error: called `is_none()` after calling `find()` on a string
 +  --> $DIR/search_is_some_fixable_none.rs:42:13
 +   |
 +LL |     let _ = s1[2..].find(&s2[2..]).is_none();
 +   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.contains()` instead: `!s1[2..].contains(&s2[2..])`
 +
 +error: called `is_none()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_none.rs:58:25
 +   |
 +LL |             .filter(|c| filter_hand.iter().find(|cc| c == cc).is_none())
 +   |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!filter_hand.iter().any(|cc| c == &cc)`
 +
 +error: called `is_none()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_none.rs:74:30
 +   |
 +LL |             .filter(|(c, _)| filter_hand.iter().find(|cc| c == *cc).is_none())
 +   |                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!filter_hand.iter().any(|cc| c == cc)`
 +
 +error: called `is_none()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_none.rs:85:17
 +   |
 +LL |         let _ = vfoo.iter().find(|v| v.foo == 1 && v.bar == 2).is_none();
 +   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!vfoo.iter().any(|v| v.foo == 1 && v.bar == 2)`
 +
 +error: called `is_none()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_none.rs:88:17
 +   |
 +LL |           let _ = vfoo
 +   |  _________________^
 +LL | |             .iter()
 +LL | |             .find(|(i, v)| *i == 42 && v.foo == 1 && v.bar == 2)
 +LL | |             .is_none();
 +   | |______________________^
 +   |
 +help: use `!_.any()` instead
 +   |
 +LL ~         let _ = !vfoo
 +LL ~             .iter().any(|(i, v)| *i == 42 && v.foo == 1 && v.bar == 2);
 +   |
 +
 +error: called `is_none()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_none.rs:96:17
 +   |
 +LL |         let _ = vfoo.iter().find(|a| a[0] == 42).is_none();
 +   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!vfoo.iter().any(|a| a[0] == 42)`
 +
 +error: called `is_none()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_none.rs:102:17
 +   |
 +LL |         let _ = vfoo.iter().find(|sub| sub[1..4].len() == 3).is_none();
 +   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!vfoo.iter().any(|sub| sub[1..4].len() == 3)`
 +
 +error: called `is_none()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_none.rs:120:17
 +   |
 +LL |         let _ = [ppx].iter().find(|ppp_x: &&&u32| please(**ppp_x)).is_none();
 +   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `![ppx].iter().any(|ppp_x: &&u32| please(ppp_x))`
 +
 +error: called `is_none()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_none.rs:121:17
 +   |
 +LL |         let _ = [String::from("Hey hey")].iter().find(|s| s.len() == 2).is_none();
 +   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `![String::from("Hey hey")].iter().any(|s| s.len() == 2)`
 +
 +error: called `is_none()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_none.rs:124:17
 +   |
 +LL |         let _ = v.iter().find(|x| deref_enough(**x)).is_none();
 +   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!v.iter().any(|x| deref_enough(*x))`
 +
 +error: called `is_none()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_none.rs:125:17
 +   |
 +LL |         let _ = v.iter().find(|x: &&u32| deref_enough(**x)).is_none();
 +   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!v.iter().any(|x: &u32| deref_enough(*x))`
 +
 +error: called `is_none()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_none.rs:128:17
 +   |
 +LL |         let _ = v.iter().find(|x| arg_no_deref(x)).is_none();
 +   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!v.iter().any(|x| arg_no_deref(&x))`
 +
 +error: called `is_none()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_none.rs:130:17
 +   |
 +LL |         let _ = v.iter().find(|x: &&u32| arg_no_deref(x)).is_none();
 +   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!v.iter().any(|x: &u32| arg_no_deref(&x))`
 +
 +error: called `is_none()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_none.rs:150:17
 +   |
 +LL |           let _ = vfoo
 +   |  _________________^
 +LL | |             .iter()
 +LL | |             .find(|v| v.inner_double.bar[0][0] == 2 && v.inner.bar[0] == 2)
 +LL | |             .is_none();
 +   | |______________________^
 +   |
 +help: use `!_.any()` instead
 +   |
 +LL ~         let _ = !vfoo
 +LL ~             .iter().any(|v| v.inner_double.bar[0][0] == 2 && v.inner.bar[0] == 2);
 +   |
 +
 +error: called `is_none()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_none.rs:166:17
 +   |
 +LL |         let _ = vfoo.iter().find(|v| v.inner[0].bar == 2).is_none();
 +   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!vfoo.iter().any(|v| v.inner[0].bar == 2)`
 +
 +error: called `is_none()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_none.rs:171:17
 +   |
 +LL |         let _ = vfoo.iter().find(|x| (**x)[0] == 9).is_none();
 +   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!vfoo.iter().any(|x| (**x)[0] == 9)`
 +
 +error: called `is_none()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_none.rs:184:17
 +   |
 +LL |         let _ = vfoo.iter().find(|v| v.by_ref(&v.bar)).is_none();
 +   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!vfoo.iter().any(|v| v.by_ref(&v.bar))`
 +
 +error: called `is_none()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_none.rs:188:17
 +   |
 +LL |         let _ = [&(&1, 2), &(&3, 4), &(&5, 4)].iter().find(|(&x, y)| x == *y).is_none();
 +   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `![&(&1, 2), &(&3, 4), &(&5, 4)].iter().any(|(&x, y)| x == *y)`
 +
 +error: called `is_none()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_none.rs:189:17
 +   |
 +LL |         let _ = [&(&1, 2), &(&3, 4), &(&5, 4)].iter().find(|&(&x, y)| x == *y).is_none();
 +   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `![&(&1, 2), &(&3, 4), &(&5, 4)].iter().any(|(&x, y)| x == *y)`
 +
- error: aborting due to 44 previous errors
 +error: called `is_none()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_none.rs:208:17
 +   |
 +LL |         let _ = v.iter().find(|s| s[0].is_empty()).is_none();
 +   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!v.iter().any(|s| s[0].is_empty())`
 +
 +error: called `is_none()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_none.rs:209:17
 +   |
 +LL |         let _ = v.iter().find(|s| test_string_1(&s[0])).is_none();
 +   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!v.iter().any(|s| test_string_1(&s[0]))`
 +
 +error: called `is_none()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_none.rs:218:17
 +   |
 +LL |         let _ = v.iter().find(|fp| fp.field.is_power_of_two()).is_none();
 +   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!v.iter().any(|fp| fp.field.is_power_of_two())`
 +
 +error: called `is_none()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_none.rs:219:17
 +   |
 +LL |         let _ = v.iter().find(|fp| test_u32_1(fp.field)).is_none();
 +   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!v.iter().any(|fp| test_u32_1(fp.field))`
 +
 +error: called `is_none()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_none.rs:220:17
 +   |
 +LL |         let _ = v.iter().find(|fp| test_u32_2(*fp.field)).is_none();
 +   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!v.iter().any(|fp| test_u32_2(*fp.field))`
 +
++error: aborting due to 43 previous errors
 +
index 241641fceae3d898fd015ece4b64db063d4f9bf8,0000000000000000000000000000000000000000..77fd52e4ce7698402433df5715745557b28d187b
mode 100644,000000..100644
--- /dev/null
@@@ -1,221 -1,0 +1,221 @@@
-     fn test_string_1(s: &String) -> bool {
 +// run-rustfix
 +#![allow(dead_code)]
 +#![warn(clippy::search_is_some)]
 +
 +fn main() {
 +    let v = vec![3, 2, 1, 0, -1, -2, -3];
 +    let y = &&42;
 +
 +    // Check `find().is_some()`, single-line case.
 +    let _ = v.iter().find(|&x| *x < 0).is_some();
 +    let _ = (0..1).find(|x| **y == *x).is_some(); // one dereference less
 +    let _ = (0..1).find(|x| *x == 0).is_some();
 +    let _ = v.iter().find(|x| **x == 0).is_some();
 +    let _ = (4..5).find(|x| *x == 1 || *x == 3 || *x == 5).is_some();
 +    let _ = (1..3).find(|x| [1, 2, 3].contains(x)).is_some();
 +    let _ = (1..3).find(|x| *x == 0 || [1, 2, 3].contains(x)).is_some();
 +    let _ = (1..3).find(|x| [1, 2, 3].contains(x) || *x == 0).is_some();
 +    let _ = (1..3)
 +        .find(|x| [1, 2, 3].contains(x) || *x == 0 || [4, 5, 6].contains(x) || *x == -1)
 +        .is_some();
 +
 +    // Check `position().is_some()`, single-line case.
 +    let _ = v.iter().position(|&x| x < 0).is_some();
 +
 +    // Check `rposition().is_some()`, single-line case.
 +    let _ = v.iter().rposition(|&x| x < 0).is_some();
 +
 +    let s1 = String::from("hello world");
 +    let s2 = String::from("world");
 +    // caller of `find()` is a `&`static str`
 +    let _ = "hello world".find("world").is_some();
 +    let _ = "hello world".find(&s2).is_some();
 +    let _ = "hello world".find(&s2[2..]).is_some();
 +    // caller of `find()` is a `String`
 +    let _ = s1.find("world").is_some();
 +    let _ = s1.find(&s2).is_some();
 +    let _ = s1.find(&s2[2..]).is_some();
 +    // caller of `find()` is slice of `String`
 +    let _ = s1[2..].find("world").is_some();
 +    let _ = s1[2..].find(&s2).is_some();
 +    let _ = s1[2..].find(&s2[2..]).is_some();
 +}
 +
 +#[allow(clippy::clone_on_copy, clippy::map_clone)]
 +mod issue7392 {
 +    struct Player {
 +        hand: Vec<usize>,
 +    }
 +    fn filter() {
 +        let p = Player {
 +            hand: vec![1, 2, 3, 4, 5],
 +        };
 +        let filter_hand = vec![5];
 +        let _ = p
 +            .hand
 +            .iter()
 +            .filter(|c| filter_hand.iter().find(|cc| c == cc).is_some())
 +            .map(|c| c.clone())
 +            .collect::<Vec<_>>();
 +    }
 +
 +    struct PlayerTuple {
 +        hand: Vec<(usize, char)>,
 +    }
 +    fn filter_tuple() {
 +        let p = PlayerTuple {
 +            hand: vec![(1, 'a'), (2, 'b'), (3, 'c'), (4, 'd'), (5, 'e')],
 +        };
 +        let filter_hand = vec![5];
 +        let _ = p
 +            .hand
 +            .iter()
 +            .filter(|(c, _)| filter_hand.iter().find(|cc| c == *cc).is_some())
 +            .map(|c| c.clone())
 +            .collect::<Vec<_>>();
 +    }
 +
 +    fn field_projection() {
 +        struct Foo {
 +            foo: i32,
 +            bar: u32,
 +        }
 +        let vfoo = vec![Foo { foo: 1, bar: 2 }];
 +        let _ = vfoo.iter().find(|v| v.foo == 1 && v.bar == 2).is_some();
 +
 +        let vfoo = vec![(42, Foo { foo: 1, bar: 2 })];
 +        let _ = vfoo
 +            .iter()
 +            .find(|(i, v)| *i == 42 && v.foo == 1 && v.bar == 2)
 +            .is_some();
 +    }
 +
 +    fn index_projection() {
 +        let vfoo = vec![[0, 1, 2, 3]];
 +        let _ = vfoo.iter().find(|a| a[0] == 42).is_some();
 +    }
 +
 +    #[allow(clippy::match_like_matches_macro)]
 +    fn slice_projection() {
 +        let vfoo = vec![[0, 1, 2, 3, 0, 1, 2, 3]];
 +        let _ = vfoo.iter().find(|sub| sub[1..4].len() == 3).is_some();
 +    }
 +
 +    fn please(x: &u32) -> bool {
 +        *x == 9
 +    }
 +
 +    fn deref_enough(x: u32) -> bool {
 +        x == 78
 +    }
 +
 +    fn arg_no_deref(x: &&u32) -> bool {
 +        **x == 78
 +    }
 +
 +    fn more_projections() {
 +        let x = 19;
 +        let ppx: &u32 = &x;
 +        let _ = [ppx].iter().find(|ppp_x: &&&u32| please(**ppp_x)).is_some();
 +        let _ = [String::from("Hey hey")].iter().find(|s| s.len() == 2).is_some();
 +
 +        let v = vec![3, 2, 1, 0];
 +        let _ = v.iter().find(|x| deref_enough(**x)).is_some();
 +        let _ = v.iter().find(|x: &&u32| deref_enough(**x)).is_some();
 +
 +        #[allow(clippy::redundant_closure)]
 +        let _ = v.iter().find(|x| arg_no_deref(x)).is_some();
 +        #[allow(clippy::redundant_closure)]
 +        let _ = v.iter().find(|x: &&u32| arg_no_deref(x)).is_some();
 +    }
 +
 +    fn field_index_projection() {
 +        struct FooDouble {
 +            bar: Vec<Vec<i32>>,
 +        }
 +        struct Foo {
 +            bar: Vec<i32>,
 +        }
 +        struct FooOuter {
 +            inner: Foo,
 +            inner_double: FooDouble,
 +        }
 +        let vfoo = vec![FooOuter {
 +            inner: Foo { bar: vec![0, 1, 2, 3] },
 +            inner_double: FooDouble {
 +                bar: vec![vec![0, 1, 2, 3]],
 +            },
 +        }];
 +        let _ = vfoo
 +            .iter()
 +            .find(|v| v.inner_double.bar[0][0] == 2 && v.inner.bar[0] == 2)
 +            .is_some();
 +    }
 +
 +    fn index_field_projection() {
 +        struct Foo {
 +            bar: i32,
 +        }
 +        struct FooOuter {
 +            inner: Vec<Foo>,
 +        }
 +        let vfoo = vec![FooOuter {
 +            inner: vec![Foo { bar: 0 }],
 +        }];
 +        let _ = vfoo.iter().find(|v| v.inner[0].bar == 2).is_some();
 +    }
 +
 +    fn double_deref_index_projection() {
 +        let vfoo = vec![&&[0, 1, 2, 3]];
 +        let _ = vfoo.iter().find(|x| (**x)[0] == 9).is_some();
 +    }
 +
 +    fn method_call_by_ref() {
 +        struct Foo {
 +            bar: u32,
 +        }
 +        impl Foo {
 +            pub fn by_ref(&self, x: &u32) -> bool {
 +                *x == self.bar
 +            }
 +        }
 +        let vfoo = vec![Foo { bar: 1 }];
 +        let _ = vfoo.iter().find(|v| v.by_ref(&v.bar)).is_some();
 +    }
 +
 +    fn ref_bindings() {
 +        let _ = [&(&1, 2), &(&3, 4), &(&5, 4)].iter().find(|(&x, y)| x == *y).is_some();
 +        let _ = [&(&1, 2), &(&3, 4), &(&5, 4)].iter().find(|&(&x, y)| x == *y).is_some();
 +    }
 +
++    fn test_string_1(s: &str) -> bool {
 +        s.is_empty()
 +    }
 +
 +    fn test_u32_1(s: &u32) -> bool {
 +        s.is_power_of_two()
 +    }
 +
 +    fn test_u32_2(s: u32) -> bool {
 +        s.is_power_of_two()
 +    }
 +
 +    fn projection_in_args_test() {
 +        // Index projections
 +        let lst = &[String::from("Hello"), String::from("world")];
 +        let v: Vec<&[String]> = vec![lst];
 +        let _ = v.iter().find(|s| s[0].is_empty()).is_some();
 +        let _ = v.iter().find(|s| test_string_1(&s[0])).is_some();
 +
 +        // Field projections
 +        struct FieldProjection<'a> {
 +            field: &'a u32,
 +        }
 +        let field = 123456789;
 +        let instance = FieldProjection { field: &field };
 +        let v = vec![instance];
 +        let _ = v.iter().find(|fp| fp.field.is_power_of_two()).is_some();
 +        let _ = v.iter().find(|fp| test_u32_1(fp.field)).is_some();
 +        let _ = v.iter().find(|fp| test_u32_2(*fp.field)).is_some();
 +    }
 +}
index 9212c6e71ff54bb7c3c4286683dadc5ec4be5da7,0000000000000000000000000000000000000000..8b424f18ef5b50c60f10d3c69837d748a0778ff6
mode 100644,000000..100644
--- /dev/null
@@@ -1,276 -1,0 +1,268 @@@
- error: writing `&String` instead of `&str` involves a new object where a slice will do
-   --> $DIR/search_is_some_fixable_some.rs:191:25
-    |
- LL |     fn test_string_1(s: &String) -> bool {
-    |                         ^^^^^^^ help: change this to: `&str`
-    |
-    = note: `-D clippy::ptr-arg` implied by `-D warnings`
 +error: called `is_some()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_some.rs:10:22
 +   |
 +LL |     let _ = v.iter().find(|&x| *x < 0).is_some();
 +   |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|x| *x < 0)`
 +   |
 +   = note: `-D clippy::search-is-some` implied by `-D warnings`
 +
 +error: called `is_some()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_some.rs:11:20
 +   |
 +LL |     let _ = (0..1).find(|x| **y == *x).is_some(); // one dereference less
 +   |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|x| **y == x)`
 +
 +error: called `is_some()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_some.rs:12:20
 +   |
 +LL |     let _ = (0..1).find(|x| *x == 0).is_some();
 +   |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|x| x == 0)`
 +
 +error: called `is_some()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_some.rs:13:22
 +   |
 +LL |     let _ = v.iter().find(|x| **x == 0).is_some();
 +   |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|x| *x == 0)`
 +
 +error: called `is_some()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_some.rs:14:20
 +   |
 +LL |     let _ = (4..5).find(|x| *x == 1 || *x == 3 || *x == 5).is_some();
 +   |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|x| x == 1 || x == 3 || x == 5)`
 +
 +error: called `is_some()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_some.rs:15:20
 +   |
 +LL |     let _ = (1..3).find(|x| [1, 2, 3].contains(x)).is_some();
 +   |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|x| [1, 2, 3].contains(&x))`
 +
 +error: called `is_some()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_some.rs:16:20
 +   |
 +LL |     let _ = (1..3).find(|x| *x == 0 || [1, 2, 3].contains(x)).is_some();
 +   |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|x| x == 0 || [1, 2, 3].contains(&x))`
 +
 +error: called `is_some()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_some.rs:17:20
 +   |
 +LL |     let _ = (1..3).find(|x| [1, 2, 3].contains(x) || *x == 0).is_some();
 +   |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|x| [1, 2, 3].contains(&x) || x == 0)`
 +
 +error: called `is_some()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_some.rs:19:10
 +   |
 +LL |           .find(|x| [1, 2, 3].contains(x) || *x == 0 || [4, 5, 6].contains(x) || *x == -1)
 +   |  __________^
 +LL | |         .is_some();
 +   | |__________________^ help: use `any()` instead: `any(|x| [1, 2, 3].contains(&x) || x == 0 || [4, 5, 6].contains(&x) || x == -1)`
 +
 +error: called `is_some()` after searching an `Iterator` with `position`
 +  --> $DIR/search_is_some_fixable_some.rs:23:22
 +   |
 +LL |     let _ = v.iter().position(|&x| x < 0).is_some();
 +   |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|&x| x < 0)`
 +
 +error: called `is_some()` after searching an `Iterator` with `rposition`
 +  --> $DIR/search_is_some_fixable_some.rs:26:22
 +   |
 +LL |     let _ = v.iter().rposition(|&x| x < 0).is_some();
 +   |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|&x| x < 0)`
 +
 +error: called `is_some()` after calling `find()` on a string
 +  --> $DIR/search_is_some_fixable_some.rs:31:27
 +   |
 +LL |     let _ = "hello world".find("world").is_some();
 +   |                           ^^^^^^^^^^^^^^^^^^^^^^^ help: use `contains()` instead: `contains("world")`
 +
 +error: called `is_some()` after calling `find()` on a string
 +  --> $DIR/search_is_some_fixable_some.rs:32:27
 +   |
 +LL |     let _ = "hello world".find(&s2).is_some();
 +   |                           ^^^^^^^^^^^^^^^^^^^ help: use `contains()` instead: `contains(&s2)`
 +
 +error: called `is_some()` after calling `find()` on a string
 +  --> $DIR/search_is_some_fixable_some.rs:33:27
 +   |
 +LL |     let _ = "hello world".find(&s2[2..]).is_some();
 +   |                           ^^^^^^^^^^^^^^^^^^^^^^^^ help: use `contains()` instead: `contains(&s2[2..])`
 +
 +error: called `is_some()` after calling `find()` on a string
 +  --> $DIR/search_is_some_fixable_some.rs:35:16
 +   |
 +LL |     let _ = s1.find("world").is_some();
 +   |                ^^^^^^^^^^^^^^^^^^^^^^^ help: use `contains()` instead: `contains("world")`
 +
 +error: called `is_some()` after calling `find()` on a string
 +  --> $DIR/search_is_some_fixable_some.rs:36:16
 +   |
 +LL |     let _ = s1.find(&s2).is_some();
 +   |                ^^^^^^^^^^^^^^^^^^^ help: use `contains()` instead: `contains(&s2)`
 +
 +error: called `is_some()` after calling `find()` on a string
 +  --> $DIR/search_is_some_fixable_some.rs:37:16
 +   |
 +LL |     let _ = s1.find(&s2[2..]).is_some();
 +   |                ^^^^^^^^^^^^^^^^^^^^^^^^ help: use `contains()` instead: `contains(&s2[2..])`
 +
 +error: called `is_some()` after calling `find()` on a string
 +  --> $DIR/search_is_some_fixable_some.rs:39:21
 +   |
 +LL |     let _ = s1[2..].find("world").is_some();
 +   |                     ^^^^^^^^^^^^^^^^^^^^^^^ help: use `contains()` instead: `contains("world")`
 +
 +error: called `is_some()` after calling `find()` on a string
 +  --> $DIR/search_is_some_fixable_some.rs:40:21
 +   |
 +LL |     let _ = s1[2..].find(&s2).is_some();
 +   |                     ^^^^^^^^^^^^^^^^^^^ help: use `contains()` instead: `contains(&s2)`
 +
 +error: called `is_some()` after calling `find()` on a string
 +  --> $DIR/search_is_some_fixable_some.rs:41:21
 +   |
 +LL |     let _ = s1[2..].find(&s2[2..]).is_some();
 +   |                     ^^^^^^^^^^^^^^^^^^^^^^^^ help: use `contains()` instead: `contains(&s2[2..])`
 +
 +error: called `is_some()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_some.rs:57:44
 +   |
 +LL |             .filter(|c| filter_hand.iter().find(|cc| c == cc).is_some())
 +   |                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|cc| c == &cc)`
 +
 +error: called `is_some()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_some.rs:73:49
 +   |
 +LL |             .filter(|(c, _)| filter_hand.iter().find(|cc| c == *cc).is_some())
 +   |                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|cc| c == cc)`
 +
 +error: called `is_some()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_some.rs:84:29
 +   |
 +LL |         let _ = vfoo.iter().find(|v| v.foo == 1 && v.bar == 2).is_some();
 +   |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|v| v.foo == 1 && v.bar == 2)`
 +
 +error: called `is_some()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_some.rs:89:14
 +   |
 +LL |               .find(|(i, v)| *i == 42 && v.foo == 1 && v.bar == 2)
 +   |  ______________^
 +LL | |             .is_some();
 +   | |______________________^ help: use `any()` instead: `any(|(i, v)| *i == 42 && v.foo == 1 && v.bar == 2)`
 +
 +error: called `is_some()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_some.rs:95:29
 +   |
 +LL |         let _ = vfoo.iter().find(|a| a[0] == 42).is_some();
 +   |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|a| a[0] == 42)`
 +
 +error: called `is_some()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_some.rs:101:29
 +   |
 +LL |         let _ = vfoo.iter().find(|sub| sub[1..4].len() == 3).is_some();
 +   |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|sub| sub[1..4].len() == 3)`
 +
 +error: called `is_some()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_some.rs:119:30
 +   |
 +LL |         let _ = [ppx].iter().find(|ppp_x: &&&u32| please(**ppp_x)).is_some();
 +   |                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|ppp_x: &&u32| please(ppp_x))`
 +
 +error: called `is_some()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_some.rs:120:50
 +   |
 +LL |         let _ = [String::from("Hey hey")].iter().find(|s| s.len() == 2).is_some();
 +   |                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|s| s.len() == 2)`
 +
 +error: called `is_some()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_some.rs:123:26
 +   |
 +LL |         let _ = v.iter().find(|x| deref_enough(**x)).is_some();
 +   |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|x| deref_enough(*x))`
 +
 +error: called `is_some()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_some.rs:124:26
 +   |
 +LL |         let _ = v.iter().find(|x: &&u32| deref_enough(**x)).is_some();
 +   |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|x: &u32| deref_enough(*x))`
 +
 +error: called `is_some()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_some.rs:127:26
 +   |
 +LL |         let _ = v.iter().find(|x| arg_no_deref(x)).is_some();
 +   |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|x| arg_no_deref(&x))`
 +
 +error: called `is_some()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_some.rs:129:26
 +   |
 +LL |         let _ = v.iter().find(|x: &&u32| arg_no_deref(x)).is_some();
 +   |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|x: &u32| arg_no_deref(&x))`
 +
 +error: called `is_some()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_some.rs:151:14
 +   |
 +LL |               .find(|v| v.inner_double.bar[0][0] == 2 && v.inner.bar[0] == 2)
 +   |  ______________^
 +LL | |             .is_some();
 +   | |______________________^ help: use `any()` instead: `any(|v| v.inner_double.bar[0][0] == 2 && v.inner.bar[0] == 2)`
 +
 +error: called `is_some()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_some.rs:165:29
 +   |
 +LL |         let _ = vfoo.iter().find(|v| v.inner[0].bar == 2).is_some();
 +   |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|v| v.inner[0].bar == 2)`
 +
 +error: called `is_some()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_some.rs:170:29
 +   |
 +LL |         let _ = vfoo.iter().find(|x| (**x)[0] == 9).is_some();
 +   |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|x| (**x)[0] == 9)`
 +
 +error: called `is_some()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_some.rs:183:29
 +   |
 +LL |         let _ = vfoo.iter().find(|v| v.by_ref(&v.bar)).is_some();
 +   |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|v| v.by_ref(&v.bar))`
 +
 +error: called `is_some()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_some.rs:187:55
 +   |
 +LL |         let _ = [&(&1, 2), &(&3, 4), &(&5, 4)].iter().find(|(&x, y)| x == *y).is_some();
 +   |                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|(&x, y)| x == *y)`
 +
 +error: called `is_some()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_some.rs:188:55
 +   |
 +LL |         let _ = [&(&1, 2), &(&3, 4), &(&5, 4)].iter().find(|&(&x, y)| x == *y).is_some();
 +   |                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|(&x, y)| x == *y)`
 +
- error: aborting due to 44 previous errors
 +error: called `is_some()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_some.rs:207:26
 +   |
 +LL |         let _ = v.iter().find(|s| s[0].is_empty()).is_some();
 +   |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|s| s[0].is_empty())`
 +
 +error: called `is_some()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_some.rs:208:26
 +   |
 +LL |         let _ = v.iter().find(|s| test_string_1(&s[0])).is_some();
 +   |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|s| test_string_1(&s[0]))`
 +
 +error: called `is_some()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_some.rs:217:26
 +   |
 +LL |         let _ = v.iter().find(|fp| fp.field.is_power_of_two()).is_some();
 +   |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|fp| fp.field.is_power_of_two())`
 +
 +error: called `is_some()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_some.rs:218:26
 +   |
 +LL |         let _ = v.iter().find(|fp| test_u32_1(fp.field)).is_some();
 +   |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|fp| test_u32_1(fp.field))`
 +
 +error: called `is_some()` after searching an `Iterator` with `find`
 +  --> $DIR/search_is_some_fixable_some.rs:219:26
 +   |
 +LL |         let _ = v.iter().find(|fp| test_u32_2(*fp.field)).is_some();
 +   |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|fp| test_u32_2(*fp.field))`
 +
++error: aborting due to 43 previous errors
 +
index c5ae3ff769b11bb8dd6513a95728fb16fb18d7d1,0000000000000000000000000000000000000000..7e3d357ae50dc6e43bae367593e0e1f79fba4fd1
mode 100644,000000..100644
--- /dev/null
@@@ -1,63 -1,0 +1,63 @@@
- fn do_stuff(vec: &mut Vec<u8>) {}
 +use std::iter::repeat;
 +
 +fn main() {
 +    resize_vector();
 +    extend_vector();
 +    mixed_extend_resize_vector();
 +}
 +
 +fn extend_vector() {
 +    // Extend with constant expression
 +    let len = 300;
 +    let mut vec1 = Vec::with_capacity(len);
 +    vec1.extend(repeat(0).take(len));
 +
 +    // Extend with len expression
 +    let mut vec2 = Vec::with_capacity(len - 10);
 +    vec2.extend(repeat(0).take(len - 10));
 +
 +    // Extend with mismatching expression should not be warned
 +    let mut vec3 = Vec::with_capacity(24322);
 +    vec3.extend(repeat(0).take(2));
 +}
 +
 +fn mixed_extend_resize_vector() {
 +    // Mismatching len
 +    let mut mismatching_len = Vec::with_capacity(30);
 +    mismatching_len.extend(repeat(0).take(40));
 +
 +    // Slow initialization
 +    let mut resized_vec = Vec::with_capacity(30);
 +    resized_vec.resize(30, 0);
 +
 +    let mut extend_vec = Vec::with_capacity(30);
 +    extend_vec.extend(repeat(0).take(30));
 +}
 +
 +fn resize_vector() {
 +    // Resize with constant expression
 +    let len = 300;
 +    let mut vec1 = Vec::with_capacity(len);
 +    vec1.resize(len, 0);
 +
 +    // Resize mismatch len
 +    let mut vec2 = Vec::with_capacity(200);
 +    vec2.resize(10, 0);
 +
 +    // Resize with len expression
 +    let mut vec3 = Vec::with_capacity(len - 10);
 +    vec3.resize(len - 10, 0);
 +
 +    // Reinitialization should be warned
 +    vec1 = Vec::with_capacity(10);
 +    vec1.resize(10, 0);
 +}
 +
++fn do_stuff(vec: &mut [u8]) {}
 +
 +fn extend_vector_with_manipulations_between() {
 +    let len = 300;
 +    let mut vec1: Vec<u8> = Vec::with_capacity(len);
 +    do_stuff(&mut vec1);
 +    vec1.extend(repeat(0).take(len));
 +}
index 2edb202892afcaf4c1b65a7b3e91337a8779f3b8,0000000000000000000000000000000000000000..21de19a26014755f493dff4dbf1927798c78aa70
mode 100644,000000..100644
--- /dev/null
@@@ -1,76 -1,0 +1,98 @@@
 +#![deny(clippy::trait_duplication_in_bounds)]
 +
++use std::collections::BTreeMap;
 +use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign};
 +
 +fn bad_foo<T: Clone + Default, Z: Copy>(arg0: T, arg1: Z)
 +where
 +    T: Clone,
 +    T: Default,
 +{
 +    unimplemented!();
 +}
 +
 +fn good_bar<T: Clone + Default>(arg: T) {
 +    unimplemented!();
 +}
 +
 +fn good_foo<T>(arg: T)
 +where
 +    T: Clone + Default,
 +{
 +    unimplemented!();
 +}
 +
 +fn good_foobar<T: Default>(arg: T)
 +where
 +    T: Clone,
 +{
 +    unimplemented!();
 +}
 +
 +trait T: Default {
 +    fn f()
 +    where
 +        Self: Default;
 +}
 +
 +trait U: Default {
 +    fn f()
 +    where
 +        Self: Clone;
 +}
 +
 +trait ZZ: Default {
 +    fn g();
 +    fn h();
 +    fn f()
 +    where
 +        Self: Default + Clone;
 +}
 +
 +trait BadTrait: Default + Clone {
 +    fn f()
 +    where
 +        Self: Default + Clone;
 +    fn g()
 +    where
 +        Self: Default;
 +    fn h()
 +    where
 +        Self: Copy;
 +}
 +
 +#[derive(Default, Clone)]
 +struct Life {}
 +
 +impl T for Life {
 +    // this should not warn
 +    fn f() {}
 +}
 +
 +impl U for Life {
 +    // this should not warn
 +    fn f() {}
 +}
 +
++// should not warn
++trait Iter: Iterator {
++    fn into_group_btreemap<K, V>(self) -> BTreeMap<K, Vec<V>>
++    where
++        Self: Iterator<Item = (K, V)> + Sized,
++        K: Ord + Eq,
++    {
++        unimplemented!();
++    }
++}
++
++struct Foo {}
++
++trait FooIter: Iterator<Item = Foo> {
++    fn bar()
++    where
++        Self: Iterator<Item = Foo>,
++    {
++    }
++}
++
 +fn main() {}
index e0c7a7ec618ed932223b8fb8a17f3e5ca61b0eab,0000000000000000000000000000000000000000..6f8c8e47dfbf1fe56589a06f80017513e69167e8
mode 100644,000000..100644
--- /dev/null
@@@ -1,63 -1,0 +1,71 @@@
-   --> $DIR/trait_duplication_in_bounds.rs:5:15
 +error: this trait bound is already specified in the where clause
-   --> $DIR/trait_duplication_in_bounds.rs:5:23
++  --> $DIR/trait_duplication_in_bounds.rs:6:15
 +   |
 +LL | fn bad_foo<T: Clone + Default, Z: Copy>(arg0: T, arg1: Z)
 +   |               ^^^^^
 +   |
 +note: the lint level is defined here
 +  --> $DIR/trait_duplication_in_bounds.rs:1:9
 +   |
 +LL | #![deny(clippy::trait_duplication_in_bounds)]
 +   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 +   = help: consider removing this trait bound
 +
 +error: this trait bound is already specified in the where clause
-   --> $DIR/trait_duplication_in_bounds.rs:34:15
++  --> $DIR/trait_duplication_in_bounds.rs:6:23
 +   |
 +LL | fn bad_foo<T: Clone + Default, Z: Copy>(arg0: T, arg1: Z)
 +   |                       ^^^^^^^
 +   |
 +   = help: consider removing this trait bound
 +
 +error: this trait bound is already specified in trait declaration
-   --> $DIR/trait_duplication_in_bounds.rs:48:15
++  --> $DIR/trait_duplication_in_bounds.rs:35:15
 +   |
 +LL |         Self: Default;
 +   |               ^^^^^^^
 +   |
 +   = help: consider removing this trait bound
 +
 +error: this trait bound is already specified in trait declaration
-   --> $DIR/trait_duplication_in_bounds.rs:54:15
++  --> $DIR/trait_duplication_in_bounds.rs:49:15
 +   |
 +LL |         Self: Default + Clone;
 +   |               ^^^^^^^
 +   |
 +   = help: consider removing this trait bound
 +
 +error: this trait bound is already specified in trait declaration
-   --> $DIR/trait_duplication_in_bounds.rs:54:25
++  --> $DIR/trait_duplication_in_bounds.rs:55:15
 +   |
 +LL |         Self: Default + Clone;
 +   |               ^^^^^^^
 +   |
 +   = help: consider removing this trait bound
 +
 +error: this trait bound is already specified in trait declaration
-   --> $DIR/trait_duplication_in_bounds.rs:57:15
++  --> $DIR/trait_duplication_in_bounds.rs:55:25
 +   |
 +LL |         Self: Default + Clone;
 +   |                         ^^^^^
 +   |
 +   = help: consider removing this trait bound
 +
 +error: this trait bound is already specified in trait declaration
- error: aborting due to 7 previous errors
++  --> $DIR/trait_duplication_in_bounds.rs:58:15
 +   |
 +LL |         Self: Default;
 +   |               ^^^^^^^
 +   |
 +   = help: consider removing this trait bound
 +
++error: this trait bound is already specified in trait declaration
++  --> $DIR/trait_duplication_in_bounds.rs:93:15
++   |
++LL |         Self: Iterator<Item = Foo>,
++   |               ^^^^^^^^^^^^^^^^^^^^
++   |
++   = help: consider removing this trait bound
++
++error: aborting due to 8 previous errors
 +
index e8f2fb46665924848e113fa3a5ee4b2859714c0a,0000000000000000000000000000000000000000..b77c19f2ba5961e30409af2c95dd9640978f9ba3
mode 100644,000000..100644
--- /dev/null
@@@ -1,26 -1,0 +1,33 @@@
 +#![warn(clippy::unnecessary_cast)]
 +#![allow(clippy::no_effect)]
 +
++#[rustfmt::skip]
 +fn main() {
 +    // Test cast_unnecessary
 +    1i32 as i32;
 +    1f32 as f32;
 +    false as bool;
 +    &1i32 as &i32;
 +
++    -1_i32 as i32;
++    - 1_i32 as i32;
++    -1f32 as f32;
++    1_i32 as i32;
++    1_f32 as f32;
++
 +    // macro version
 +    macro_rules! foo {
 +        ($a:ident, $b:ident) => {
 +            #[allow(unused)]
 +            pub fn $a() -> $b {
 +                1 as $b
 +            }
 +        };
 +    }
 +    foo!(a, i32);
 +    foo!(b, f32);
 +    foo!(c, f64);
 +
 +    // do not lint cast to cfg-dependant type
 +    1 as std::os::raw::c_char;
 +}
index 70aa448af68ee4774dc0a0d4762f6e20bb538baa,0000000000000000000000000000000000000000..a5a93c6110c6a0233f7b8304ceaebb730f878b15
mode 100644,000000..100644
--- /dev/null
@@@ -1,22 -1,0 +1,52 @@@
-   --> $DIR/unnecessary_cast.rs:6:5
 +error: casting integer literal to `i32` is unnecessary
-   --> $DIR/unnecessary_cast.rs:7:5
++  --> $DIR/unnecessary_cast.rs:7:5
 +   |
 +LL |     1i32 as i32;
 +   |     ^^^^^^^^^^^ help: try: `1_i32`
 +   |
 +   = note: `-D clippy::unnecessary-cast` implied by `-D warnings`
 +
 +error: casting float literal to `f32` is unnecessary
-   --> $DIR/unnecessary_cast.rs:8:5
++  --> $DIR/unnecessary_cast.rs:8:5
 +   |
 +LL |     1f32 as f32;
 +   |     ^^^^^^^^^^^ help: try: `1_f32`
 +
 +error: casting to the same type is unnecessary (`bool` -> `bool`)
- error: aborting due to 3 previous errors
++  --> $DIR/unnecessary_cast.rs:9:5
 +   |
 +LL |     false as bool;
 +   |     ^^^^^^^^^^^^^ help: try: `false`
 +
++error: casting integer literal to `i32` is unnecessary
++  --> $DIR/unnecessary_cast.rs:12:5
++   |
++LL |     -1_i32 as i32;
++   |     ^^^^^^^^^^^^^ help: try: `-1_i32`
++
++error: casting integer literal to `i32` is unnecessary
++  --> $DIR/unnecessary_cast.rs:13:5
++   |
++LL |     - 1_i32 as i32;
++   |     ^^^^^^^^^^^^^^ help: try: `- 1_i32`
++
++error: casting float literal to `f32` is unnecessary
++  --> $DIR/unnecessary_cast.rs:14:5
++   |
++LL |     -1f32 as f32;
++   |     ^^^^^^^^^^^^ help: try: `-1_f32`
++
++error: casting integer literal to `i32` is unnecessary
++  --> $DIR/unnecessary_cast.rs:15:5
++   |
++LL |     1_i32 as i32;
++   |     ^^^^^^^^^^^^ help: try: `1_i32`
++
++error: casting float literal to `f32` is unnecessary
++  --> $DIR/unnecessary_cast.rs:16:5
++   |
++LL |     1_f32 as f32;
++   |     ^^^^^^^^^^^^ help: try: `1_f32`
++
++error: aborting due to 8 previous errors
 +
index e356f13d087b1fcdeffbb7a3c4f15d52b55b183e,0000000000000000000000000000000000000000..e431661d180deb443298780b3445becb2bd1fd2e
mode 100644,000000..100644
--- /dev/null
@@@ -1,135 -1,0 +1,135 @@@
-     #[allow(unused_parens, clippy::double_parens)]
 +// run-rustfix
 +
 +#![deny(clippy::useless_asref)]
 +
 +use std::fmt::Debug;
 +
 +struct FakeAsRef;
 +
 +#[allow(clippy::should_implement_trait)]
 +impl FakeAsRef {
 +    fn as_ref(&self) -> &Self {
 +        self
 +    }
 +}
 +
 +struct MoreRef;
 +
 +impl<'a, 'b, 'c> AsRef<&'a &'b &'c MoreRef> for MoreRef {
 +    fn as_ref(&self) -> &&'a &'b &'c MoreRef {
 +        &&&&MoreRef
 +    }
 +}
 +
 +fn foo_rstr(x: &str) {
 +    println!("{:?}", x);
 +}
 +fn foo_rslice(x: &[i32]) {
 +    println!("{:?}", x);
 +}
 +fn foo_mrslice(x: &mut [i32]) {
 +    println!("{:?}", x);
 +}
 +fn foo_rrrrmr(_: &&&&MoreRef) {
 +    println!("so many refs");
 +}
 +
 +fn not_ok() {
 +    let rstr: &str = "hello";
 +    let mut mrslice: &mut [i32] = &mut [1, 2, 3];
 +
 +    {
 +        let rslice: &[i32] = &*mrslice;
 +        foo_rstr(rstr);
 +        foo_rstr(rstr);
 +        foo_rslice(rslice);
 +        foo_rslice(rslice);
 +    }
 +    {
 +        foo_mrslice(mrslice);
 +        foo_mrslice(mrslice);
 +        foo_rslice(mrslice);
 +        foo_rslice(mrslice);
 +    }
 +
 +    {
 +        let rrrrrstr = &&&&rstr;
 +        let rrrrrslice = &&&&&*mrslice;
 +        foo_rslice(rrrrrslice);
 +        foo_rslice(rrrrrslice);
 +        foo_rstr(rrrrrstr);
 +        foo_rstr(rrrrrstr);
 +    }
 +    {
 +        let mrrrrrslice = &mut &mut &mut &mut mrslice;
 +        foo_mrslice(mrrrrrslice);
 +        foo_mrslice(mrrrrrslice);
 +        foo_rslice(mrrrrrslice);
 +        foo_rslice(mrrrrrslice);
 +    }
++    #[allow(unused_parens, clippy::double_parens, clippy::needless_borrow)]
 +    foo_rrrrmr((&&&&MoreRef));
 +
 +    generic_not_ok(mrslice);
 +    generic_ok(mrslice);
 +}
 +
 +fn ok() {
 +    let string = "hello".to_owned();
 +    let mut arr = [1, 2, 3];
 +    let mut vec = vec![1, 2, 3];
 +
 +    {
 +        foo_rstr(string.as_ref());
 +        foo_rslice(arr.as_ref());
 +        foo_rslice(vec.as_ref());
 +    }
 +    {
 +        foo_mrslice(arr.as_mut());
 +        foo_mrslice(vec.as_mut());
 +    }
 +
 +    {
 +        let rrrrstring = &&&&string;
 +        let rrrrarr = &&&&arr;
 +        let rrrrvec = &&&&vec;
 +        foo_rstr(rrrrstring.as_ref());
 +        foo_rslice(rrrrarr.as_ref());
 +        foo_rslice(rrrrvec.as_ref());
 +    }
 +    {
 +        let mrrrrarr = &mut &mut &mut &mut arr;
 +        let mrrrrvec = &mut &mut &mut &mut vec;
 +        foo_mrslice(mrrrrarr.as_mut());
 +        foo_mrslice(mrrrrvec.as_mut());
 +    }
 +    FakeAsRef.as_ref();
 +    foo_rrrrmr(MoreRef.as_ref());
 +
 +    generic_not_ok(arr.as_mut());
 +    generic_ok(&mut arr);
 +}
 +
 +fn foo_mrt<T: Debug + ?Sized>(t: &mut T) {
 +    println!("{:?}", t);
 +}
 +fn foo_rt<T: Debug + ?Sized>(t: &T) {
 +    println!("{:?}", t);
 +}
 +
 +fn generic_not_ok<T: AsMut<T> + AsRef<T> + Debug + ?Sized>(mrt: &mut T) {
 +    foo_mrt(mrt);
 +    foo_mrt(mrt);
 +    foo_rt(mrt);
 +    foo_rt(mrt);
 +}
 +
 +fn generic_ok<U: AsMut<T> + AsRef<T> + ?Sized, T: Debug + ?Sized>(mru: &mut U) {
 +    foo_mrt(mru.as_mut());
 +    foo_rt(mru.as_ref());
 +}
 +
 +fn main() {
 +    not_ok();
 +    ok();
 +}
index 2a80291f5d837b4614de012ac60f9fb1d2b9b256,0000000000000000000000000000000000000000..6ae931d7aa4812097f77622589501baaaf846b92
mode 100644,000000..100644
--- /dev/null
@@@ -1,135 -1,0 +1,135 @@@
-     #[allow(unused_parens, clippy::double_parens)]
 +// run-rustfix
 +
 +#![deny(clippy::useless_asref)]
 +
 +use std::fmt::Debug;
 +
 +struct FakeAsRef;
 +
 +#[allow(clippy::should_implement_trait)]
 +impl FakeAsRef {
 +    fn as_ref(&self) -> &Self {
 +        self
 +    }
 +}
 +
 +struct MoreRef;
 +
 +impl<'a, 'b, 'c> AsRef<&'a &'b &'c MoreRef> for MoreRef {
 +    fn as_ref(&self) -> &&'a &'b &'c MoreRef {
 +        &&&&MoreRef
 +    }
 +}
 +
 +fn foo_rstr(x: &str) {
 +    println!("{:?}", x);
 +}
 +fn foo_rslice(x: &[i32]) {
 +    println!("{:?}", x);
 +}
 +fn foo_mrslice(x: &mut [i32]) {
 +    println!("{:?}", x);
 +}
 +fn foo_rrrrmr(_: &&&&MoreRef) {
 +    println!("so many refs");
 +}
 +
 +fn not_ok() {
 +    let rstr: &str = "hello";
 +    let mut mrslice: &mut [i32] = &mut [1, 2, 3];
 +
 +    {
 +        let rslice: &[i32] = &*mrslice;
 +        foo_rstr(rstr.as_ref());
 +        foo_rstr(rstr);
 +        foo_rslice(rslice.as_ref());
 +        foo_rslice(rslice);
 +    }
 +    {
 +        foo_mrslice(mrslice.as_mut());
 +        foo_mrslice(mrslice);
 +        foo_rslice(mrslice.as_ref());
 +        foo_rslice(mrslice);
 +    }
 +
 +    {
 +        let rrrrrstr = &&&&rstr;
 +        let rrrrrslice = &&&&&*mrslice;
 +        foo_rslice(rrrrrslice.as_ref());
 +        foo_rslice(rrrrrslice);
 +        foo_rstr(rrrrrstr.as_ref());
 +        foo_rstr(rrrrrstr);
 +    }
 +    {
 +        let mrrrrrslice = &mut &mut &mut &mut mrslice;
 +        foo_mrslice(mrrrrrslice.as_mut());
 +        foo_mrslice(mrrrrrslice);
 +        foo_rslice(mrrrrrslice.as_ref());
 +        foo_rslice(mrrrrrslice);
 +    }
++    #[allow(unused_parens, clippy::double_parens, clippy::needless_borrow)]
 +    foo_rrrrmr((&&&&MoreRef).as_ref());
 +
 +    generic_not_ok(mrslice);
 +    generic_ok(mrslice);
 +}
 +
 +fn ok() {
 +    let string = "hello".to_owned();
 +    let mut arr = [1, 2, 3];
 +    let mut vec = vec![1, 2, 3];
 +
 +    {
 +        foo_rstr(string.as_ref());
 +        foo_rslice(arr.as_ref());
 +        foo_rslice(vec.as_ref());
 +    }
 +    {
 +        foo_mrslice(arr.as_mut());
 +        foo_mrslice(vec.as_mut());
 +    }
 +
 +    {
 +        let rrrrstring = &&&&string;
 +        let rrrrarr = &&&&arr;
 +        let rrrrvec = &&&&vec;
 +        foo_rstr(rrrrstring.as_ref());
 +        foo_rslice(rrrrarr.as_ref());
 +        foo_rslice(rrrrvec.as_ref());
 +    }
 +    {
 +        let mrrrrarr = &mut &mut &mut &mut arr;
 +        let mrrrrvec = &mut &mut &mut &mut vec;
 +        foo_mrslice(mrrrrarr.as_mut());
 +        foo_mrslice(mrrrrvec.as_mut());
 +    }
 +    FakeAsRef.as_ref();
 +    foo_rrrrmr(MoreRef.as_ref());
 +
 +    generic_not_ok(arr.as_mut());
 +    generic_ok(&mut arr);
 +}
 +
 +fn foo_mrt<T: Debug + ?Sized>(t: &mut T) {
 +    println!("{:?}", t);
 +}
 +fn foo_rt<T: Debug + ?Sized>(t: &T) {
 +    println!("{:?}", t);
 +}
 +
 +fn generic_not_ok<T: AsMut<T> + AsRef<T> + Debug + ?Sized>(mrt: &mut T) {
 +    foo_mrt(mrt.as_mut());
 +    foo_mrt(mrt);
 +    foo_rt(mrt.as_ref());
 +    foo_rt(mrt);
 +}
 +
 +fn generic_ok<U: AsMut<T> + AsRef<T> + ?Sized, T: Debug + ?Sized>(mru: &mut U) {
 +    foo_mrt(mru.as_mut());
 +    foo_rt(mru.as_ref());
 +}
 +
 +fn main() {
 +    not_ok();
 +    ok();
 +}
index 0a127858defdfefe997701fa396f34fcbfadeabf,0000000000000000000000000000000000000000..4466917441162f49b14ae65722cac9f1a7ae6378
mode 100644,000000..100644
--- /dev/null
@@@ -1,43 -1,0 +1,43 @@@
-     write!(&mut v, "Hello");
-     writeln!(&mut v, "Hello");
 +#![allow(unused_must_use)]
 +#![warn(clippy::write_literal)]
 +
 +use std::io::Write;
 +
 +fn main() {
 +    let mut v = Vec::new();
 +
 +    // these should be fine
-     writeln!(&mut v, "Hello {}", world);
-     writeln!(&mut v, "Hello {world}", world = world);
-     writeln!(&mut v, "3 in hex is {:X}", 3);
-     writeln!(&mut v, "2 + 1 = {:.4}", 3);
-     writeln!(&mut v, "2 + 1 = {:5.4}", 3);
-     writeln!(&mut v, "Debug test {:?}", "hello, world");
-     writeln!(&mut v, "{0:8} {1:>8}", "hello", "world");
-     writeln!(&mut v, "{1:8} {0:>8}", "hello", "world");
-     writeln!(&mut v, "{foo:8} {bar:>8}", foo = "hello", bar = "world");
-     writeln!(&mut v, "{bar:8} {foo:>8}", foo = "hello", bar = "world");
-     writeln!(&mut v, "{number:>width$}", number = 1, width = 6);
-     writeln!(&mut v, "{number:>0width$}", number = 1, width = 6);
-     writeln!(&mut v, "{} of {:b} people know binary, the other half doesn't", 1, 2);
-     writeln!(&mut v, "10 / 4 is {}", 2.5);
-     writeln!(&mut v, "2 + 1 = {}", 3);
++    write!(v, "Hello");
++    writeln!(v, "Hello");
 +    let world = "world";
-     write!(&mut v, "Hello {}", "world");
-     writeln!(&mut v, "Hello {} {}", world, "world");
-     writeln!(&mut v, "Hello {}", "world");
++    writeln!(v, "Hello {}", world);
++    writeln!(v, "Hello {world}", world = world);
++    writeln!(v, "3 in hex is {:X}", 3);
++    writeln!(v, "2 + 1 = {:.4}", 3);
++    writeln!(v, "2 + 1 = {:5.4}", 3);
++    writeln!(v, "Debug test {:?}", "hello, world");
++    writeln!(v, "{0:8} {1:>8}", "hello", "world");
++    writeln!(v, "{1:8} {0:>8}", "hello", "world");
++    writeln!(v, "{foo:8} {bar:>8}", foo = "hello", bar = "world");
++    writeln!(v, "{bar:8} {foo:>8}", foo = "hello", bar = "world");
++    writeln!(v, "{number:>width$}", number = 1, width = 6);
++    writeln!(v, "{number:>0width$}", number = 1, width = 6);
++    writeln!(v, "{} of {:b} people know binary, the other half doesn't", 1, 2);
++    writeln!(v, "10 / 4 is {}", 2.5);
++    writeln!(v, "2 + 1 = {}", 3);
 +
 +    // these should throw warnings
-     writeln!(&mut v, "{0} {1}", "hello", "world");
-     writeln!(&mut v, "{1} {0}", "hello", "world");
++    write!(v, "Hello {}", "world");
++    writeln!(v, "Hello {} {}", world, "world");
++    writeln!(v, "Hello {}", "world");
 +
 +    // positional args don't change the fact
 +    // that we're using a literal -- this should
 +    // throw a warning
-     writeln!(&mut v, "{foo} {bar}", foo = "hello", bar = "world");
-     writeln!(&mut v, "{bar} {foo}", foo = "hello", bar = "world");
++    writeln!(v, "{0} {1}", "hello", "world");
++    writeln!(v, "{1} {0}", "hello", "world");
 +
 +    // named args shouldn't change anything either
++    writeln!(v, "{foo} {bar}", foo = "hello", bar = "world");
++    writeln!(v, "{bar} {foo}", foo = "hello", bar = "world");
 +}
index e0297c0023156ad7ef1952718fecf1a628de87be,0000000000000000000000000000000000000000..593e9493ec5904edacfc7eafd6277121141ac6a8
mode 100644,000000..100644
--- /dev/null
@@@ -1,135 -1,0 +1,135 @@@
-   --> $DIR/write_literal.rs:30:32
 +error: literal with an empty format string
- LL |     write!(&mut v, "Hello {}", "world");
-    |                                ^^^^^^^
++  --> $DIR/write_literal.rs:30:27
 +   |
- LL -     write!(&mut v, "Hello {}", "world");
- LL +     write!(&mut v, "Hello world");
++LL |     write!(v, "Hello {}", "world");
++   |                           ^^^^^^^
 +   |
 +   = note: `-D clippy::write-literal` implied by `-D warnings`
 +help: try this
 +   |
-   --> $DIR/write_literal.rs:31:44
++LL -     write!(v, "Hello {}", "world");
++LL +     write!(v, "Hello world");
 +   | 
 +
 +error: literal with an empty format string
- LL |     writeln!(&mut v, "Hello {} {}", world, "world");
-    |                                            ^^^^^^^
++  --> $DIR/write_literal.rs:31:39
 +   |
- LL -     writeln!(&mut v, "Hello {} {}", world, "world");
- LL +     writeln!(&mut v, "Hello {} world", world);
++LL |     writeln!(v, "Hello {} {}", world, "world");
++   |                                       ^^^^^^^
 +   |
 +help: try this
 +   |
-   --> $DIR/write_literal.rs:32:34
++LL -     writeln!(v, "Hello {} {}", world, "world");
++LL +     writeln!(v, "Hello {} world", world);
 +   | 
 +
 +error: literal with an empty format string
- LL |     writeln!(&mut v, "Hello {}", "world");
-    |                                  ^^^^^^^
++  --> $DIR/write_literal.rs:32:29
 +   |
- LL -     writeln!(&mut v, "Hello {}", "world");
- LL +     writeln!(&mut v, "Hello world");
++LL |     writeln!(v, "Hello {}", "world");
++   |                             ^^^^^^^
 +   |
 +help: try this
 +   |
-   --> $DIR/write_literal.rs:37:33
++LL -     writeln!(v, "Hello {}", "world");
++LL +     writeln!(v, "Hello world");
 +   | 
 +
 +error: literal with an empty format string
- LL |     writeln!(&mut v, "{0} {1}", "hello", "world");
-    |                                 ^^^^^^^
++  --> $DIR/write_literal.rs:37:28
 +   |
- LL -     writeln!(&mut v, "{0} {1}", "hello", "world");
- LL +     writeln!(&mut v, "hello {1}", "world");
++LL |     writeln!(v, "{0} {1}", "hello", "world");
++   |                            ^^^^^^^
 +   |
 +help: try this
 +   |
-   --> $DIR/write_literal.rs:37:42
++LL -     writeln!(v, "{0} {1}", "hello", "world");
++LL +     writeln!(v, "hello {1}", "world");
 +   | 
 +
 +error: literal with an empty format string
- LL |     writeln!(&mut v, "{0} {1}", "hello", "world");
-    |                                          ^^^^^^^
++  --> $DIR/write_literal.rs:37:37
 +   |
- LL -     writeln!(&mut v, "{0} {1}", "hello", "world");
- LL +     writeln!(&mut v, "{0} world", "hello");
++LL |     writeln!(v, "{0} {1}", "hello", "world");
++   |                                     ^^^^^^^
 +   |
 +help: try this
 +   |
-   --> $DIR/write_literal.rs:38:33
++LL -     writeln!(v, "{0} {1}", "hello", "world");
++LL +     writeln!(v, "{0} world", "hello");
 +   | 
 +
 +error: literal with an empty format string
- LL |     writeln!(&mut v, "{1} {0}", "hello", "world");
-    |                                 ^^^^^^^
++  --> $DIR/write_literal.rs:38:28
 +   |
- LL -     writeln!(&mut v, "{1} {0}", "hello", "world");
- LL +     writeln!(&mut v, "{1} hello", "world");
++LL |     writeln!(v, "{1} {0}", "hello", "world");
++   |                            ^^^^^^^
 +   |
 +help: try this
 +   |
-   --> $DIR/write_literal.rs:38:42
++LL -     writeln!(v, "{1} {0}", "hello", "world");
++LL +     writeln!(v, "{1} hello", "world");
 +   | 
 +
 +error: literal with an empty format string
- LL |     writeln!(&mut v, "{1} {0}", "hello", "world");
-    |                                          ^^^^^^^
++  --> $DIR/write_literal.rs:38:37
 +   |
- LL -     writeln!(&mut v, "{1} {0}", "hello", "world");
- LL +     writeln!(&mut v, "world {0}", "hello");
++LL |     writeln!(v, "{1} {0}", "hello", "world");
++   |                                     ^^^^^^^
 +   |
 +help: try this
 +   |
-   --> $DIR/write_literal.rs:41:37
++LL -     writeln!(v, "{1} {0}", "hello", "world");
++LL +     writeln!(v, "world {0}", "hello");
 +   | 
 +
 +error: literal with an empty format string
- LL |     writeln!(&mut v, "{foo} {bar}", foo = "hello", bar = "world");
-    |                                     ^^^^^^^^^^^^^
++  --> $DIR/write_literal.rs:41:32
 +   |
- LL -     writeln!(&mut v, "{foo} {bar}", foo = "hello", bar = "world");
- LL +     writeln!(&mut v, "hello {bar}", bar = "world");
++LL |     writeln!(v, "{foo} {bar}", foo = "hello", bar = "world");
++   |                                ^^^^^^^^^^^^^
 +   |
 +help: try this
 +   |
-   --> $DIR/write_literal.rs:41:52
++LL -     writeln!(v, "{foo} {bar}", foo = "hello", bar = "world");
++LL +     writeln!(v, "hello {bar}", bar = "world");
 +   | 
 +
 +error: literal with an empty format string
- LL |     writeln!(&mut v, "{foo} {bar}", foo = "hello", bar = "world");
-    |                                                    ^^^^^^^^^^^^^
++  --> $DIR/write_literal.rs:41:47
 +   |
- LL -     writeln!(&mut v, "{foo} {bar}", foo = "hello", bar = "world");
- LL +     writeln!(&mut v, "{foo} world", foo = "hello");
++LL |     writeln!(v, "{foo} {bar}", foo = "hello", bar = "world");
++   |                                               ^^^^^^^^^^^^^
 +   |
 +help: try this
 +   |
-   --> $DIR/write_literal.rs:42:37
++LL -     writeln!(v, "{foo} {bar}", foo = "hello", bar = "world");
++LL +     writeln!(v, "{foo} world", foo = "hello");
 +   | 
 +
 +error: literal with an empty format string
- LL |     writeln!(&mut v, "{bar} {foo}", foo = "hello", bar = "world");
-    |                                     ^^^^^^^^^^^^^
++  --> $DIR/write_literal.rs:42:32
 +   |
- LL -     writeln!(&mut v, "{bar} {foo}", foo = "hello", bar = "world");
- LL +     writeln!(&mut v, "{bar} hello", bar = "world");
++LL |     writeln!(v, "{bar} {foo}", foo = "hello", bar = "world");
++   |                                ^^^^^^^^^^^^^
 +   |
 +help: try this
 +   |
-   --> $DIR/write_literal.rs:42:52
++LL -     writeln!(v, "{bar} {foo}", foo = "hello", bar = "world");
++LL +     writeln!(v, "{bar} hello", bar = "world");
 +   | 
 +
 +error: literal with an empty format string
- LL |     writeln!(&mut v, "{bar} {foo}", foo = "hello", bar = "world");
-    |                                                    ^^^^^^^^^^^^^
++  --> $DIR/write_literal.rs:42:47
 +   |
- LL -     writeln!(&mut v, "{bar} {foo}", foo = "hello", bar = "world");
- LL +     writeln!(&mut v, "world {foo}", foo = "hello");
++LL |     writeln!(v, "{bar} {foo}", foo = "hello", bar = "world");
++   |                                               ^^^^^^^^^^^^^
 +   |
 +help: try this
 +   |
++LL -     writeln!(v, "{bar} {foo}", foo = "hello", bar = "world");
++LL +     writeln!(v, "world {foo}", foo = "hello");
 +   | 
 +
 +error: aborting due to 11 previous errors
 +
index f341e8215e1caff9491c8963b2275b63cf4d9a1b,0000000000000000000000000000000000000000..ba0d7be5eaa68dfe5234f0499db72cc8d759af99
mode 100644,000000..100644
--- /dev/null
@@@ -1,27 -1,0 +1,27 @@@
-     writeln!(&mut v, "{}", "{hello}");
-     writeln!(&mut v, r"{}", r"{hello}");
-     writeln!(&mut v, "{}", '\'');
-     writeln!(&mut v, "{}", '"');
-     writeln!(&mut v, r"{}", '"'); // don't lint
-     writeln!(&mut v, r"{}", '\'');
 +#![allow(unused_must_use)]
 +#![warn(clippy::write_literal)]
 +
 +use std::io::Write;
 +
 +fn main() {
 +    let mut v = Vec::new();
 +
-         &mut v,
++    writeln!(v, "{}", "{hello}");
++    writeln!(v, r"{}", r"{hello}");
++    writeln!(v, "{}", '\'');
++    writeln!(v, "{}", '"');
++    writeln!(v, r"{}", '"'); // don't lint
++    writeln!(v, r"{}", '\'');
 +    writeln!(
-         &mut v,
++        v,
 +        "some {}",
 +        "hello \
 +        world!"
 +    );
 +    writeln!(
++        v,
 +        "some {}\
 +        {} \\ {}",
 +        "1", "2", "3",
 +    );
 +}
index 73c6b88581329a0ca5658647de0474dbf902ceff,0000000000000000000000000000000000000000..fc40fbfa9e239b7ab02eed9b3d372484647a67cb
mode 100644,000000..100644
--- /dev/null
@@@ -1,112 -1,0 +1,112 @@@
-   --> $DIR/write_literal_2.rs:9:28
 +error: literal with an empty format string
- LL |     writeln!(&mut v, "{}", "{hello}");
-    |                            ^^^^^^^^^
++  --> $DIR/write_literal_2.rs:9:23
 +   |
- LL -     writeln!(&mut v, "{}", "{hello}");
- LL +     writeln!(&mut v, "{{hello}}");
++LL |     writeln!(v, "{}", "{hello}");
++   |                       ^^^^^^^^^
 +   |
 +   = note: `-D clippy::write-literal` implied by `-D warnings`
 +help: try this
 +   |
-   --> $DIR/write_literal_2.rs:10:29
++LL -     writeln!(v, "{}", "{hello}");
++LL +     writeln!(v, "{{hello}}");
 +   | 
 +
 +error: literal with an empty format string
- LL |     writeln!(&mut v, r"{}", r"{hello}");
-    |                             ^^^^^^^^^^
++  --> $DIR/write_literal_2.rs:10:24
 +   |
- LL -     writeln!(&mut v, r"{}", r"{hello}");
- LL +     writeln!(&mut v, r"{{hello}}");
++LL |     writeln!(v, r"{}", r"{hello}");
++   |                        ^^^^^^^^^^
 +   |
 +help: try this
 +   |
-   --> $DIR/write_literal_2.rs:11:28
++LL -     writeln!(v, r"{}", r"{hello}");
++LL +     writeln!(v, r"{{hello}}");
 +   | 
 +
 +error: literal with an empty format string
- LL |     writeln!(&mut v, "{}", '/'');
-    |                            ^^^^
++  --> $DIR/write_literal_2.rs:11:23
 +   |
- LL -     writeln!(&mut v, "{}", '/'');
- LL +     writeln!(&mut v, "'");
++LL |     writeln!(v, "{}", '/'');
++   |                       ^^^^
 +   |
 +help: try this
 +   |
-   --> $DIR/write_literal_2.rs:12:28
++LL -     writeln!(v, "{}", '/'');
++LL +     writeln!(v, "'");
 +   | 
 +
 +error: literal with an empty format string
- LL |     writeln!(&mut v, "{}", '"');
-    |                            ^^^
++  --> $DIR/write_literal_2.rs:12:23
 +   |
- LL -     writeln!(&mut v, "{}", '"');
- LL +     writeln!(&mut v, "/"");
++LL |     writeln!(v, "{}", '"');
++   |                       ^^^
 +   |
 +help: try this
 +   |
-   --> $DIR/write_literal_2.rs:14:29
++LL -     writeln!(v, "{}", '"');
++LL +     writeln!(v, "/"");
 +   | 
 +
 +error: literal with an empty format string
- LL |     writeln!(&mut v, r"{}", '/'');
-    |                             ^^^^
++  --> $DIR/write_literal_2.rs:14:24
 +   |
- LL -     writeln!(&mut v, r"{}", '/'');
- LL +     writeln!(&mut v, r"'");
++LL |     writeln!(v, r"{}", '/'');
++   |                        ^^^^
 +   |
 +help: try this
 +   |
++LL -     writeln!(v, r"{}", '/'');
++LL +     writeln!(v, r"'");
 +   | 
 +
 +error: literal with an empty format string
 +  --> $DIR/write_literal_2.rs:18:9
 +   |
 +LL | /         "hello /
 +LL | |         world!"
 +   | |_______________^
 +   |
 +help: try this
 +   |
 +LL ~         "some hello /
 +LL ~         world!"
 +   |
 +
 +error: literal with an empty format string
 +  --> $DIR/write_literal_2.rs:25:9
 +   |
 +LL |         "1", "2", "3",
 +   |         ^^^
 +   |
 +help: try this
 +   |
 +LL ~         "some 1/
 +LL ~         {} / {}", "2", "3",
 +   |
 +
 +error: literal with an empty format string
 +  --> $DIR/write_literal_2.rs:25:14
 +   |
 +LL |         "1", "2", "3",
 +   |              ^^^
 +   |
 +help: try this
 +   |
 +LL ~         2 / {}",
 +LL ~         "1", "3",
 +   |
 +
 +error: literal with an empty format string
 +  --> $DIR/write_literal_2.rs:25:19
 +   |
 +LL |         "1", "2", "3",
 +   |                   ^^^
 +   |
 +help: try this
 +   |
 +LL ~         {} / 3",
 +LL ~         "1", "2",
 +   |
 +
 +error: aborting due to 9 previous errors
 +
index 1c1b1b58402e830393a9f2e57a43918d414f6f85,0000000000000000000000000000000000000000..446d6914d3461205a185daf7f71f6fabf399e3c7
mode 100644,000000..100644
--- /dev/null
@@@ -1,59 -1,0 +1,59 @@@
-     write!(&mut v, "Hello\n");
-     write!(&mut v, "Hello {}\n", "world");
-     write!(&mut v, "Hello {} {}\n", "world", "#2");
-     write!(&mut v, "{}\n", 1265);
-     write!(&mut v, "\n");
 +// FIXME: Ideally these suggestions would be fixed via rustfix. Blocked by rust-lang/rust#53934
 +// // run-rustfix
 +
 +#![allow(clippy::write_literal)]
 +#![warn(clippy::write_with_newline)]
 +
 +use std::io::Write;
 +
 +fn main() {
 +    let mut v = Vec::new();
 +
 +    // These should fail
-     write!(&mut v, "");
-     write!(&mut v, "Hello");
-     writeln!(&mut v, "Hello");
-     writeln!(&mut v, "Hello\n");
-     writeln!(&mut v, "Hello {}\n", "world");
-     write!(&mut v, "Issue\n{}", 1265);
-     write!(&mut v, "{}", 1265);
-     write!(&mut v, "\n{}", 1275);
-     write!(&mut v, "\n\n");
-     write!(&mut v, "like eof\n\n");
-     write!(&mut v, "Hello {} {}\n\n", "world", "#2");
-     writeln!(&mut v, "\ndon't\nwarn\nfor\nmultiple\nnewlines\n"); // #3126
-     writeln!(&mut v, "\nbla\n\n"); // #3126
++    write!(v, "Hello\n");
++    write!(v, "Hello {}\n", "world");
++    write!(v, "Hello {} {}\n", "world", "#2");
++    write!(v, "{}\n", 1265);
++    write!(v, "\n");
 +
 +    // These should be fine
-     write!(&mut v, "\\n"); // #3514
-     write!(&mut v, "\\\n"); // should fail
-     write!(&mut v, "\\\\n");
++    write!(v, "");
++    write!(v, "Hello");
++    writeln!(v, "Hello");
++    writeln!(v, "Hello\n");
++    writeln!(v, "Hello {}\n", "world");
++    write!(v, "Issue\n{}", 1265);
++    write!(v, "{}", 1265);
++    write!(v, "\n{}", 1275);
++    write!(v, "\n\n");
++    write!(v, "like eof\n\n");
++    write!(v, "Hello {} {}\n\n", "world", "#2");
++    writeln!(v, "\ndon't\nwarn\nfor\nmultiple\nnewlines\n"); // #3126
++    writeln!(v, "\nbla\n\n"); // #3126
 +
 +    // Escaping
-     write!(&mut v, r"\n"); // #3778
++    write!(v, "\\n"); // #3514
++    write!(v, "\\\n"); // should fail
++    write!(v, "\\\\n");
 +
 +    // Raw strings
-         &mut v,
++    write!(v, r"\n"); // #3778
 +
 +    // Literal newlines should also fail
 +    write!(
-         &mut v,
++        v,
 +        "
 +"
 +    );
 +    write!(
-     write!(&mut v, "\r\n");
-     write!(&mut v, "foo\r\n");
-     write!(&mut v, "\\r\n"); //~ ERROR
-     write!(&mut v, "foo\rbar\n");
++        v,
 +        r"
 +"
 +    );
 +
 +    // Don't warn on CRLF (#4208)
++    write!(v, "\r\n");
++    write!(v, "foo\r\n");
++    write!(v, "\\r\n"); //~ ERROR
++    write!(v, "foo\rbar\n");
 +}
index 186459e50b64ce6a118bd5b4c3f9a1a90c565829,0000000000000000000000000000000000000000..3314a2a6e242089ff826a4d412cff4185f0e2311
mode 100644,000000..100644
--- /dev/null
@@@ -1,133 -1,0 +1,133 @@@
- LL |     write!(&mut v, "Hello/n");
-    |     ^^^^^^^^^^^^^^^^^^^^^^^^^
 +error: using `write!()` with a format string that ends in a single newline
 +  --> $DIR/write_with_newline.rs:13:5
 +   |
- LL -     write!(&mut v, "Hello/n");
- LL +     writeln!(&mut v, "Hello");
++LL |     write!(v, "Hello/n");
++   |     ^^^^^^^^^^^^^^^^^^^^
 +   |
 +   = note: `-D clippy::write-with-newline` implied by `-D warnings`
 +help: use `writeln!()` instead
 +   |
- LL |     write!(&mut v, "Hello {}/n", "world");
-    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
++LL -     write!(v, "Hello/n");
++LL +     writeln!(v, "Hello");
 +   | 
 +
 +error: using `write!()` with a format string that ends in a single newline
 +  --> $DIR/write_with_newline.rs:14:5
 +   |
- LL -     write!(&mut v, "Hello {}/n", "world");
- LL +     writeln!(&mut v, "Hello {}", "world");
++LL |     write!(v, "Hello {}/n", "world");
++   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 +   |
 +help: use `writeln!()` instead
 +   |
- LL |     write!(&mut v, "Hello {} {}/n", "world", "#2");
-    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
++LL -     write!(v, "Hello {}/n", "world");
++LL +     writeln!(v, "Hello {}", "world");
 +   | 
 +
 +error: using `write!()` with a format string that ends in a single newline
 +  --> $DIR/write_with_newline.rs:15:5
 +   |
- LL -     write!(&mut v, "Hello {} {}/n", "world", "#2");
- LL +     writeln!(&mut v, "Hello {} {}", "world", "#2");
++LL |     write!(v, "Hello {} {}/n", "world", "#2");
++   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 +   |
 +help: use `writeln!()` instead
 +   |
- LL |     write!(&mut v, "{}/n", 1265);
-    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
++LL -     write!(v, "Hello {} {}/n", "world", "#2");
++LL +     writeln!(v, "Hello {} {}", "world", "#2");
 +   | 
 +
 +error: using `write!()` with a format string that ends in a single newline
 +  --> $DIR/write_with_newline.rs:16:5
 +   |
- LL -     write!(&mut v, "{}/n", 1265);
- LL +     writeln!(&mut v, "{}", 1265);
++LL |     write!(v, "{}/n", 1265);
++   |     ^^^^^^^^^^^^^^^^^^^^^^^
 +   |
 +help: use `writeln!()` instead
 +   |
- LL |     write!(&mut v, "/n");
-    |     ^^^^^^^^^^^^^^^^^^^^
++LL -     write!(v, "{}/n", 1265);
++LL +     writeln!(v, "{}", 1265);
 +   | 
 +
 +error: using `write!()` with a format string that ends in a single newline
 +  --> $DIR/write_with_newline.rs:17:5
 +   |
- LL -     write!(&mut v, "/n");
- LL +     writeln!(&mut v);
++LL |     write!(v, "/n");
++   |     ^^^^^^^^^^^^^^^
 +   |
 +help: use `writeln!()` instead
 +   |
- LL |     write!(&mut v, "//n"); // should fail
-    |     ^^^^^^^^^^^^^^^^^^^^^^
++LL -     write!(v, "/n");
++LL +     writeln!(v);
 +   | 
 +
 +error: using `write!()` with a format string that ends in a single newline
 +  --> $DIR/write_with_newline.rs:36:5
 +   |
- LL -     write!(&mut v, "//n"); // should fail
- LL +     writeln!(&mut v, "/"); // should fail
++LL |     write!(v, "//n"); // should fail
++   |     ^^^^^^^^^^^^^^^^^
 +   |
 +help: use `writeln!()` instead
 +   |
- LL | |         &mut v,
++LL -     write!(v, "//n"); // should fail
++LL +     writeln!(v, "/"); // should fail
 +   | 
 +
 +error: using `write!()` with a format string that ends in a single newline
 +  --> $DIR/write_with_newline.rs:43:5
 +   |
 +LL | /     write!(
- LL |         &mut v,
++LL | |         v,
 +LL | |         "
 +LL | | "
 +LL | |     );
 +   | |_____^
 +   |
 +help: use `writeln!()` instead
 +   |
 +LL ~     writeln!(
- LL | |         &mut v,
++LL |         v,
 +LL ~         ""
 +   |
 +
 +error: using `write!()` with a format string that ends in a single newline
 +  --> $DIR/write_with_newline.rs:48:5
 +   |
 +LL | /     write!(
- LL |         &mut v,
++LL | |         v,
 +LL | |         r"
 +LL | | "
 +LL | |     );
 +   | |_____^
 +   |
 +help: use `writeln!()` instead
 +   |
 +LL ~     writeln!(
- LL |     write!(&mut v, "/r/n"); //~ ERROR
-    |     ^^^^^^^^^^^^^^^^^^^^^^^
++LL |         v,
 +LL ~         r""
 +   |
 +
 +error: using `write!()` with a format string that ends in a single newline
 +  --> $DIR/write_with_newline.rs:57:5
 +   |
- LL -     write!(&mut v, "/r/n"); //~ ERROR
- LL +     writeln!(&mut v, "/r"); //~ ERROR
++LL |     write!(v, "/r/n"); //~ ERROR
++   |     ^^^^^^^^^^^^^^^^^^
 +   |
 +help: use `writeln!()` instead
 +   |
- LL |     write!(&mut v, "foo/rbar/n");
-    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
++LL -     write!(v, "/r/n"); //~ ERROR
++LL +     writeln!(v, "/r"); //~ ERROR
 +   | 
 +
 +error: using `write!()` with a format string that ends in a single newline
 +  --> $DIR/write_with_newline.rs:58:5
 +   |
- LL -     write!(&mut v, "foo/rbar/n");
- LL +     writeln!(&mut v, "foo/rbar");
++LL |     write!(v, "foo/rbar/n");
++   |     ^^^^^^^^^^^^^^^^^^^^^^^
 +   |
 +help: use `writeln!()` instead
 +   |
++LL -     write!(v, "foo/rbar/n");
++LL +     writeln!(v, "foo/rbar");
 +   | 
 +
 +error: aborting due to 10 previous errors
 +
index c3ac15b03751cb62852d7594e9440990b039b8d1,0000000000000000000000000000000000000000..e7d94acd130d67b2877a6bf45c4a9b2351785bbf
mode 100644,000000..100644
--- /dev/null
@@@ -1,20 -1,0 +1,20 @@@
-     writeln!(&mut v);
 +// run-rustfix
 +
 +#![allow(unused_must_use)]
 +#![warn(clippy::writeln_empty_string)]
 +use std::io::Write;
 +
 +fn main() {
 +    let mut v = Vec::new();
 +
 +    // These should fail
-     writeln!(&mut suggestion);
++    writeln!(v);
 +
 +    let mut suggestion = Vec::new();
-     writeln!(&mut v);
-     writeln!(&mut v, " ");
-     write!(&mut v, "");
++    writeln!(suggestion);
 +
 +    // These should be fine
++    writeln!(v);
++    writeln!(v, " ");
++    write!(v, "");
 +}
index 9a8894b6c0d3285b2a3a07ed6b7ecdaec4094658,0000000000000000000000000000000000000000..662c62f02116e64d4a21213bface9d73b8bb11d4
mode 100644,000000..100644
--- /dev/null
@@@ -1,20 -1,0 +1,20 @@@
-     writeln!(&mut v, "");
 +// run-rustfix
 +
 +#![allow(unused_must_use)]
 +#![warn(clippy::writeln_empty_string)]
 +use std::io::Write;
 +
 +fn main() {
 +    let mut v = Vec::new();
 +
 +    // These should fail
-     writeln!(&mut suggestion, "");
++    writeln!(v, "");
 +
 +    let mut suggestion = Vec::new();
-     writeln!(&mut v);
-     writeln!(&mut v, " ");
-     write!(&mut v, "");
++    writeln!(suggestion, "");
 +
 +    // These should be fine
++    writeln!(v);
++    writeln!(v, " ");
++    write!(v, "");
 +}
index 99635229b3e13eafc1f4bf2db210de1e677215a0,0000000000000000000000000000000000000000..ac65aadfc0e8926f4cf5d04dcde1f0906d5672e9
mode 100644,000000..100644
--- /dev/null
@@@ -1,16 -1,0 +1,16 @@@
- error: using `writeln!(&mut v, "")`
++error: using `writeln!(v, "")`
 +  --> $DIR/writeln_empty_string.rs:11:5
 +   |
- LL |     writeln!(&mut v, "");
-    |     ^^^^^^^^^^^^^^^^^^^^ help: replace it with: `writeln!(&mut v)`
++LL |     writeln!(v, "");
++   |     ^^^^^^^^^^^^^^^ help: replace it with: `writeln!(v)`
 +   |
 +   = note: `-D clippy::writeln-empty-string` implied by `-D warnings`
 +
- error: using `writeln!(&mut suggestion, "")`
++error: using `writeln!(suggestion, "")`
 +  --> $DIR/writeln_empty_string.rs:14:5
 +   |
- LL |     writeln!(&mut suggestion, "");
-    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `writeln!(&mut suggestion)`
++LL |     writeln!(suggestion, "");
++   |     ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `writeln!(suggestion)`
 +
 +error: aborting due to 2 previous errors
 +
index 5b7e61a349d979c08b68fc04e994c1b35f018e69,0000000000000000000000000000000000000000..83a200ca3c4f4d112999c1bf3ddfd9d40ebd6299
mode 100644,000000..100644
--- /dev/null
@@@ -1,611 -1,0 +1,616 @@@
 +<!DOCTYPE html>
 +<!--
 +Welcome to a Clippy's lint list, at least the source code of it. If you are
 +interested in contributing to this website checkout `util/gh-pages/index.html`
 +inside the rust-clippy repository.
 +
 +Otherwise, have a great day =^.^=
 +-->
 +<html lang="en">
 +<head>
 +    <meta charset="UTF-8"/>
 +    <meta name="viewport" content="width=device-width, initial-scale=1"/>
 +
 +    <title>Clippy Lints</title>
 +
 +    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css"/>
 +    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.5.0/styles/github.min.css"/>
 +
 +    <!-- The files are not copied over into the Clippy project since they use the MPL-2.0 License -->
 +    <link rel="stylesheet" href="https://rust-lang.github.io/mdBook/css/variables.css"/>
 +    <link id="styleHighlight" rel="stylesheet" href="https://rust-lang.github.io/mdBook/highlight.css">
 +    <link id="styleNight" rel="stylesheet" href="https://rust-lang.github.io/mdBook/tomorrow-night.css" disabled="true">
 +    <link id="styleAyu" rel="stylesheet" href="https://rust-lang.github.io/mdBook/ayu-highlight.css" disabled="true">
 +    <style>
 +        blockquote { font-size: 1em; }
 +        [ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak { display: none !important; }
 +
 +        .form-inline .checkbox { margin-right: 0.6em }
 +
 +        .panel-heading { cursor: pointer; }
 +
 +        .panel-title { display: flex; flex-wrap: wrap;}
 +        .panel-title .label { display: inline-block; }
 +
 +        .panel-title-name { flex: 1; min-width: 400px;}
 +        .panel-title-name span { vertical-align: bottom; }
 +
 +        .panel .panel-title-name .anchor { display: none; }
 +        .panel:hover .panel-title-name .anchor { display: inline;}
 +
 +        .label {
 +            padding-top: 0.3em;
 +            padding-bottom: 0.3em;
 +        }
 +
 +        .label-lint-group {
 +            min-width: 8em;
 +        }
 +        .label-lint-level {
 +            min-width: 4em;
 +        }
 +
 +        .label-lint-level-allow {
 +            background-color: #5cb85c;
 +        }
 +        .label-lint-level-warn {
 +            background-color: #f0ad4e;
 +        }
 +        .label-lint-level-deny {
 +            background-color: #d9534f;
 +        }
 +        .label-lint-level-none {
 +            background-color: #777777;
 +            opacity: 0.5;
 +        }
 +
 +        .label-group-deprecated {
 +            opacity: 0.5;
 +        }
 +
 +        .label-doc-folding {
 +            color: #000;
 +            background-color: #fff;
 +            border: 1px solid var(--theme-popup-border);
 +        }
 +        .label-doc-folding:hover {
 +            background-color: #e6e6e6;
 +        }
 +
 +        .lint-doc-md > h3 {
 +            border-top: 1px solid var(--theme-popup-border);
 +            padding: 10px 15px;
 +            margin: 0 -15px;
 +            font-size: 18px;
 +        }
 +        .lint-doc-md > h3:first-child {
 +            border-top: none;
 +            padding-top: 0px;
 +        }
 +
 +        @media (max-width:749px) {
 +            .lint-additional-info-container {
 +                display: flex;
 +                flex-flow: column;
 +            }
 +            .lint-additional-info-item + .lint-additional-info-item {
 +                border-top: 1px solid var(--theme-popup-border);
 +            }
 +        }
 +        @media (min-width:750px) {
 +            .lint-additional-info-container {
 +                display: flex;
 +                flex-flow: row;
 +            }
 +            .lint-additional-info-item + .lint-additional-info-item {
 +                border-left: 1px solid var(--theme-popup-border);
 +            }
 +        }
 +
 +        .lint-additional-info-item {
 +            display: inline-flex;
 +            min-width: 200px;
 +            flex-grow: 1;
 +            padding: 9px 5px 5px 15px;
 +        }
 +
 +        .label-applicability {
 +            background-color: #777777;
 +            margin: auto 5px;
 +        }
 +
 +        .label-version {
 +            background-color: #777777;
 +            margin: auto 5px;
 +            font-family: monospace;
 +        }
 +    </style>
 +    <style>
 +        /* Expanding the mdBoom theme*/
 +        .light {
 +            --inline-code-bg: #f6f7f6;
 +        }
 +        .rust {
 +            --inline-code-bg: #f6f7f6;
 +        }
 +        .coal {
 +            --inline-code-bg: #1d1f21;
 +        }
 +        .navy {
 +            --inline-code-bg: #1d1f21;
 +        }
 +        .ayu {
 +            --inline-code-bg: #191f26;
 +        }
 +
 +        /* Applying the mdBook theme */
 +        .theme-icon {
 +            position: absolute;
 +            text-align: center;
 +            width: 2em;
 +            height: 2em;
 +            margin: 0.7em;
 +            line-height: 2em;
 +            border: solid 1px var(--icons);
 +            border-radius: 5px;
 +            user-select: none;
 +            cursor: pointer;
 +        }
 +        .theme-icon:hover {
 +            background: var(--theme-hover);
 +        }
 +        .theme-choice {
 +            position: absolute;
 +            margin-top: calc(2em + 0.7em);
 +            margin-left: 0.7em;
 +            list-style: none;
 +            border: 1px solid var(--theme-popup-border);
 +            border-radius: 5px;
 +            color: var(--fg);
 +            background: var(--theme-popup-bg);
 +            padding: 0 0;
 +        }
 +        .theme-choice > li {
 +            padding: 5px 10px;
 +            font-size: 0.8em;
 +            user-select: none;
 +            cursor: pointer;
 +        }
 +        .theme-choice > li:hover {
 +            background: var(--theme-hover);
 +        }
 +
 +        .alert {
 +            color: var(--fg);
 +            background: var(--theme-hover);
 +            border: 1px solid var(--theme-popup-border);
 +        }
 +        .page-header {
 +            border-color: var(--theme-popup-border);
 +        }
 +        .panel-default > .panel-heading {
 +            background: var(--theme-hover);
 +            color: var(--fg);
 +            border: 1px solid var(--theme-popup-border);
 +        }
 +        .panel-default > .panel-heading:hover {
 +            filter: brightness(90%);
 +        }
 +        .list-group-item {
 +            background: 0%;
 +            border: 1px solid var(--theme-popup-border);
 +        }
 +        .panel, pre, hr {
 +            background: var(--bg);
 +            border: 1px solid var(--theme-popup-border);
 +        }
 +
 +        #filter-label, #filter-clear {
 +            background: var(--searchbar-bg);
 +            color: var(--searchbar-fg);
 +            border-color: var(--theme-popup-border);
 +            filter: brightness(95%);
 +        }
 +        #filter-label:hover, #filter-clear:hover {
 +            filter: brightness(90%);
 +        }
 +        #filter-input {
 +            background: var(--searchbar-bg);
 +            color: var(--searchbar-fg);
 +            border-color: var(--theme-popup-border);
 +        }
 +
 +        #filter-input::-webkit-input-placeholder,
 +        #filter-input::-moz-placeholder {
 +            color: var(--searchbar-fg);
 +            opacity: 30%;
 +        }
 +
 +        :not(pre) > code {
 +            color: var(--inline-code-color);
 +            background-color: var(--inline-code-bg);
 +        }
 +        html {
 +            scrollbar-color: var(--scrollbar) var(--bg);
 +        }
 +        body {
 +            background: var(--bg);
 +            color: var(--fg);
 +        }
 +
 +    </style>
 +</head>
 +<body>
 +    <div id="theme-icon" class="theme-icon">&#128396;</div>
 +    <ul id="theme-menu" class="theme-choice" style="display: none;">
 +        <li id="light">Light</li>
 +        <li id="rust">Rust</li>
 +        <li id="coal">Coal</li>
 +        <li id="navy">Navy</li>
 +        <li id="ayu">Ayu</li>
 +    </ul>
 +
 +    <div class="container" ng-app="clippy" ng-controller="lintList">
 +        <div class="page-header">
 +            <h1>Clippy Lints</h1>
 +        </div>
 +
 +        <noscript>
 +            <div class="alert alert-danger" role="alert">
 +                Sorry, this site only works with JavaScript! :(
 +            </div>
 +        </noscript>
 +
 +        <div ng-cloak>
 +
 +            <div class="alert alert-info" role="alert" ng-if="loading">
 +                Loading&#x2026;
 +            </div>
 +            <div class="alert alert-danger" role="alert" ng-if="error">
 +                Error loading lints!
 +            </div>
 +
 +            <div class="panel panel-default" ng-show="data">
 +                <div class="panel-body row filter-panel">
 +                    <div class="col-md-6 form-inline">
 +                        <div class="form-group form-group-lg">
 +                            <p class="h4">
 +                                Lint levels
 +                                <a href="https://doc.rust-lang.org/rustc/lints/levels.html">(?)</a>
 +                            </p>
 +                            <div class="checkbox" ng-repeat="(level, enabled) in levels">
 +                                <label class="text-capitalize">
 +                                    <input type="checkbox" ng-model="levels[level]" />
 +                                    {{level}}
 +                                </label>
 +                            </div>
 +                        </div>
 +                    </div>
 +                    <div class="col-md-6 form-inline">
 +                        <div class="form-group form-group-lg">
 +                            <p class="h4">
 +                                Lint groups
 +                                <a href="https://github.com/rust-lang/rust-clippy/#clippy">(?)</a>
 +                            </p>
 +                            <div class="checkbox" ng-repeat="(group, enabled) in groups">
 +                                <label class="text-capitalize">
 +                                    <input type="checkbox" ng-model="groups[group]" />
 +                                    {{group}}
 +                                </label>
 +                            </div>
 +                        </div>
 +                    </div>
 +                </div>
 +                <div class="panel-body row">
 +                    <div class="col-md-12 form-horizontal">
 +                        <div class="input-group">
 +                            <label class="input-group-addon" id="filter-label" for="filter-input">Filter:</label>
 +                            <input type="text" class="form-control" placeholder="Keywords or search string" id="filter-input" ng-model="search" ng-model-options="{debounce: 50}"/>
 +                            <span class="input-group-btn">
 +                                <button id="filter-clear" class="btn" type="button" ng-click="search = ''">
 +                                    Clear
 +                                </button>
 +                            </span>
 +                        </div>
 +                    </div>
 +                </div>
 +            </div>
 +            <!-- The order of the filters should be from most likely to remove a lint to least likely to improve performance. -->
 +            <article class="panel panel-default" id="{{lint.id}}" ng-repeat="lint in data | filter:bySearch | filter:byGroups | filter:byLevels">
 +                <header class="panel-heading" ng-click="open[lint.id] = !open[lint.id]">
 +                    <h2 class="panel-title">
 +                        <div class="panel-title-name">
 +                            <span>{{lint.id}}</span>
 +                            <a href="#{{lint.id}}" class="anchor label label-default" ng-click="open[lint.id] = true; $event.stopPropagation()">&para;</a>
 +                        </div>
 +
 +                        <div class="panel-title-addons">
 +                            <span class="label label-lint-group label-default label-group-{{lint.group}}">{{lint.group}}</span>
 +
 +                            <span class="label label-lint-level label-lint-level-{{lint.level}}">{{lint.level}}</span>
 +
 +
 +                            <span class="label label-doc-folding" ng-show="open[lint.id]">&minus;</span>
 +                            <span class="label label-doc-folding" ng-hide="open[lint.id]">&plus;</span>
 +                        </div>
 +                    </h2>
 +                </header>
 +
 +                <div class="list-group lint-docs" ng-class="{collapse: true, in: open[lint.id]}">
 +                    <div class="list-group-item lint-doc-md" ng-bind-html="lint.docs | markdown"></div>
 +                    <div class="lint-additional-info-container">
 +                        <!-- Applicability -->
 +                        <div class="lint-additional-info-item">
 +                            <span> Applicability: </span>
 +                            <span class="label label-default label-applicability">{{lint.applicability.applicability}}</span>
 +                            <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint_defs/enum.Applicability.html#variants">(?)</a>
 +                        </div>
 +                        <!-- Clippy version -->
 +                        <div class="lint-additional-info-item">
 +                            <span>{{lint.group == "deprecated" ? "Deprecated" : "Added"}} in: </span>
 +                            <span class="label label-default label-version">{{lint.version}}</span>
 +                        </div>
 +                        <!-- Open related issues -->
 +                        <div class="lint-additional-info-item">
 +                            <a href="https://github.com/rust-lang/rust-clippy/issues?q=is%3Aissue+{{lint.id}}">Related Issues</a>
 +                        </div>
 +                        <!-- Jump to source -->
 +                        <div class="lint-additional-info-item">
 +                            <a href="https://github.com/rust-lang/rust-clippy/blob/{{docVersion}}/clippy_lints/{{lint.id_span.path}}#L{{lint.id_span.line}}">View Source</a>
 +                        </div>
 +                    </div>
 +                </div>
 +            </article>
 +        </div>
 +    </div>
 +
 +    <a href="https://github.com/rust-lang/rust-clippy">
 +        <img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on Github"/>
 +    </a>
 +
 +    <script src="https://cdnjs.cloudflare.com/ajax/libs/markdown-it/12.3.2/markdown-it.min.js"></script>
 +    <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.5.0/highlight.min.js"></script>
 +    <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.5.0/languages/rust.min.js"></script>
 +    <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.12/angular.min.js"></script>
 +    <script>
 +    (function () {
 +        var md = window.markdownit({
 +            html: true,
 +            linkify: true,
 +            typographer: true,
 +            highlight: function (str, lang) {
 +                if (lang && hljs.getLanguage(lang)) {
 +                    try {
 +                        return '<pre class="hljs"><code>' +
 +                            hljs.highlight(lang, str, true).value +
 +                            '</code></pre>';
 +                    } catch (__) {}
 +                }
 +
 +                return '<pre class="hljs"><code>' + md.utils.escapeHtml(str) + '</code></pre>';
 +            }
 +        });
 +
 +        function scrollToLint(lintId) {
 +            var target = document.getElementById(lintId);
 +            if (!target) {
 +                return;
 +            }
 +            target.scrollIntoView();
 +        }
 +
 +        function scrollToLintByURL($scope) {
 +            var removeListener = $scope.$on('ngRepeatFinished', function(ngRepeatFinishedEvent) {
 +                scrollToLint(window.location.hash.slice(1));
 +                removeListener();
 +            });
 +        }
 +
 +        function selectGroup($scope, selectedGroup) {
 +            var groups = $scope.groups;
 +            for (var group in groups) {
 +                if (groups.hasOwnProperty(group)) {
 +                    if (group === selectedGroup) {
 +                        groups[group] = true;
 +                    } else {
 +                        groups[group] = false;
 +                    }
 +                }
 +            }
 +        }
 +
 +        angular.module("clippy", [])
 +        .filter('markdown', function ($sce) {
 +            return function (text) {
 +                return $sce.trustAsHtml(
 +                    md.render(text || '')
 +                    // Oh deer, what a hack :O
 +                    .replace('<table', '<table class="table"')
 +                );
 +            };
 +        })
 +        .directive('onFinishRender', function ($timeout) {
 +            return {
 +                restrict: 'A',
 +                link: function (scope, element, attr) {
 +                    if (scope.$last === true) {
 +                        $timeout(function () {
 +                            scope.$emit(attr.onFinishRender);
 +                        });
 +                    }
 +                }
 +            };
 +        })
 +        .controller("lintList", function ($scope, $http, $timeout) {
 +            // Level filter
 +            var LEVEL_FILTERS_DEFAULT = {allow: true, warn: true, deny: true, none: true};
 +            $scope.levels = LEVEL_FILTERS_DEFAULT;
 +            $scope.byLevels = function (lint) {
 +                return $scope.levels[lint.level];
 +            };
 +
 +            var GROUPS_FILTER_DEFAULT = {
 +                cargo: true,
 +                complexity: true,
 +                correctness: true,
 +                deprecated: false,
 +                nursery: true,
 +                pedantic: true,
 +                perf: true,
 +                restriction: true,
 +                style: true,
 +                suspicious: true,
 +            };
 +            $scope.groups = GROUPS_FILTER_DEFAULT;
 +            $scope.byGroups = function (lint) {
 +                return $scope.groups[lint.group];
 +            };
 +
 +            $scope.bySearch = function (lint, index, array) {
 +                let searchStr = $scope.search;
 +                // It can be `null` I haven't missed this value
 +                if (searchStr == null || searchStr.length < 3) {
 +                    return true;
 +                }
 +                searchStr = searchStr.toLowerCase();
 +
 +                // Search by id
 +                if (lint.id.indexOf(searchStr.replace("-", "_")) !== -1) {
 +                    return true;
 +                }
 +
 +                // Search the description
 +                // The use of `for`-loops instead of `foreach` enables us to return early
 +                let terms = searchStr.split(" ");
 +                let docsLowerCase = lint.docs.toLowerCase();
 +                for (index = 0; index < terms.length; index++) {
 +                    // This is more likely and will therefor be checked first
 +                    if (docsLowerCase.indexOf(terms[index]) !== -1) {
 +                        continue;
 +                    }
 +
 +                    if (lint.id.indexOf(terms[index]) !== -1) {
 +                        continue;
 +                    }
 +
 +                    return false;
 +                }
 +
 +                return true;
 +            }
 +
 +            // Get data
 +            $scope.open = {};
 +            $scope.loading = true;
 +            // This will be used to jump into the source code of the version that this documentation is for.
 +            $scope.docVersion = window.location.pathname.split('/')[2] || "master";
 +
 +            if (window.location.hash.length > 1) {
 +                $scope.search = window.location.hash.slice(1);
 +                $scope.open[window.location.hash.slice(1)] = true;
 +                scrollToLintByURL($scope);
 +            }
 +
 +            $http.get('./lints.json')
 +            .success(function (data) {
 +                $scope.data = data;
 +                $scope.loading = false;
 +
 +                var selectedGroup = getQueryVariable("sel");
 +                if (selectedGroup) {
 +                    selectGroup($scope, selectedGroup.toLowerCase());
 +                }
 +
 +                scrollToLintByURL($scope);
++
++                setTimeout(function () {
++                    var el = document.getElementById('filter-input');
++                    if (el) { el.focus() }
++                }, 0);
 +            })
 +            .error(function (data) {
 +                $scope.error = data;
 +                $scope.loading = false;
 +            });
 +
 +            window.addEventListener('hashchange', function () {
 +                // trigger re-render
 +                $timeout(function () {
 +                    $scope.levels = LEVEL_FILTERS_DEFAULT;
 +                    $scope.search = window.location.hash.slice(1);
 +                    $scope.open[window.location.hash.slice(1)] = true;
 +
 +                    scrollToLintByURL($scope);
 +                });
 +                return true;
 +            }, false);
 +        });
 +    })();
 +
 +    function getQueryVariable(variable) {
 +        var query = window.location.search.substring(1);
 +        var vars = query.split('&');
 +        for (var i = 0; i < vars.length; i++) {
 +            var pair = vars[i].split('=');
 +            if (decodeURIComponent(pair[0]) == variable) {
 +                return decodeURIComponent(pair[1]);
 +            }
 +        }
 +    }
 +
 +    function setupListeners() {
 +        let themeIcon = document.getElementById("theme-icon");
 +        let themeMenu = document.getElementById("theme-menu");
 +        themeIcon.addEventListener("click", function(e) {
 +            if (themeMenu.style.display == "none") {
 +                themeMenu.style.display = "block";
 +            } else {
 +                themeMenu.style.display = "none";
 +            }
 +        });
 +
 +        let children = themeMenu.children;
 +        for (let index = 0; index < children.length; index++) {
 +            let child = children[index];
 +            child.addEventListener("click", function(e) {
 +                setTheme(child.id, true);
 +            });
 +        }
 +    }
 +
 +    setupListeners();
 +
 +    function setTheme(theme, store) {
 +        let enableHighlight = false;
 +        let enableNight = false;
 +        let enableAyu = false;
 +
 +        if (theme == "ayu") {
 +            enableAyu = true;
 +        } else if (theme == "coal" || theme == "navy") {
 +            enableNight = true;
 +        } else if (theme == "rust") {
 +            enableHighlight = true;
 +        } else {
 +            enableHighlight = true;
 +            // this makes sure that an unknown theme request gets set to a known one
 +            theme = "light";
 +        }
 +        document.getElementsByTagName("body")[0].className = theme;
 +
 +        document.getElementById("styleHighlight").disabled = !enableHighlight;
 +        document.getElementById("styleNight").disabled = !enableNight;
 +        document.getElementById("styleAyu").disabled = !enableAyu;
 +
 +        if (store) {
 +            try {
 +                localStorage.setItem('clippy-lint-list-theme', theme);
 +            } catch (e) { }
 +        }
 +    }
 +
 +    // loading the theme after the initial load
 +    setTheme(localStorage.getItem('clippy-lint-list-theme'), false);
 +    </script>
 +</body>
 +</html>