Commit graph

16107 commits

Author SHA1 Message Date
Kyle Huey
755ae3fa29 Fix spelling while we're in the neighborhood. 2023-01-04 14:58:07 -08:00
Andre Bogus
05ba519a3a trim paths in default_trait_access/clone_on_copy suggestions 2023-01-04 23:39:46 +01:00
Kyle Huey
d0c1605d51 Make the iter_kv_map lint handle ref/mut annotations.
For the degenerate (`map(|(k, _)| k)`/`map(|(_, v)| v)`) cases a mut annotation is superfluous and a ref annotation won't compile, so no additional handling is required. For cases where the `map` call must be preserved ref/mut annotations should also be presereved so that the map body continues to work as expected.
2023-01-04 13:32:34 -08:00
bors
d39dd869a5 Auto merge of #10140 - chansuke:chore/add-comment-for-enclosing-block, r=Alexendoo
chore: add simple comment for `get_enclosing_block`

I was reading the code of `clippy_utils/src/lib.rs` and thought that adding comment on `get_closing_block` would be helpful to first time visitor.

---

changelog: none
<!-- changelog_checked -->
2023-01-04 20:52:31 +00:00
bors
a385d34fc2 Auto merge of #10107 - tylerjw:suggest_path, r=Alexendoo
Suggest using Path for comparing extensions

fixes #10042

