Commit graph

4405 commits

Author SHA1 Message Date
bors
1cec8b30fa Auto merge of #8594 - FoseFx:unit_like_struct_brackets, r=giraffate
add `empty_structs_with_brackets`

<!-- Thank you for making Clippy better!

We're collecting our changelog from pull request descriptions.
If your PR only includes internal changes, you can just write
`changelog: none`. Otherwise, please write a short comment
explaining your change. Also, it's helpful for us that
the lint name is put into brackets `[]` and backticks `` ` ` ``,
e.g. ``[`lint_name`]``.

If your PR fixes an issue, you can add "fixes #issue_number" into this
PR description. This way the issue will be automatically closed when
your PR is merged.

If you added a new lint, here's a checklist for things that will be
checked during review or continuous integration.

- \[ ] Followed [lint naming conventions][lint_naming]
- \[ ] Added passing UI tests (including committed `.stderr` file)
- \[ ] `cargo test` passes locally
- \[ ] Executed `cargo dev update_lints`
- \[ ] Added lint documentation
- \[ ] Run `cargo dev fmt`

[lint_naming]: https://rust-lang.github.io/rfcs/0344-conventions-galore.html#lints

Note that you can skip the above if you are just opening a WIP PR in
order to get feedback.

Delete this line and everything above before opening your PR.

--

*Please write a short comment explaining your change (or "none" for internal only changes)*
-->
Closes #8591

I'm already sorry for the massive diff 😅

changelog: New lint [`empty_structs_with_brackets`]
2022-04-04 07:28:36 +00:00
Jason Newcomb
d5ef542d37 Generate renamed lint test 2022-04-03 22:52:42 -04:00
Jason Newcomb
4227411513 Generate deprecated lints test 2022-04-03 08:54:37 -04:00
Jason Newcomb
17c8bee95a Add a couple of examples to undocumented_unsafe_blocks 2022-04-02 00:46:45 -04:00
Peter Jaszkowiak
c70f1e0f8f ignore &x | &y in unnested_or_patterns
replacing it with `&(x | y)` is actually more characters
2022-04-01 22:36:30 -06:00
bors
f6b29923c6 Auto merge of #8616 - pitaj:single_element_loop_arrays, r=llogiq
single_element_loop: handle arrays for Edition2021

changelog: [`single_element_loop`] handle arrays in Edition 2021, handle `.iter_mut()` and `.into_iter()`, and wrap in parens if necessary
2022-04-01 18:45:49 +00:00
Peter Jaszkowiak
3bbb3e3329 single_element_loop: handle arrays for Edition2021
also handle `.iter_mut()`, `.into_iter()`,
and wrapping in parens if necessary
2022-04-01 00:04:19 -06:00
SabrinaJewson
11045f94e2
Don't unnecessarily suggest unsafe block 2022-04-01 06:32:22 +01:00
SabrinaJewson
7a80c23f83
Suggest from_utf8_unchecked in const contexts 2022-03-30 21:49:13 +01:00
bors
db5739ac55 Auto merge of #8610 - SabrinaJewson:transmute-int-to-char-const, r=xFrednet
Don't warn int-to-char transmutes in const contexts

changelog: Don't warn ``[`transmute_int_to_char`]`` in const contexts

fixes: #8379
2022-03-30 20:23:03 +00:00
Max Baumann
e552267db3 style -> pedantic 2022-03-30 20:13:16 +02:00
Max Baumann
2953cba116 unit_like_struct_brackets -> empty_structs_with_brackets 2022-03-30 20:13:16 +02:00
Max Baumann
37d5a6264c changes after review 2022-03-30 20:12:58 +02:00
Max Baumann
33383a418d use span_suggestion_hidden 2022-03-30 20:12:58 +02:00
Max Baumann
7192297c28 additional checks for conditionally compiled code 2022-03-30 20:12:58 +02:00
Max Baumann
315521afc6 fix uitests 2022-03-30 20:12:58 +02:00
Max Baumann
9be3945be7 fix existing clippy tests 2022-03-30 20:12:58 +02:00
Max Baumann
528ada958b add unit_like_struct_brackets 2022-03-30 20:12:58 +02:00
SabrinaJewson
d6f05c6a89
Don't warn int-to-char transmutes in const contexts 2022-03-30 18:47:50 +01:00
bors
c0a5693abc Auto merge of #8602 - giraffate:fix_ice_for_iter_overeager_cloned, r=llogiq
Fix ICE for `iter_overeager_cloned`

