Commit Graph

5719 Commits

Author SHA1 Message Date
bors
ad70bffa9e Auto merge of #8944 - xFrednet:8877-append-doc-idents, r=Manishearth
List configuration values can now be extended instead of replaced

I've seen some `clippy.toml` files, that have a few additions to the default list of a configuration and then a copy of our default. The list will therefore not be updated, when we add new names. This change should make it simple for new users to append values instead of replacing them.

I'm uncertain if the documentation of the `".."` is apparent. Any suggestions are welcome. I've also check that the lint list displays the examples correctly.

<details>
<summary>Lint list screenshots</summary>

![image](https://user-images.githubusercontent.com/17087237/171999434-393f2f83-09aa-4bab-8b05-bd4973150f27.png)

![image](https://user-images.githubusercontent.com/17087237/171999401-e6942b53-25e6-4b09-89e5-d867c7463156.png)

</details>

---

changelog: enhancement: [`doc_markdown`]: Users can now indicate, that the `doc-valid-idents` should extend the default and not replace it
changelog: enhancement: [`blacklisted-name`]: Users can now indicate, that the `blacklisted-names` should extend the default and not replace it

Closes: #8877

That's it. Have a fantastic weekend to everyone reading this. Here is a cookie 🍪
2022-06-06 16:34:27 +00:00
Dennis Luxen
8ba377a783 Fix names to use plural 2022-06-05 22:47:21 +02:00
Dennis Luxen
0409306bb0 Implement support for implicit start and end 2022-06-05 22:46:53 +02:00
Dennis Luxen
90c8463d7e Rewrite check to account for floating point literals 2022-06-05 22:46:34 +02:00
Dennis Luxen
5948959c7e Fix misnomer braces -> parenthesis 2022-06-05 22:46:23 +02:00
Dennis Luxen
ba43f0aee9 Add new lint [needless_braces_on_range_literal] 2022-06-05 22:45:57 +02:00
bors
3e52dee646 Auto merge of #8941 - DevAccentor:for_loops_over_fallibles, r=llogiq
improve [`for_loops_over_fallibles`] to detect the usage of iter, iter_mut and into_iterator

fix #6762

detects code like
```rust
for _ in option.iter() {
    //..
}
```

changelog: Improve [`for_loops_over_fallibles`] to detect `for _ in option.iter() {}` or using `iter_mut()` or `into_iterator()`.
2022-06-05 11:16:37 +00:00
DevAccentor
3737abe802 change based on review 2022-06-05 10:26:29 +02:00
xFrednet
c31b4a9d21
List configuration values can now be extended instead of replaced 2022-06-04 16:03:25 +02:00
bors
542d474d38 Auto merge of #8930 - kyoto7250:issue_8920, r=Alexendoo
fix(manual_find_map and manual_filter_map): check clone method

close #8920

Added conditional branching when the clone method is used.

Thank you in advance.

---

changelog: check `clone()` and other variant preserving methods in [`manual_find_map`] and [`manual_filter_map`]
2022-06-04 13:05:27 +00:00
kyoto7250
42cf98553a refactor: check copied and cloned 2022-06-04 21:28:14 +09:00
DevAccentor
5a49918f36 improve for_loops_over_fallibles to detect the usage of iter, iter_mut and into_iterator 2022-06-04 11:11:00 +02:00
kyoto7250
990f8bf5a6 refactor: Add some methods 2022-06-04 17:15:55 +09:00
DevAccentor
64fe4e32db add as_underscore lint 2022-06-03 18:11:23 +02:00
Ariel Uy
58cd01c2fc Add new lint mismatching_type_param_order
Add new lint for checking if type parameters are consistent between type
definitions and impl blocks.
2022-06-03 00:04:55 -07:00
bors
1194c6369e Auto merge of #8932 - dswij:pr-8879, r=giraffate
`needless_return` checks for macro expr in return stmts

closes #8879

Macro expressions in returns were not checked by `needless_return`. The test added in [this commit](6396a7a425 (diff-a869168cfafb7e6e5010feb76a16389d6c96d59e98113dee5c2b304a5160e43aR51-R55)) seems to have regressed.

changelog: [`needless_return`] checks for macro exprs in return statements
2022-06-03 00:00:23 +00:00
bors
97e5449a70 Auto merge of #8902 - PrestonFrom:add_suggestion_for_move_and_clone_when_not_ref, r=flip1995
When setting suggestion for significant_drop_in_scrutinee, add suggestion for MoveAndClone for non-ref

When trying to set the current suggestion, if the type of the expression
is not a reference and it is not trivially pure clone copy, we should still
trigger and emit a lint message. Since this fix may require cloning an
expensive-to-clone type, do not attempt to offer a suggested fix.

This change means that matches generated from TryDesugar and AwaitDesugar
would normally trigger a lint, but they are out of scope for this lint,
so we will explicitly ignore matches with sources of TryDesugar or
AwaitDesugar.

changelog: Update for ``[`significant_drop_in_scrutinee`]`` to correctly
emit lint messages for cases where the type is not a reference *and*
not trivially pure clone copy.
changelog: [`significant_drop_in_scrutinee`]: No longer lint on Try `?`
and `await` desugared expressions.
2022-06-02 17:16:43 +00:00
bors
e32b66c871 Auto merge of #8906 - rust-lang:copy-large-enum-variants, r=Jarcho
remove `large_enum_variant` suggestion for `Copy` types

Replaces the (erroneous) suggestion on `large_enum_variant` for `Copy` types by a note. This fixes #8894.

---

changelog: none
2022-06-02 16:37:09 +00:00
dswij
b885035ef7 needless_return checks for macro expr in return stmts 2022-06-02 20:22:15 +08:00
Andre Bogus
756caf79e6 account for generics 2022-06-02 12:45:15 +02:00
Preston From
bc5a8e9537 Lint message correctly identifies match vs for loop 2022-06-02 02:38:57 -06:00
kyoto7250
007fae10ed fix(manual_find_map and manual_filter_map): check clone method 2022-06-02 09:54:14 +09:00
bors
7572b6b757 Auto merge of #8869 - Jarcho:derive_partial_eq_without_eq, r=flip1995
Set correct `ParamEnv` for `derive_partial_eq_without_eq`

fixes #8867

changelog: Handle differing predicates applied by `#[derive(PartialEq)]` and `#[derive(Eq)]` in `derive_partial_eq_without_eq`
2022-06-01 19:27:54 +00:00
bors
c4c413b6fc Auto merge of #7930 - lengyijun:needless_deref_new, r=Jarcho
new lint: `borrow_deref_ref`

changelog: ``[`borrow_deref_ref`]``

Related pr: #6837 #7577
`@Jarcho` Could you please give a review?

`cargo lintcheck` gives no false negative (but tested crates are out-of-date).

TODO:
1. Not sure the name. `deref_on_immutable_ref` or some others?
2022-06-01 16:43:14 +00:00
lengyijun
202fdb9c53 split into borrow_deref_ref.rs and borrow_deref_ref_unfixable.rs 2022-06-01 15:43:48 +00:00
Jason Newcomb
ca78e2428e Add lint swap_ptr_to_ref 2022-05-31 13:08:05 -04:00
bors
5b1a4c0d76 Auto merge of #8884 - evantypanski:manual_range_contains_multiple, r=Manishearth
Fix `manual_range_contains` false negative with chains of `&&` and `||`

Fixes #8745

Since the precedence for `&&` is the same as itself the HIR for a chain of `&&` ends up with a right skewed tree like:

```
     &&
    /  \
  &&   c2
 /  \
... c1
```

So only the leftmost `&&` was actually "fully" checked, the top level was just `c2` and `&&` so the `manual_range_contains` lint won't apply. This change makes it also check `c2` with `c1`.

There's a bit of a hacky solution in the [second commit](257f09776a) to check if the number of open/closing parens in the snippet match. This is to prevent a case like `((x % 2 == 0) || (x < 0)) || (x >= 10)` from offering a suggestion like `((x % 2 == 0) || !(0..10).contains(&x)` which now won't compile.

Any suggestions for that paren hack welcome, kinda new to working on this so not too sure about possible solutions :) it's weird because I don't know how else to check for parens in HIR considering they're removed when lowering AST.

changelog: Fix [`manual_range_contains`] false negative with chains of `&&` and `||`
2022-05-31 16:17:12 +00:00
bors
7000e758c1 Auto merge of #8564 - Jarcho:transmute_erase_regions, r=Alexendoo
Don't lint `useless_transmute` on types with erased regions

fixes #6356
fixes #3340
fixes #2906

This should get a proper fix at some point, but this at least gets the lint running on some types.

cc #5343

changelog: Don't lint `useless_transmute` on types with erased regions
2022-05-31 15:57:27 +00:00
bors
9add456618 Auto merge of #8876 - Alexendoo:cast-abs-to-different-uint, r=dswij,xFrednet
`cast_abs_to_unsigned`: do not remove cast if it's required

Fixes #8873

If `iX` is not cast to `uX` then keep the cast rather than removing it

changelog: [`cast_abs_to_unsigned`]: do not remove cast if it's required
2022-05-31 15:40:03 +00:00
Jason Newcomb
0c6ebf1c6a Move useless_transmute back to complexity 2022-05-31 10:40:40 -04:00
Jason Newcomb
9c9cca3e66 Don't lint useless_transmute on types with erased regions 2022-05-31 10:39:53 -04:00
bors
2466a0507c Auto merge of #8918 - Jarcho:almost_complete_letter_range, r=llogiq
Add lint `almost_complete_letter_range`

fixes #7269

changelog: Add lint `almost_complete_letter_range`
2022-05-31 05:10:42 +00:00
Jason Newcomb
eb2908b4ea Add lint almost_complete_letter_range 2022-05-30 23:20:04 -04:00
bors
e1607e9d31 Auto merge of #8912 - Alexendoo:needless-late-init-ice, r=giraffate
needless_late_init: fix ICE when all branches return the never type

Fixes #8911

When the assignment is done in a match guard or the if condition and all of the branches return the never type `assignment_suggestions` would return an empty `Vec` which caused the ICE. It now returns `None` in that scenario

Also moves some tests to the top of the file

changelog: ICE Fixes: [`needless_late_init`] #8911
2022-05-31 00:46:52 +00:00
bors
588e1982d3 Auto merge of #8913 - InfRandomness:ICE-#8748, r=giraffate
Fix #8748

Thank you for making Clippy better!

changelog: Fix ICE #8748 in shadow.rs
2022-05-31 00:17:52 +00:00
bors
d9f497830c Auto merge of #8899 - botahamec:use-self-tuple-struct-variants, r=Alexendoo
Fix `[use_self]` false negative with on struct and tuple struct patterns

fixes #8845

changelog: Triggered the warning for ``[`use_self`]`` on `TupleStruct` and `Struct` patterns, whereas currently it's only triggered for `Path` patterns
2022-05-30 22:05:13 +00:00
InfRandomness
0a7f19b547 Fix #8748 2022-05-30 22:46:31 +02:00
Micha White
2aa4569303
Triggered the lint on tuple struct and struct patterns 2022-05-30 13:39:18 -04:00
lengyijun
8430fa2a82 run-rustfix 2022-05-30 01:49:46 +00:00
lyj
c5410150eb needless_deref 2022-05-30 01:46:15 +00:00
Alex Macleod
722f7d28c3 needless_late_init: fix ICE when all branches return the never type 2022-05-29 18:39:27 +00:00
bors
39231b4b50 Auto merge of #8385 - cameron1024:doc_link_with_quotes, r=llogiq
add doc_link_with_quotes lint

I'm not sure about wording, it seems OK to me but happy to change if other people have better ideas

closes #8383

---
changelog: add [`doc_link_with_quotes`] lint
2022-05-28 14:27:51 +00:00
bors
5920fa3516 Auto merge of #8844 - smoelius:fixed-paths, r=Alexendoo
Check `.fixed` paths' existence in `run_ui`

This PR adds a test to check that there exists a `.fixed` file for every `.stderr` file in `tests/ui` that mentions a `MachineApplicable` lint. The test leverages `compiletest-rs`'s `rustfix_coverage` option.

I tried to add `.fixed` files where they appeared to be missing. However, 38 exceptional `.rs` files remain. Several of those include comments indicating that they are exceptions, though not all do. Apologies, as I have not tried to associate the 38 files with GH issues. (I think that would be a lot of work, and I worry about linking the wrong issue.)

changelog: none
2022-05-28 11:28:04 +00:00
llogiq
c9be57dbf3
Merge branch 'master' into doc_link_with_quotes 2022-05-28 10:55:25 +02:00
Andre Bogus
19f94d52b3 remove large_enum_variant suggestion for Copy types 2022-05-28 01:36:05 +02:00
Samuel E. Moelius III
6027255eb2 Ignore crashes dir 2022-05-27 16:44:02 -04:00
bors
1dd55471b4 Auto merge of #8892 - smoelius:fix-empty-line-false-positive, r=Manishearth
Fix `empty_line_after_outer_attribute` false positive

This PR fixes a false positive in `empty_line_after_outer_attribute`.

Here is a minimal example that trigger the FP:
```rust
#[derive(clap::Parser)]
#[clap(after_help = "This ia a help message.

You're welcome.
")]
pub struct Args;
```

changelog: PF: [`empty_line_after_outer_attribute`]: No longer lints empty lines in inner string values.
2022-05-27 20:34:06 +00:00
bors
461a6613cf Auto merge of #8897 - tamaroning:improve_dbg, r=Alexendoo
Introduce `allow-dbg-in-tests` config value

related to: Issue #8758,  PR https://github.com/rust-lang/rust-clippy/pull/8838

changelog: Introduced `allow-dbg-in-tests` config value. [dbg_macro] does not allow `dbg!` in test code by default.
2022-05-27 19:41:39 +00:00
Samuel E. Moelius III
8f49e4127f Fix assert! message 2022-05-27 15:18:46 -04:00
Samuel E. Moelius III
c91a7f0b83 Address review comments 2022-05-27 15:18:46 -04:00