changelog: Sugg: [`case_sensitive_file_extension_comparisons`]: Now displays a suggestion with `Path`
[#10107](https://github.com/rust-lang/rust-clippy/pull/10107)
<!-- changelog_checked -->
2023-01-04 19:27:11 +00:00
Tyler Weaver
ea6ff7ed04
Apply changes suggested in review 2023-01-04 07:06:07 -07:00
Michael Goulet
70f6c478f6 get_parent and find_parent 2023-01-04 00:43:13 +00:00
Michael Goulet
bd1d8971cf rename find_parent_node to opt_parent_id 2023-01-04 00:43:13 +00:00
Michael Goulet
73d293fb6d rename get_parent_node to parent_id 2023-01-04 00:43:13 +00:00
Andre Bogus
d3a50d2fda trim paths in box_default 2023-01-04 00:44:20 +01:00
bors
0bca8dd254 Auto merge of #10135 - ardislu:fix-typo, r=giraffate
Fix typo in installation instructions

changelog: none
<!-- changelog_checked -->
2023-01-03 14:17:55 +00:00
bors
8b1ac4539d Auto merge of #10141 - FoseFx:fosefx/9887, r=Jarcho
fix empty_structs_with_brackets suggestion errors

fixes #9887

I refer to [my comment](https://github.com/rust-lang/rust-clippy/issues/9887#issuecomment-1368495395) to explain this PR.

---

changelog: Sugg: [`empty_structs_with_brackets`]: The suggestion is no longer machine applicable, to avoid errors when accessing struct fields
[#10141](https://github.com/rust-lang/rust-clippy/pull/10141)
<!-- changelog_checked -->
2023-01-03 03:57:19 +00:00
bors
43349195f7 Auto merge of #10143 - EricWu2003:field_reassign_with_default-FP, r=Manishearth
don't lint field_reassign when field in closure

fixes #10136

This change makes the ContainsName struct visit all interior expressions, which means that ContainsName will return true even if `name` is used in a closure within `expr`.

---

changelog: FP: [`field_reassign_with_default`]: No longer lints cases, where values are initializes from closures capturing struct values
[#10143](https://github.com/rust-lang/rust-clippy/pull/10143)
<!-- changelog_checked -->
2023-01-03 03:16:18 +00:00
Tyler Weaver
0cee2c5095
Don't trigger lint if last method is to_lower/upper 2023-01-02 16:42:56 -07:00
Eric Wu
cf4e9813b0 use OnlyBodies instead of All
we only need to check closures, so
nestedfilter::All was overkill here.
2023-01-02 18:35:21 -05:00
Tyler Weaver
0aa7d73df3
Only remove method from end of recv, indent suggestion source
Signed-off-by: Tyler Weaver <maybe@tylerjw.dev>
2023-01-02 16:27:46 -07:00
Tyler Weaver
bd83650e91
Suggest using Path for comparing extensions
Signed-off-by: Tyler Weaver <maybe@tylerjw.dev>
2023-01-02 16:27:46 -07:00
bors
1a46dc0b9f Auto merge of #10138 - smoelius:unused_self-typo, r=xFrednet
Fix typo in `unused_self` diagnostic message

changelog: Msg: [`unused_self`]: The message now correctly uses *an*
[#10138](https://github.com/rust-lang/rust-clippy/pull/10138)
<!-- changelog_checked -->
2023-01-02 22:57:27 +00:00
bors
653f5d98d8 Auto merge of #10139 - chansuke:chore/fix-if_chain_ident, r=Jarcho
chore: fix identation of `if_chain` in `filter_map`

This is a really small fix.
If someone could take a look at it, I would appreciate it🙏

---

changelog: none
<!-- changelog_checked -->
2023-01-02 22:44:15 +00:00
bors
3006c7cd4f Auto merge of #10146 - Nilstrieb:💀, r=llogiq
Correct Gankra's name in the linkedlist lint

changelog: [`linkedlist`]: Update description
2023-01-02 20:14:21 +00:00
Nilstrieb
f53c6e2f15 Correct Gankra's name in the linkedlist lint 2023-01-02 19:58:00 +01:00
Andy Russell
9aef1a264a
reword dbg_macro labels 2023-01-02 12:09:26 -05:00
Max Baumann
7a1a9c8188
empty_structs_with_brackets: not MachineApplicable anymore 2023-01-02 14:58:10 +01:00
Eric Wu
01a2a9df43 [drop_ref]: don't lint idiomatic in match arm 2023-01-01 22:33:18 -05:00
Eric Wu
8de011fdf7 don't lint field_reassign when field in closure
This commit makes the ContainsName struct visit all interior
expressions, which means that ContainsName will return true
even if `name` is used in a closure within `expr`.
2023-01-01 21:41:46 -05:00
chansuke
6145194b68 chore: add simple comment for get_enclosing_block 2023-01-02 00:18:03 +09:00
chansuke
5b46f2db59 chore: fix identation of if_chain in filter_map 2023-01-02 00:17:52 +09:00
bors
a85e480dd1 Auto merge of #10110 - Niki4tap:needless_anyhow_return, r=Alexendoo
Fix FN in `needless_return`

Fixes #10051

changelog: Enhancement: [`needless_return`]: Now detects more cases for returns of owned values
[#10110](https://github.com/rust-lang/rust-clippy/pull/10110)
<!-- changelog_checked -->
2023-01-01 13:55:29 +00:00
Samuel Moelius
da7c99b81e Fix typo in unused_self diagnostic message 2023-01-01 06:21:28 -05:00
Ardis Lu
7a64a51818
Fix typo 2022-12-31 02:14:20 -08:00
Trevor Gross
ca5f4a1dee option_if_let_else: update known problems wording 2022-12-30 16:10:21 -05:00
bors
6ccd4ebd5b Auto merge of #10115 - rdrpenguin04:master, r=flip1995
Move `mutex_atomic` to `restriction`

By #4295, the general consensus seems to be that `mutex_atomic` is not a useful lint in most cases. If anything, it could be useful as a restriction on code that for whatever reason can't use atomics. Keeping it in `clippy::nursery` is harmful to people attempting to use clippy for soundness.

---

changelog: Moved [`mutex_atomic`] to `restriction`
[#10115](https://github.com/rust-lang/rust-clippy/pull/10115)
<!-- chnagelog_checked -->
2022-12-30 15:49:12 +00:00
Ray Redondo
0298095ac2 add comment about mutex_atomic issue to description 2022-12-29 14:48:36 -06:00
bors
cd579d69ec Auto merge of #106266 - matthiaskrgr:rollup-cxrdbzy, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #104531 (Provide a better error and a suggestion for `Fn` traits with lifetime params)
 - #105899 (`./x doc library --open` opens `std`)
 - #106190 (Account for multiple multiline spans with empty padding)
 - #106202 (Trim more paths in obligation types)
 - #106234 (rustdoc: simplify settings, help, and copy button CSS by not reusing)
 - #106236 (docs/test: add docs and a UI test for `E0514` and `E0519`)
 - #106259 (Update Clippy)
 - #106260 (Fix index out of bounds issues in rustdoc)
 - #106263 (Formatter should not try to format non-Rust files)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-12-29 19:40:06 +00:00
Matthias Krüger
d8365f9864 Rollup merge of #106259 - flip1995:clippyup, r=matthiaskrgr
Update Clippy

r? `@Manishearth`

I think this was the very first sync with no conflicts whatsoever. I love this time of the year :D
2022-12-29 18:24:32 +01:00
Esteban Küber
315bb10405 Account for multiple multiline spans with empty padding
Instead of

```
LL |    fn oom(
   |  __^
   | | _|
   | ||
LL | || ) {
   | ||_-
LL | |  }
   | |__^
```

emit

```
LL | // fn oom(
LL | || ) {
   | ||_-
LL | |  }
   | |__^
   ```
2022-12-29 09:13:40 -08:00
Philipp Krones
4ccafea92d Merge commit '4f3ab69ea0a0908260944443c739426cc384ae1a' into clippyup 2022-12-29 14:28:34 +01:00
bors
4f3ab69ea0 Auto merge of #10126 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

Love this time of the year. No conflicts, because no one merges anything.

changelog: none
2022-12-29 13:26:43 +00:00
Philipp Krones
1f971866d1
Bump nightly version -> 2022-12-29 2022-12-29 14:24:44 +01:00
Philipp Krones
08535408e8
Merge remote-tracking branch 'upstream/master' into rustup 2022-12-29 14:24:30 +01:00
bors
22af8fe683 Auto merge of #10060 - alex-semenyuk:match_single_binding_fix, r=llogiq
Fix [match_single_binding] suggestion introduced an extra semicolon

Fix #9725

---

changelog: [`match_single_binding`]: suggestion no longer introduces unneeded semicolons
[#10060](https://github.com/rust-lang/rust-clippy/pull/10060)
<!-- changelog_checked -->
2022-12-29 09:23:03 +00:00
Nilstrieb
c617a8e01c Rename Rptr to Ref in AST and HIR
The name makes a lot more sense, and `ty::TyKind` calls it `Ref` already
as well.
2022-12-28 18:52:36 +01:00
bors
266eef7701 Auto merge of #10119 - koka831:doc/config-default-value, r=xFrednet
fix codeblocks in the document

While I've looked into https://github.com/rust-lang/rust-clippy/issues/9990, I found broken code blocks in the document.

This patch not only improves visibility, but also fixes a potential bug. When a lint description ends with code block, the string will have three backquotes at the end.
Since the current implementation prints the default value immediately after that, the markdown renderer is unable to properly close the code block.

e.g. `arithmetic_side_effects`, we can see code block is not rendered properly, and (I think) it's bit hard to understand what ``"defaults to `[]`"`` is meant.

![2022-12-26_01-51](https://user-images.githubusercontent.com/14945055/209476342-4d0b2e18-44b6-4c74-8c3c-4f4f0904e8ca.png)

In this PR, it will be rendered as:

![image](https://user-images.githubusercontent.com/14945055/209476353-07587b86-1100-445f-946d-41f62f741e51.png)

changelog: none

r? `@xFrednet`
2022-12-28 13:53:34 +00:00
bors
d98e714988 Auto merge of #10113 - EricWu2003:suboptimal_flops_incorrect_suggestion, r=Jarcho
fix incorrect suggestion in `suboptimal_flops`

fixes #10003

There was an error when trying to negate an expression like `x - 1.0`. We used to format it as `-x - 1.0` whereas a proper negation would be `-(x - 1.0)`.

Therefore, we add parentheses around the expression when it is `ExprKind::Binary`.

We also add parentheses around multiply and divide expressions, even though this is not strictly necessary.

changelog: [`suboptimal_flops`]: fix incorrect suggestion caused by an incorrect negation of floating point expressions.
2022-12-26 02:00:26 +00:00
Eric Wu
6bb6dd64d4 fix incorrect suggestion in suboptimal_flops
There was an error when trying to negate an expression
like `x - 1.0`. We used to format it as `-x - 1.0` whereas
a proper negation would be `-(x - 1.0)`.

Therefore, we add parentheses around the expression when it is a
Binary ExprKind.

We also add parentheses around multiply and divide expressions,
even though this is not strictly necessary.
2022-12-25 16:56:46 -05:00
koka
fae19a9a79
Place default values near its definitions
This patch not only improves visibility, but also fixes a potential bug.
When a lint description ends with code block, the string will have three
backquotes at the end.
Since the current implementation prints the default value immediately
after that, the markdown renderer is unable to properly close the code
block.
2022-12-26 01:51:46 +09:00
bors
4f1bae0c96 Auto merge of #10116 - tgross35:patch-1, r=llogiq
`not_unsafe_ptr_arg_deref` update documentation

changelog: [`not_unsafe_ptr_arg_deref`]: strengthened documentation wording, fixes #7714
2022-12-25 14:19:10 +00:00
Trevor Gross
12f2dea229 not_unsafe_ptr_arg_deref update documentation 2022-12-25 07:30:21 -05:00
Ray Redondo
0e5fcb7b7f move mutex_atomic to clippy::restriction 2022-12-24 23:47:14 -06:00
bors
e8703a0ce2 Auto merge of #10098 - lukaslueg:size_of_ref, r=Jarcho
Add size_of_ref lint

This addresses #9995, which is likely raising a valid point about `std::mem::size_of_val()`: It's [very easy to use double-references as the argument](https://github.com/apache/arrow-datafusion/pull/4371#discussion_r1032385224), which the function will happily accept and give back the size of _the reference_, not the size of the value _behind_ the reference. In the worst case, if the value matches the programmer's expectation, this seems to work, while in fact, everything will go horribly wrong e.g. on a different platform.

The size of a `&T` is independent of what `T` is, and people might want to use `std::mem::size_of_val()` to actually get the size of _any_ reference (e.g. via `&&()`). I would rather suggest that this is always bad behavior, though ([instead](https://doc.rust-lang.org/reference/type-layout.html#pointers-and-references-layout), [and](https://doc.rust-lang.org/stable/std/primitive.usize.html#associatedconstant.BITS)). I, therefore, put this lint into `correctness`.

Since the problem is usually easily fixed by removing extra `&`, I went light on suggesting code.

---

changelog: New lint: [`size_of_ref`]
[#10098](https://github.com/rust-lang/rust-clippy/pull/10098)
<!-- changelog_checked -->
2022-12-24 23:33:13 +00:00