Commit graph

14780 commits

Author SHA1 Message Date
bors
f4f5bb4328 Auto merge of #9327 - Serial-ATA:non_ascii_literal_macro, r=Alexendoo
Fix [`non_ascii_literal`] in tests

changelog: Don't lint [`non_ascii_literal`] when using non-ascii comments in tests
changelog: Don't lint [`non_ascii_literal`] when `allow`ed on tests

closes: #7739
closes: #8263
2022-08-16 20:22:39 +00:00
Serial
bd121eff8a Fix [non_ascii_literal] in tests 2022-08-16 15:53:01 -04:00
bors
048e4d004a Auto merge of #9340 - alex-semenyuk:box_t, r=dswij
Fix example

The example didn't show the actual problem [playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=9d0e0727ca5bbd854767f50da693ca0f)
changelog: none
2022-08-16 13:27:10 +00:00
bors
86ac6e88a8 Auto merge of #9040 - miam-miam100:unused_named_parameter, r=dswij
Add new lint [`positional_named_format_parameters`]

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: Add new lint [`positional_named_format_parameters`] to warn when named parameters in format strings are used as positional arguments.
2022-08-16 13:11:27 +00:00
alexey semenyuk
9e9b3ddf69
Fix example 2022-08-16 12:50:53 +03:00
bors
a427b12803 Auto merge of #9328 - stanislav-tkach:borrow_deref_ref-remove-extra-deref-from-example, r=giraffate
Remove extra dereference from the borrow_deref_ref lint example

I don't think such minor change should be mentioned in the changelog.

changelog: none
2022-08-16 00:19:21 +00:00
bors
0fc95e88f5 Auto merge of #9318 - lukaslueg:ifletmutexref, r=xFrednet
Fix if_let_mutex not checking Mutexes behind refs

Fixes #9193

We can always peel references because we are looking for a method-call, for which autoderef applies.

---

changelog: [`if_let_mutex`]: detect calls to `Mutex::lock()` if mutex is behind a ref
changelog: [`if_let_mutex`]: Add labels to the two instances of the same Mutex that will deadlock
2022-08-15 21:31:37 +00:00
Stanislav Tkach
7727c303e5
Simplify the borrow_deref_ref lint example 2022-08-15 20:48:40 +02:00
lukaslueg
6de4bdfa8e Fix label not starting with lcase-letter
Co-authored-by: Fridtjof Stoldt <xFrednet@gmail.com>
2022-08-15 20:24:30 +02:00
bors
8c9040ceaa Auto merge of #9329 - xphoniex:fix-#9317, r=flip1995
Skip `unnecessary_to_owned` when `t != t.to_string()`

Fixes #9317

changelog: [`unnecessary_to_owned`]: none
2022-08-15 10:01:20 +00:00
xphoniex
1a2aaf68de
Skip unnecessary_to_owned when t != t.to_string()
Signed-off-by: xphoniex <dj.2dixx@gmail.com>
2022-08-14 16:29:26 +00:00
bors
679fa9f2bf Auto merge of #9187 - sgued:iter-once, r=flip1995
Add lint recommending using `std::iter::once` and `std::iter::empty`

```
changelog: [`iter_once`]: add new lint
changelog: [`iter_empty`]: add new lint
```

fixes #9186

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

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

The lint doesn't really follow the naming conventions. I don't have any better idea so I'm open to suggestions.
2022-08-14 15:45:17 +00:00
bors
84df61c06e Auto merge of #9167 - aldhsu:fix-trait-duplication-false-pos, r=flip1995
Fixes [`trait_duplication_in_bounds`] false positives

Fixes #9076 #9151 #8757.
Partially fixes #8771.

changelog: [`trait_duplication_in_bounds`]: Reduce number of false positives.
2022-08-14 14:46:26 +00:00
bors
4d5d191f6a Auto merge of #9326 - flip1995:version-update, r=xFrednet
Update lint versions for 1.63 release

r? `@xFrednet`

