This is a temporary fix for `needless_borrow`. The proper fix is included in #8355.
This should probably be merged into rustc before beta branches on Friday. This issue has been reported six or seven times in the past couple of weeks.
changelog: Fix various issues with `needless_borrow` n´. Note to changelog writer: those issues might have been introduced in this release cycle, so this might not matter in the changelog.
bors [Wed, 16 Feb 2022 22:01:49 +0000 (22:01 +0000)]
Auto merge of #8188 - jamesmcm:recursive_display_impl, r=camsteffen
new lint: `recursive_format_impl`
The to_string_in_display lint is renamed to recursive_format_impl
A check is added for the use of self formatted with Display or Debug inside any format string in the same impl
The to_string_in_display check is kept as is - like in the format_in_format_args lint
This is my first contribution so please check it for better / more idiomatic checks + error messages. Note the format macro paths are shared with the `format_in_format_args` lint - maybe those could be moved to clippy utils too.
This relates to issues #2691 and #7830
------
changelog: Renamed `to_string_in_display` lint to [`recursive_format_impl`] with new check for any use of self as Display or Debug inside the same format trait impl.
James McMurray [Tue, 28 Dec 2021 18:27:11 +0000 (19:27 +0100)]
Add recursive_format_impl lint
The to_string_in_display lint is renamed to recursive_format_impl
A check is added for the use of self formatted with Display or Debug
inside any format string in the same impl
The to_string_in_display check is kept as is - like in the
format_in_format_args lint
For now only Display and Debug are checked
This could also be extended to other Format traits (Binary, etc.)
bors [Mon, 14 Feb 2022 05:55:34 +0000 (05:55 +0000)]
Auto merge of #8429 - nsunderland1:master, r=llogiq
Document `pub` requirement for `new_without_default` lint
fixes #8415
Also adds some UI tests that ensure that `pub` is required on both the struct _and_ the field. The only thing I'm not sure about is that the lint actually [checks](https://github.com/rust-lang/rust-clippy/blob/master/clippy_lints/src/new_without_default.rs#L102) if `new` is _reachable_, not _public_. To the best of my understanding, both the struct and the method need to be public for the method to be reachable for external crates (I certainly didn't manage to craft a counterexample).
changelog: Document `pub` requirement for ``[`new_without_default`]`` lint.
bors [Sat, 12 Feb 2022 07:22:13 +0000 (07:22 +0000)]
Auto merge of #8418 - dtolnay-contrib:transmuteundefinedrepr, r=llogiq
Downgrade transmute_undefined_repr to nursery
Reason: #8417. I am skeptical of this lint but maybe there is a narrower subset of types on which it is useful, so keeping it for now but moving to nursery for further development.
---
*Please write a short comment explaining your change (or "none" for internal only changes)*
changelog: Remove [`transmute_undefined_repr`] from default set of enabled lints
bors [Tue, 8 Feb 2022 20:50:41 +0000 (20:50 +0000)]
Auto merge of #8374 - Alexendoo:bless-revisions, r=camsteffen
Support `cargo dev bless` for tests with revisions
changelog: internal: Support `cargo dev bless` for tests with revisions
Previously bless wouldn't pick up the saved stderr from `target/debug/tests/manual_assert.stage-id.edition2021.stderr` or `target/debug/tests/manual_assert.stage-id.edition2018.stderr` due to there being multiple revisions of the test output
This tweaks compile-test so the built files end up in e.g. `target/debug/tests/ui`, `target/debug/tests/ui-cargo` rather than share the `tests` dir. `cargo dev bless` then uses that to update all the `.stdout/stdout/fixed` files it can find
Also removes an empty file I found, and the logic to remove empty outputs as compiletest doesn't produce empty `.stdout/stderr` files
bors [Mon, 7 Feb 2022 15:23:23 +0000 (15:23 +0000)]
Auto merge of #8305 - camsteffen:util-cleanup, r=flip1995
Factor out several utils, add `path_def_id`
changelog: none
This is generally an effort to reduce the total number of utils. `path_def_id` is added which I believe is more "cross-cutting" and also complements `path_to_local`. Best reviewed one commit at a time.
bors [Sun, 6 Feb 2022 16:05:00 +0000 (16:05 +0000)]
Auto merge of #8398 - Jarcho:unordered_transmute, r=llogiq
Add lint `transmute_undefined_repr`
Partially implements #3999 and #546
This doesn't consider `enum`s at all right now as those are going to be a pain to deal with. This also allows `#[repr(Rust)]` structs with only one non-zero sized fields. I think those are technically undefined when transmuted.
bors [Wed, 2 Feb 2022 12:37:18 +0000 (12:37 +0000)]
Auto merge of #8382 - tamaroning:suggest_iter_instead_of_into_iter, r=giraffate
[explicit_counter_loop] suggests `.into_iter()`, despite that triggering [into_iter_on_ref] in some cases
I have modified `fn make_iterator_snippet` in clippy_lints/src/loops/utils.rs ,so this change has some little influence on another lint [manual_flatten] .
fixes #8155
---
changelog: Fix that [`explicit_counter_loop`] suggests `into_iter()` despite that triggering [`into_iter_on_ref`] in some cases
bors [Tue, 1 Feb 2022 21:18:45 +0000 (21:18 +0000)]
Auto merge of #8370 - smoelius:master, r=flip1995
Format `if_chain` invocations in clippy_utils
Not realizing it was [already obsolete](https://github.com/rust-lang/rust-clippy/pull/8360), I built a [tool to format inside `if_chain` invocations](https://crates.io/crates/rustfmt_if_chain).
This PR applies the tool to clippy_utils. (If you apply it to clippy_lints, the changes are extensive.)
Anyway, I'm making it known here in case anyone wants to use it while `if-let` chain support is developed for `rustfmt`. (There could be a few Clippy PRs between now and then, and IMHO, the code looks better with the `if_chain` invocations formatted.)
Matthias Krüger [Tue, 1 Feb 2022 15:08:05 +0000 (16:08 +0100)]
Rollup merge of #93290 - lcnr:same_type, r=jackh726
remove `TyS::same_type`
This function ignored regions and constants in adts, but didn't do so for references or any other types. cc https://github.com/rust-lang/rust/pull/93148#discussion_r791408057
bors [Sun, 30 Jan 2022 22:00:36 +0000 (22:00 +0000)]
Auto merge of #8322 - jubnzv:8282-single-match, r=llogiq
single_match: Don't lint non-exhaustive matches; support tuples
`single_match` lint:
* Don't lint exhaustive enum patterns without a wild.
Rationale: The definition of the enum could be changed, so the user can get non-exhaustive match after applying the suggested lint (see https://github.com/rust-lang/rust-clippy/issues/8282#issuecomment-1013566068 for context).
* Lint `match` constructions with tuples (as suggested at https://github.com/rust-lang/rust-clippy/issues/8282#issuecomment-1015621148)
Closes #8282
---
changelog: [`single_match`]: Don't lint exhaustive enum patterns without a wild.
changelog: [`single_match`]: Lint `match` constructions with tuples