Fix https://github.com/rust-lang/rust-clippy/issues/8527

changelog: Fix ICE for [`iter_overeager_cloned`]
2022-03-30 17:12:24 +00:00
bors
fe7254ff6f Auto merge of #8576 - smoelius:crate_in_macro_def, r=llogiq
Add `crate_in_macro_def` lint

This PR adds a lint to check for `crate` as opposed to `$crate` used in a macro definition.

I think this can close #4798. That issue focused on the case where the macro author "imports something into said macro."

But I think use of `crate` is likely to be a bug whether it appears in a `use` statement or not. There could be some use case I am failing to see, though. (cc: `@nilscript` `@flip1995)`

changelog: `crate_in_macro_def`
2022-03-30 16:57:24 +00:00
Samuel E. Moelius III
aaf04dc043 Fix error message in crate_in_macro_def.stderr 2022-03-30 12:52:31 -04:00
bors
0031f69999 Auto merge of #8592 - c410-f3r:stuff, r=flip1995
Do not fire `panic` in a constant environment

Let rustc handle panics in constant environments.

Since https://github.com/rust-lang/rust-clippy/issues/8348 I thought that such modification would require a lot of work but thanks to https://github.com/rust-lang/rust-clippy/pull/8588 I now know that it is not the case.

changelog: [`panic`]: No longer lint in constant context. `rustc` already handles this.
2022-03-30 16:04:14 +00:00
bors
d9819c3b8d Auto merge of #8584 - Alexendoo:map-unit-fn-context, r=Manishearth
Provide suggestion context in map_unit_fn

Fixes #8569

changelog: Fix incorrect suggestion for `option_map_unit_fn` , `result_map_unit_fn`
2022-03-30 15:25:37 +00:00
Takayuki Nakata
c22b7b8814 Fix ICE for iter_overeager_cloned 2022-03-29 21:51:37 +09:00
J-ZhengLi
448a26d696 improve parent expr check 2022-03-29 15:23:19 +08:00
Samuel E. Moelius III
cb307bbfcd Address review comments 2022-03-28 04:48:12 -04:00
Jaic1
ec851b870b First submit 2022-03-28 12:09:01 +08:00
bors
6206086dd5 Auto merge of #8487 - dswij:8478, r=giraffate
[`map_identity`] checks for needless `map_err`

Closes #8478

changelog: [`map_identity`] checks for needless `map_err`
2022-03-28 00:25:45 +00:00
bors
59c0f29916 Auto merge of #8519 - tysg:redundant-modulo, r=giraffate
Check if lhs < rhs in modulos in `identity_op`

Fixes #8508

changelog: [`identity_op`] now checks for modulos, e.g. `1 % 3`
2022-03-28 00:11:32 +00:00
Tianyi Song
52b563b283 Emit lint when rhs is negative 2022-03-27 21:49:38 +08:00
bors
a7da8a6019 Auto merge of #95274 - jendrikw:slice-must-use, r=Dylan-DPC
add #[must_use] to functions of slice and its iterators.

Continuation of #92853.

Tracking issue: #89692.
2022-03-26 20:17:04 +00:00
Caio
af8ed04e09 Rustfmt 2022-03-26 15:48:17 -03:00
Caio
c687f6575f Do not fire panic in a constant environment 2022-03-26 15:39:21 -03:00
Jendrik
41f1413085 add #[must_use] to functions of slice and its iterators. 2022-03-26 16:19:47 +01:00
Jendrik
96f4e1c630 add #[must_use] to functions of slice and its iterators. 2022-03-26 15:37:48 +01:00
Peter Jaszkowiak
21eae8ceb6 fix indexing_slicing with const
- should not fire if indexing with a constant block
- should not fire if indexing within a constant context
(const statement or const block)
2022-03-25 23:05:38 -06:00
Alex Macleod
610db04222 Provide suggestion context in map_unit_fn 2022-03-25 20:47:54 +00:00
bors
b7b0dad656 Auto merge of #95273 - flip1995:clippyup, r=manishearth
Update Clippy

r? `@Manishearth`
2022-03-24 22:52:34 +00:00
flip1995
1fa3d66e62 Merge commit 'd0cf3481a84e3aa68c2f185c460e282af36ebc42' into clippyup 2022-03-24 14:50:04 +01:00
flip1995
1147b2c481
Merge remote-tracking branch 'upstream/master' into rustup 2022-03-24 14:22:35 +01:00
Yoav Lavi
b60a7fb7b6
unnecessary_join lint 2022-03-24 13:18:18 +01:00
Oli Scherer
6fc3850847 update clippy stderr file 2022-03-24 11:27:07 +00:00
Samuel E. Moelius III
65a26692fd Add crate_in_macro_def lint 2022-03-24 05:08:10 -04:00
bors
f07ee8a998 Auto merge of #8232 - Jarcho:match_same_arm_860, r=xFrednet
`match_same_arms` fix

fixes #860
fixes #1140

changelog: Don't lint `match_same_arms` when an interposing arm's pattern would overlap
2022-03-21 20:42:51 +00:00
bors
4a07662d94 Auto merge of #8561 - FoseFx:use_unwrap_or, r=xFrednet
add `or_then_unwrap`

Closes #8557

changelog: New lint [`or_then_unwrap`]
2022-03-21 20:08:29 +00:00
J-ZhengLi
5b6295d663 allowing [map_flatten] to split long suggestions
add new function `span_lint_and_sugg_` for edges in `clippy_utils::diagnostics`
2022-03-21 14:11:22 +08:00
Max Baumann
0f83753934
feat: change error message 2022-03-20 23:43:17 +01:00
Max Baumann
20c352a4f6
test: add method chain test 2022-03-19 18:17:43 +01:00
Max Baumann
895de1f13e
feat: make fixable 2022-03-18 23:18:36 +01:00
Max Baumann
f00e844a1f
feat: use span_lint_and_sugg 2022-03-18 22:44:56 +01:00
bors
a31dcb77be Auto merge of #8562 - Jarcho:enum_tuple_variant_as_int, r=Manishearth
Add lint `cast_enum_constructor`

fixes: #1116

changelog: Add lint `cast_enum_constructor`
2022-03-18 15:54:45 +00:00
Max Baumann
fd2c860171
feat: add comment 2022-03-18 14:45:48 +01:00
bors
9fd3c2d788 Auto merge of #8543 - dswij:8393, r=giraffate
`unnecessary_lazy_eval` show suggestions on multiline lint

Closes #8393

changelog: [`unnecessary_lazy_eval`] now shows suggestions for long-line lints
2022-03-18 00:42:18 +00:00
Max Baumann
05e05eaed7
refactor: rename lint to or_then_unwrap 2022-03-18 01:04:33 +01:00
Jason Newcomb
39329d1d40 Add lint cast_enum_constructor 2022-03-17 19:57:35 -04:00
Max Baumann
44c62c9aa2
feat: add tests and fix existing ones 2022-03-18 00:51:26 +01:00
Max Baumann
3f00f074de
fix: fix tests 2022-03-17 19:13:44 +01:00
Max Baumann
f49a2c3457
feat: add use_unwrap_or 2022-03-17 18:57:28 +01:00
bors
8d5c0eadde Auto merge of #8552 - Jarcho:ptr_arg_8495, r=xFrednet
Don't lint `ptr_arg` on `&mut Cow<_>`

fixes: #8495

changelog: Don't lint `ptr_arg` on `&mut Cow<_>`
2022-03-17 17:05:26 +00:00
J-ZhengLi
4b128624ed fix #8551, add test cases, and some code improvement 2022-03-17 23:06:31 +08:00
Jason Newcomb
773d20341a Fix mixed enum variant kinds + code cleanup 2022-03-17 01:09:25 -04:00
Jason Newcomb
08a7157a37 Improve message for match_single_arms 2022-03-16 13:58:09 -04:00
Jason Newcomb
b37317b028 Check if there are any overlapping patterns between equal arm bodies in match_same_arm 2022-03-16 13:18:29 -04:00
Jason Newcomb
8e5208cbff Don't lint transmute_undefined_repr when changing the type of generic params 2022-03-16 12:56:23 -04:00
Jason Newcomb
851e715e5a Don't lint ptr_arg on &mut Cow<_> 2022-03-16 12:00:27 -04:00
codehorseman
4beda1be70 resolve the conflict in compiler/rustc_session/src/parse.rs
Signed-off-by: codehorseman <cricis@yeah.net>
2022-03-16 20:12:30 +08:00
J-ZhengLi
2909b33a24 quick fix of issue#8542 for lint [needless_match]
remove `ref`/`ref mut` check
2022-03-16 16:26:56 +08:00
Jason Newcomb
47c9ed697b Fix checking transmutes with adjusted types 2022-03-15 23:11:11 -04:00
Jason Newcomb
911e10562a Don't lint transmute_undefined_repr on unions. 2022-03-15 22:38:15 -04:00
Jason Newcomb
442d4ce1c3 Don't lint fat pointer to (usize, usize) conversion in transmute_undefined_repr 2022-03-15 22:31:07 -04:00
Jason Newcomb
e71ac41d44 Fix transmute_undefined_repr for single element tuples 2022-03-15 21:51:07 -04:00
Jason Newcomb
30b333645d Don't lint undocumented_unsafe_blocks on bad proc-macro spans. 2022-03-15 16:52:28 -04:00
Jason Newcomb
65f96e2b53 Rework undocumented_unsafe_blocks 2022-03-15 14:18:05 -04:00
dswij
6a3dbe4798 unnecessary_lazy_eval show suggestions on multiline lint 2022-03-15 23:59:26 +08:00
bors
71ecbc42f9 Auto merge of #8509 - smoelius:fix-8507, r=giraffate
Fix `unncessary_to_owned` false positive

Fix #8507

changelog: none
2022-03-15 01:08:47 +00:00
xFrednet
2ee5372389
Allow single_component_path_imports for all macros 2022-03-14 22:45:00 +01:00
flip1995
d1b087fdee Merge commit 'dc5423ad448877e33cca28db2f1445c9c4473c75' into clippyup 2022-03-14 12:02:53 +01:00
flip1995
d5ab347d5c
Merge remote-tracking branch 'upstream/master' into rustup 2022-03-14 11:29:18 +01:00
bors
e2e492c10e Auto merge of #8422 - buttercrab:only_used_in_recursion, r=llogiq
new lint: `only_used_in_recursion`

changed:
- added `only_used_in_recursion`.
- fixed code that variables are only used in recursion.
- this would not lint when `unused_variable`

This fixes: #8390

-----

changelog: add lint [`only_used_in_recursion`]
2022-03-13 16:11:25 +00:00
bors
75b616e92f Auto merge of #8471 - J-ZhengLi:master-issue7040, r=llogiq
new lint that detects useless match expression

fixes #7040

changelog: Add new  lint [`needless_match`] under complexity lint group
2022-03-13 14:49:56 +00:00
Tianyi Song
a944ccb677 Check if lhs < rhs in modulos and emit 2022-03-11 16:02:49 +08:00
J-ZhengLi
086b045822 add checking for x -> x and ref x -> x and related test cases. 2022-03-10 14:46:58 +08:00
Jaeyong Sung
69161c6327
fix to lint Self::function 2022-03-10 15:46:40 +09:00
J-ZhengLi
ec9116412a rename lint to needless_match
and change its lint group to "complexity"
2022-03-10 09:44:25 +08:00
J-ZhengLi
750204e3e3 fix a bug that caused internal test fail 2022-03-08 18:15:11 +08:00
J-ZhengLi
6bfc1120cf add nop if-let expression check.
re-design test cases as some of them are not worth the effort to check.
2022-03-08 17:37:53 +08:00
Eric Holk
43ce0a94af Update and fix clippy tests 2022-03-07 08:47:18 -08:00
J-ZhengLi
db3fcf8df7 add basic code to check nop match blocks
modify `manual_map_option` uitest because one test case has confliction.
2022-03-07 18:12:35 +08:00
Jaeyong Sung
e4766776d2
add test for trait recursion 2022-03-07 12:15:00 +09:00
bors
0c483f69db Auto merge of #8445 - asquared31415:slice_ptr_cast, r=llogiq
Llint for casting between raw slice pointers with different element sizes

This lint disallows using `as` to convert from a raw pointer to a slice (e.g. `*const [i32]`, `*mut [Foo]`) to any other raw pointer to a slice if the element types have different sizes.  When a raw slice pointer is cast, the data pointer and count metadata are preserved.  This means that when the size of the inner slice's element type changes, the total number of bytes pointed to by the count changes.  For example a `*const [i32]` with length 4 (four `i32` elements) is cast `as *const [u8]` the resulting pointer points to four `u8` elements at the same address, losing most of the data.  When the size *increases* the resulting pointer will point to *more* data, and accessing that data will be UB.

On its own, *producing* the pointer isn't actually a problem, but because any use of the pointer as a slice will either produce surprising behavior or cause UB I believe this is a correctness lint.  If the pointer is not intended to be used as a slice, the user should instead use any of a number of methods to produce just a data pointer including an `as` cast to a thin pointer (e.g. `p as *const i32`) or if the pointer is being created from a slice, the `as_ptr` method on slices.  Detecting the intended use of the pointer is outside the scope of this lint, but I believe this lint will also lead users to realize that a slice pointer is only for slices.

There is an exception to this lint when either of the slice element types are zero sized (e.g `*mut [()]`).  The total number of bytes pointed to by the slice with a zero sized element is zero.  In that case preserving the length metadata is likely intended as a workaround to get the length metadata of a slice pointer though a zero sized slice.

The lint does not forbid casting pointers to slices with the *same* element size as the cast was likely intended to reinterpret the data in the slice as some equivalently sized data and the resulting pointer will behave as intended.

---

changelog: Added ``[`cast_slice_different_sizes`]``, a lint that disallows using `as`-casts to convert between raw pointers to slices when the elements have different sizes.
2022-03-06 07:46:56 +00:00
Samuel E. Moelius III
1a95590faf Fix #8507 2022-03-05 21:18:44 -05:00
Jaeyong Sung
2b0f9aba64
don't lint when implementing trait 2022-03-05 21:39:00 +09:00
Esteban Kuber
90da7cdd41 Do not point at whole file missing fn main
Only point at the end of the crate. We could try making it point at the
beginning of the crate, but that is confused with `DUMMY_SP`, causing
the output to be *worse*.

This change will make it so that VSCode will *not* underline the whole
file when `main` is missing, so other errors will be visible.
2022-03-05 02:42:55 +00:00
bors
48d54942f5 Auto merge of #8504 - xFrednet:8502-allow-lint-without-reason, r=flip1995
Add lint to detect `allow` attributes without reason

I was considering putting this lint into the pedantic group. However, that would result in countless warnings for existing projects. Having it in restriction also seems good to me 🙃 (And now I need sleep 💤 )

---

changelog: New lint [`allow_lint_without_reason`] (Requires the `lint_reasons` feature)

Closes: rust-lang/rust-clippy#8502
2022-03-04 19:23:39 +00:00
asquared31415
f932c304bb lint for casting raw pointers to slices with different element sizes 2022-03-04 13:23:06 -05:00
xFrednet
ab6ffb6371
Add lint to detect allow attributes without reason 2022-03-04 17:45:43 +01:00
bors
53189ad190 Auto merge of #8500 - rust-lang:testless-dbg-macro, r=Manishearth
Omit dbg_macro in test code

This fixes #8481.

---

changelog: none
2022-03-03 18:32:07 +00:00
Andre Bogus
63907234d7 Omit dbg_macro in test code 2022-03-03 19:28:05 +01:00
Liu Dingming
6cc2eeaa56 Suggest into_iter() over drain(..)
Add doc

Add description

iter_with_drain dogfood

Disable emiting on struct field.

Fix clippy

Add eq_path for SpanlessEq

Fix tests

Better error message

Fix doc test

Fix version

Apply suggestions
2022-03-03 13:10:19 +08:00
Ralf Jung
c45a42a332 bless clippy 2022-03-02 19:20:27 -05:00
bors
6e211eac7c Auto merge of #8489 - smoelius:unnecessary-find-map, r=llogiq
Add `unnecessary_find_map` lint

This PR adds an `unnecessary_find_map` lint. It is essentially just a minor enhancement of `unnecessary_filter_map`.

Closes #8467

changelog: New lint `unnecessary_find_map`
2022-03-02 19:50:27 +00:00
bors
2e40dc81b7 Auto merge of #8456 - ebobrow:use_self_pat, r=llogiq
check `use_self` in `pat`

fixes #6955

changelog: check `use_self` in `pat`
2022-03-02 19:31:22 +00:00
Andre Bogus
9f1080cc6e new lint: missing-spin-loop 2022-03-02 19:31:06 +01:00
Samuel E. Moelius III
2a588d810f Add unnecessary_find_map lint 2022-03-01 19:24:55 -05:00
dswij
3d1f83efbd map_identity Add tests for needless .map_err 2022-03-01 13:11:40 +08:00
Samuel E. Moelius III
cfd32522c0 Add tests to tests/ui/unnecessary_filter_map.rs
The tests currently fail, and are fixed by the next commit.
2022-02-28 05:24:00 -05:00
Elliot Bobrow
914ae1e849 check use_self in pat 2022-02-26 09:23:29 -08:00
bors
d1ca1c1d0c Auto merge of #8462 - ken-matsui:use-precise-namespace-for-reverse, r=llogiq
Use the precise namespace for `Reverse`

Closes: https://github.com/rust-lang/rust-clippy/issues/8461

changelog: [`unnecessary_sort_by`](https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_sort_by): Use the precise namespace for `Reverse`
2022-02-26 14:49:39 +00:00
flip1995
35020280a0 Merge commit 'e329249b6a3a98830d860c74c8234a8dd9407436' into clippyup 2022-02-26 14:26:21 +01:00
bors
e329249b6a Auto merge of #8464 - Jarcho:ptr_arg_8463, r=camsteffen
Fix `ptr_arg`

fixes: #8463

changelog: Fix `ptr_arg` when multiple arguments are being checked in one function
2022-02-26 03:00:53 +00:00
bors
2c8d5a2500 Auto merge of #8453 - tamaroning:fix_large_enum_variant, r=camsteffen
fix false positives of large_enum_variant

fixes: #8321
The size of enums containing generic type was calculated to be 0.
I changed [large_enum_variant] so that such enums are not linted.

changelog: none
2022-02-26 02:42:43 +00:00
Alex Macleod
52f3d61a2a Add print_in_format_impl lint 2022-02-25 21:10:06 +00:00
Florian Nagel
862211d540 Disable `[new-without-default]` for new() methods that are marked with '#[doc(hidden)]'
Fixes issue #8152
2022-02-25 16:34:37 +01:00
J-ZhengLi
30fb8229e1 add tests, add base bone for the new lint 2022-02-25 18:08:52 +08:00
Vadim Petrochenkov
a30eba2c7e Update clippy tests 2022-02-24 22:55:40 +03:00
tamaron
db62821c03 fix 2022-02-24 00:16:24 +09:00
Jason Newcomb
382b3f0601 Fix counting the number of unchangeable arguments in ptr_arg 2022-02-23 01:04:49 -05:00
Ken Matsui
7412e6976e
Use the precise namespace for Reverse 2022-02-23 06:06:09 +09:00
bors
9e605ef80f Auto merge of #8443 - Jarcho:match_cfg_arm, r=flip1995
Don't lint `match` expressions with `cfg`ed arms

Somehow there are no open issues related to this for any of the affected lints. At least none that I could fine from a quick search.

changelog: Don't lint `match` expressions with `cfg`ed arms in many cases
2022-02-21 08:46:42 +00:00
tamaron
e3b5cac3c8 fix 2022-02-21 13:25:53 +09:00
Jason Newcomb
d28d19d74c Fix transmute_undefined_repr when converting between a fat pointer and a type containing a fat pointer 2022-02-18 15:02:28 -05:00
Jason Newcomb
7c07022c98 Allow transmuting fat pointers to some types in transmute_undefined_repr 2022-02-18 15:02:28 -05:00
Jason Newcomb
447a24588a Allow various type erasure patterns in transmute_undefined_repr 2022-02-18 15:02:25 -05:00
Jason Newcomb
c02dff7167 Fix transmute_undefined_repr when converting between a pointer and a type containing a pointer 2022-02-18 15:01:58 -05:00
Jason Newcomb
90bb7a3476 New lint cast_enum_truncation 2022-02-18 09:16:17 -05:00
Jason Newcomb
8a466454ab Lint enum-to-int casts with cast_possible_truncation 2022-02-18 09:11:15 -05:00
bors
02f3c17593 Auto merge of #8419 - flip1995:await_parking_alot, r=llogiq
Fix `await_holding_lock` not linting `parking_lot` Mutex/RwLock

This adds tests for `RwLock` and `parking_lot::{Mutex, RwLock}`, which were added before in 2dc8c083f5, but never tested in UI tests. I noticed this while reading [fasterthanli.me](https://fasterthanli.me/articles/a-rust-match-made-in-hell) latest blog post, complaining that Clippy doesn't catch this for `parking_lot`. (Too many people read his blog, he's too powerful)

Some more things:
- Adds a test for #6446
- Improves the lint message

changelog: [`await_holding_lock`]: Now also lints for `parking_lot::{Mutex, RwLock}`
2022-02-18 10:55:05 +00:00
bors
a703a82035 Auto merge of #94088 - oli-obk:revert, r=jackh726
Revert #91403

fixes #94004

r? `@pnkfelix` `@cjgillot`
2022-02-18 07:35:37 +00:00
bors
76f91b6f5a Auto merge of #8442 - rsmantini:issue-8120-fix, r=Manishearth
trigger  `ptr_as_ptr` inside macros

This PR makes `ptr_as_ptr` trigger inside macros

Fixes issue #8120

changelog: ``[`ptr_as_ptr`]`` is now triggered inside macros

r? `@llogiq`
2022-02-17 22:57:23 +00:00
Jason Newcomb
8912d659cd Remove hack testing for cfg attribute in match_single_binding 2022-02-17 14:16:21 -05:00
Rodrigo Mantini
aaeeed6a59 trigger ptr_as_ptr inside macros 2022-02-17 20:16:14 +01:00
Jason Newcomb
8ce2d46cac Check for cfg attrubutes before linting match expressions 2022-02-17 14:04:10 -05:00
flip1995
c5709419b1
Add test for drop-before-await FP 2022-02-17 18:03:13 +01:00
flip1995
c4944fb60d
Actually lint parking_lot in await_holding_lock
This adapts the paths for the parking_lot mutex guards, so that
parking_lot mutexes and RwLocks actually get linted. This is now also
tested.
2022-02-17 18:02:31 +01:00
flip1995
cdf9a28006
Improve lint message of await_holding_*
Improves the message of the lints await_holding_lock and
await_holding_refcell_ref. Now also actually tests RwLock.
2022-02-17 18:00:40 +01:00
bors
668b3e47f9 Auto merge of #8218 - Jarcho:redundant_slicing_deref, r=camsteffen
Improve `redundant_slicing` lint

fixes #7972
fixes #7257

This can supersede #7976

changelog: Fix suggestion for `redundant_slicing` when re-borrowing for a method call
changelog: New lint `deref_as_slicing`
2022-02-17 16:08:45 +00:00
Oli Scherer
4abaa0239a Revert "Auto merge of #91403 - cjgillot:inherit-async, r=oli-obk"
This reverts commit 3cfa4def7c87d571bd46d92fed608edf8fad236e, reversing
changes made to 5d8767cb229b097fedb1dd4bd9420d463c37774f.
2022-02-17 16:00:04 +00:00
bors
7ee2081fb6 Auto merge of #8441 - Jarcho:needless_borrow_temp, r=flip1995
Don't lint `needless_borrow` in method receiver positions

fixes #8408
fixes #8407
fixes #8391
fixes #8367
fixes #8380

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.
2022-02-17 15:51:30 +00:00
Jason Newcomb
9af2be8e96 Don't lint needless_borrow in method receiver positions 2022-02-17 16:21:53 +01:00
bors
a4cf91b9c8 Auto merge of #8433 - hellow554:update_default_trait, r=flip1995
Don't lint Default::default if it is the udpate syntax base

changelog: Don't lint `Default::default` it is part of the update syntax

Current clippy warns about this:

```
warning: calling `Foo::default()` is more clear than this expression
  --> src/main.rs:12:11
   |
12 |         ..Default::default()
   |           ^^^^^^^^^^^^^^^^^^ help: try: `Foo::default()`
   |
```

With these changes, it will not lint that particular expression anymore.
2022-02-17 09:13:30 +00:00
Marcel Hellwig
504f3af70e Don't lint Default::default if it is the udpate syntax base
An Update Syntax looks like this:

   Foo {
      a: 3,
      ..Default::default()
    }

Don't lint `Default::default` here
2022-02-17 10:04:25 +01:00
Jason Newcomb
7724d6773d Move some cases from redundant_slicing to deref_by_slicing 2022-02-17 00:02:33 -05:00
Jason Newcomb
113ac6e15e Split off new lint deref_by_slicing from redundant_slicing 2022-02-17 00:02:26 -05:00
Jason Newcomb
4bdc97c4a6 Account for auto-borrows and precedence in redundant_slicing lint 2022-02-16 23:52:23 -05:00
Jason Newcomb
faeeef3b9c Improve redundant_slicing lint
* Lint when slicing triggers auto-deref
* Lint when slicing returns the same type as dereferencing
2022-02-16 23:52:23 -05:00
Jason Newcomb
a135b52102 Don't lint needless_borrow in method receiver positions 2022-02-16 23:14:39 -05:00
James McMurray
b162b11abc 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.)
2022-02-14 18:49:51 +01:00
bors
4931cab709 Auto merge of #8425 - Jarcho:transmute_8417, r=giraffate
Fix `transmute_undefined_repr` with single field `#[repr(C)]` structs

Fixes: #8417

The description has also been made more precise.

changelog: Fix `transmute_undefined_repr` with single field `#[repr(C)]` structs
changelog: Move `transmute_undefined_repr` back to `correctness`
2022-02-14 06:58:51 +00:00
nsunderland1
78c2e0bfe9 Document pub requirement for new_without_default lint 2022-02-13 17:07:14 -08:00