changelog: none
2022-08-13 10:02:57 +00:00
flip1995
f18cd274be
Update lint versions for 1.63 release 2022-08-12 23:19:53 +02:00
bors
dfa780e0ef Auto merge of #9324 - flip1995:changelog, r=xFrednet
1.63 Changelog

r? `@xFrednet`

changelog: none

[Rendered](https://github.com/flip1995/rust-clippy/blob/changelog/CHANGELOG.md)
2022-08-12 21:11:33 +00:00
flip1995
35486cb661
Update Changelog to 1.63 2022-08-12 23:10:23 +02:00
bors
05fc1c7dbc Auto merge of #9289 - mkrasnitski:9094, r=xFrednet
Extend `if_then_some_else_none` to also suggest `bool::then_some`

Closes #9094.

changelog: Extend `if_then_some_else_none` to also suggest `bool::then_some`
2022-08-12 06:25:59 +00:00
Allen Hsu
8bae517c2d Lint trait duplication in one pass. 2022-08-12 12:51:58 +10:00
Michael Krasnitski
f7f60b82e8 Adjust lint description for better clarity 2022-08-11 22:41:25 -04:00
bors
2b2190cb56 Auto merge of #9323 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2022-08-11 17:28:47 +00:00
Philipp Krones
280b527821
Bump Clippy version -> 0.1.65 2022-08-11 19:26:38 +02:00
Philipp Krones
eda0b001e8
Bump nightly version -> 2022-08-11 2022-08-11 19:26:26 +02:00
Philipp Krones
879855bbaf
Merge remote-tracking branch 'upstream/master' into rustup 2022-08-11 19:26:04 +02:00
Lukas Lueg
0428f0d234 Add labels to if_let_mutex 2022-08-10 21:07:07 +02:00
Lukas Lueg
6a73a45418 Fix if_let_mutex not checking Mutexes behind refs
Fixes #9193
2022-08-10 19:40:42 +02:00
miam-miam100
9ffddf563c
Add new lint [positional_named_format_parameters] 2022-08-09 21:03:41 +01:00
bors
f7e2cb4470 Auto merge of #9308 - daxpedda:missing-const-for-fn, r=Jarcho
Use `check_proc_macro` for `missing_const_for_fn`

This uses `@Jarcho's` #8694 implementation to fix `missing_const_for_fn` linting in proc-macros.
I'm not 100% sure what I'm doing here, any feedback is appreciated.

Previously: https://github.com/Jarcho/rust-clippy/pull/1.
Fixes #8854.

changelog: [`missing_const_for_fn`]: No longer lints in proc-macros
2022-08-09 03:44:21 +00:00
dAxpeDDa
fd60581628
Address review take 2 2022-08-09 05:14:03 +02:00
dAxpeDDa
6f5d64842b
Address review 2022-08-09 04:56:04 +02:00
dAxpeDDa
8d4f2ac381
Use check_proc_macro for missing_const_for_fn 2022-08-09 03:41:59 +02:00
bors
3af9072bc6 Auto merge of #9288 - lukaslueg:partialeqnone, r=Jarcho
Add partialeq_to_none lint

Initial implementation of #9275, adding lint `partialeq_to_none`. This is my first time working on `clippy`, so please review carefully.

I'm unsure especially about the `Sugg`, as it covers the entire `BinOp`, instead of just covering one of the sides and the operator (see the multi-line example). I was unsure if pinpointing the suggestion wouldn't be brittle...

changelog: [`PARTIALEQ_TO_NONE`]: Initial commit
2022-08-09 00:12:29 +00:00
Sosthène Guédon
af4885c0cd Rename new lints to iter_on_empty_collections and iter_on_single_items 2022-08-08 21:05:27 +02:00
Sosthène Guédon
b247594a39 Prevent some false positives 2022-08-08 21:04:44 +02:00
Sosthène Guédon
f30d7c2495 Improve suggestions 2022-08-08 21:04:44 +02:00
Sosthène Guédon
f3f86d8fd9 Move iter_once and iter_empty to methods as a late pass
This enables more thorough checking of types to avoid triggering on
custom Some and None enum variants
2022-08-08 21:04:44 +02:00
Sosthène Guédon
332e03146e Fix the lint in clippy itself 2022-08-08 21:04:44 +02:00
Sosthène Guédon
73cd95465e Add iter_once and iter_empty lints 2022-08-08 21:04:41 +02:00
Lukas Lueg
657b0da912 Add partialeq_to_none lint
Fixes #9275
2022-08-08 20:17:13 +02:00
bors
8f390610a5 Auto merge of #9306 - guerinoni:rename-logic-bug, r=llogiq,xFrednet
Rename `logic_bug` to `overly_complex_bool_expr`

Closes #1916

changelog: Rename `logic_bug` to [`overly_complex_bool_expr`]
2022-08-08 17:04:06 +00:00
Federico Guerinoni
f6cab94bd0 Rename logic_bug to overly_complex_bool_expr
Closes #1916
2022-08-08 18:38:39 +02:00
bors
4912c0ece4 Auto merge of #9126 - Jarcho:auto_deref_sugg, r=Manishearth
`explicit_auto_deref` changes

fixes #9123
fixes #9109
fixes #9143
fixes #9101

This avoid suggesting code which hits a rustc bug. Basically `&{x}` won't use auto-deref if the target type is `Sized`.

changelog: Don't suggest using auto deref for block expressions when the target type is `Sized`
changelog: Include the borrow in the suggestion for `explicit_auto_deref`
changelog: Don't lint `explicit_auto_deref` on `dyn Trait` return
changelog: Don't lint `explicit_auto_deref` when other adjustments are required
changelog: Lint `explicit_auto_deref` in implicit return positions for closures
2022-08-08 15:20:24 +00:00
Jason Newcomb
ecb51fe6a5 Lint explicit_auto_deref in implicit return positions for closures 2022-08-08 10:25:05 -04:00
Jason Newcomb
5285928bc0 Fix ICE when checking the HIR ty of closure args. 2022-08-08 10:09:05 -04:00
bors
0ee702514e Auto merge of #9303 - Jarcho:ice_9297, r=Alexendoo
Fix ICE when reading literals with weird proc-macro spans

fixes #9297
changelog: Fix ICE when reading literals with weird proc-macro spans
2022-08-08 11:36:27 +00:00
bors
10853f71f2 Auto merge of #8694 - Jarcho:check_proc_macro, r=xFrednet
More proc-macro detection

fixes #6514
fixes #8683
fixes #6858
fixes #6594

This is a more general way of checking if an expression comes from a macro and could be trivially applied to other lints. Ideally this would be fixed in rustc's proc-macro api, but I don't see that happening any time soon.

changelog: FPs: [`unit_arg`] [`default_trait_access`] [`missing_docs_in_private_items`]: No longer trigger in code generated from proc-macros.
2022-08-08 09:27:33 +00:00
bors
97a0cf2de2 Auto merge of #9302 - Jarcho:sig_drop_nursery, r=flip1995
Move `significant_drop_in_scrutinee` into `nursey`

The current suggestion of extending the lifetime of every sub-expression is not great and doesn't fix the error given in the lint's example, though it does make the potential deadlock easier to see, but it can also cause it's own issues by delaying the drop of the lock guard.

e.g.
```rust
match x.lock().foo {
    ..
}
// some stuff
let y = x.lock();
```
The suggestion would create a deadlock at the second `x.lock()` call.

This also lints even when a significant drop type isn't created as a temporary. (#9072)

I agree `@kpreid` (https://github.com/rust-lang/rust-clippy/issues/8987#issuecomment-1207464440) that this should be back-ported before the lint hits stable.

changelog: Move `significant_drop_in_scrutinee` into `nursey`
2022-08-08 08:28:06 +00:00
Jason Newcomb
99abd4a9f6 Fix ICE when reading literals with weird proc-macro spans 2022-08-07 22:22:17 -04:00
Jason Newcomb
745b194292 Small cleanup for check_proc_macro.rs 2022-08-07 21:55:10 -04:00
Jason Newcomb
8dda974a27 Add note to the docs on is_from_proc_macro 2022-08-07 21:55:10 -04:00