Commit graph

1206 commits

Author SHA1 Message Date
Jason Newcomb
79247d95f7 Split part of needless_borrow into needless_borrows_for_generic_args 2023-09-17 09:48:12 -04:00
y21
981e96008b new lint: path_ends_with_ext 2023-09-15 16:17:51 +02:00
jonboh
f136e1634a new unnecessary_map_on_constructor lint 2023-09-12 17:32:11 +02:00
Alex Macleod
b99921a5e8 Rename incorrect_impls to non_canonical_impls, move them to warn by default 2023-09-08 13:15:51 +00:00
y21
b54bac9f14 new lint: missing_assert_for_indexing 2023-08-31 17:44:19 +02:00
bors
c50d86fc6a Auto merge of #11418 - Benjscho:explicit_iter_loop_config, r=llogiq
Add config flag for reborrows in explicit_iter_loop

This PR adds a config flag for enforcing explicit into iter lint for reborrowed values. The config flag, `enforce_iter_loop_reborrow`, can be added to clippy.toml files to enable the linting behaviour. By default the reborrow lint is disabled.

fixes: #11074

changelog: [`explicit_iter_loop`]: add config flag `enforce_iter_loop_reborrow` to disable reborrow linting by default
2023-08-31 11:19:04 +00:00
Ben Schofield
55bd0fe296 Fix metadata collection 2023-08-30 16:02:37 -07:00
bors
3da21b089f Auto merge of #11396 - y21:issue11345, r=Jarcho
new lint: `iter_out_of_bounds`

Closes #11345

The original idea in the linked issue seemed to be just about arrays afaict, but I extended this to catch some other iterator sources such as `iter::once` or `iter::empty`.

I'm not entirely sure if this name makes a lot of sense now that it's not just about arrays anymore (specifically, not sure if you can call `.take(1)` on an `iter::Empty` to be "out of bounds"?).

changelog: [`iter_out_of_bounds`]: new lint
2023-08-30 19:51:32 +00:00
xFrednet
fe38aaad66
Update changelog stable note 2023-08-24 20:41:26 +02:00
y21
86b6644379 new lint: iter_out_of_bounds 2023-08-24 20:21:55 +02:00
y21
09506f49c1 rename lint, docs, improve diagnostics 2023-08-23 17:06:55 +02:00
y21
42bd6d7af3 new lint: implied_bounds_in_impl 2023-08-23 17:05:55 +02:00
Red Rapious
7fbf808a50 Added new lint: reserve_after_initialization 2023-08-21 18:50:53 +02:00
y21
e52bd6f850 new lint: should_panic_without_expect 2023-08-18 18:57:14 +02:00
xFrednet
8f06b19b45
Changelog for Rust 1.72 🏖️ 2023-08-18 18:27:11 +02:00
Morten Lohne
1d61fc1b0a Rename 'impossible_double_const_comparisons' -> 'impossible_comparisons' and 'ineffective_double_const_comparisons' -> 'redundant_comparisons', after discussion on Zulip 2023-08-05 21:28:08 +02:00
Morten Lohne
046d3df35e New lints: impossible_double_const_comparisons and ineffective_double_const_comparisons 2023-08-05 21:28:08 +02:00
bors
1eb254ef83 Auto merge of #11242 - samueltardieu:issue-11238, r=Centri3,giraffate
New lint `ignored_unit_patterns`

This idea comes from #11238. I've put the lint in `pedantic` as it might trigger numerous positives (three in Clippy itself).

changelog: [`ignored_unit_patterns`]: new lint
2023-08-03 01:04:39 +00:00
Samuel "Sam" Tardieu
f9a6dfa60d New lint ignored_unit_patterns 2023-07-31 22:00:53 +02:00
y21
136339f2d3 new lint: [readonly_write_lock] 2023-07-27 21:19:35 +02:00
Catherine
978b1daf99 New lint [filter_map_bool_then] 2023-07-25 17:42:36 -05:00
bors
31f37693e9 Auto merge of #11031 - Centri3:needless_return, r=giraffate
New lint [`needless_return_with_try`]

Closes #10902

Rather than having a config option, this will just suggest removing the "return"; if `try_err` is used as well, then it'll be added again but without the `?`.

changelog: New lint [`needless_return_with_try`]
2023-07-24 13:17:50 +00:00
bors
e4923c21c8 Auto merge of #10120 - smoelius:or_insert_with, r=blyxyas
`unwrap_or_else_default` -> `unwrap_or_default` and improve resulting lint

Resolves #10080 (though it doesn't implement exactly what's described there)

This PR does the following:
1. Merges `unwrap_or_else_default.rs`'s code into `or_fun_call.rs`
2. Extracts the code to handle `unwrap_or(/* default value */)` and similar, and moves it into `unwrap_or_else_default`
3. Implements the missing functionality from #9342, e.g.,, to handle `or_insert_with(Default::default)`
4. Renames `unwrap_or_else_default` to `unwrap_or_default` (since the "new" lint handles both `unwrap_or` and `unwrap_or_else`, it seemed sensible to use the shortened name)

This PR is currently two commits. The first implements 1-3, the second implements 4.

A word about 2: the `or_fun_call` lint currently produces warnings like the following:
```
error: use of `unwrap_or` followed by a call to `new`
  --> $DIR/or_fun_call.rs:56:14
   |
LL |     with_new.unwrap_or(Vec::new());
   |              ^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()`
```
To me, such warnings look like they should come from `unwrap_or_else_default`, not `or_fun_call`, especially since `or_fun_call` is [in the nursery](https://github.com/rust-lang/rust-clippy/pull/9829).

---

changelog: Move: Renamed `unwrap_or_else_default` to [`unwrap_or_default`]
[#10120](https://github.com/rust-lang/rust-clippy/pull/10120)
changelog: Enhancement: [`unwrap_or_default`]: Now handles more functions, like `or_insert_with`
[#10120](https://github.com/rust-lang/rust-clippy/pull/10120)
<!-- changelog_checked-->
2023-07-23 20:28:07 +00:00
Centri3
51b57723d1 new lint redundant_guards 2023-07-22 06:28:05 -05:00
Max Niederman
008ba2b8bb
new lint: redundant_local
fix dogfood lints in `redundant_local`

keep `redundant_local` from running in proc macros

rewrite `redundant_local` as late pass

make redundant_local's `find_binding` more readable

pluralize `redundant_locals` name

add test for `redundant_locals` in macros

test `redundant_locals` in proc macros

use more destructuring in `redundant_locals`

fix: format redundant_locals.rs

ignore needless_pass_by_mut_ref in redundant_locals test
2023-07-21 18:14:03 -07:00
Catherine
9cf1509b25 New lint absolute_paths 2023-07-21 17:26:58 -05:00
bors
d71fbb9db2 Auto merge of #11107 - Centri3:error_impl_error, r=Jarcho
New lint [`error_impl_error`]

Closes #11101

changelog: New lint [`error_impl_error`]
2023-07-20 02:07:27 +00:00
Samuel Moelius
e27977b847 Rename unwrap_or_else_default to unwrap_or_default 2023-07-19 20:36:10 -04:00
Catherine
4c79d8ace5 new lint iter_skip_zero 2023-07-19 03:26:15 -05:00
Catherine
19b0e84187 Remove the configuration option
Also no longer lints non-exported types now
2023-07-19 02:08:33 -05:00
Catherine
9d08502496 New lint [string_lit_chars_any] 2023-07-19 00:38:22 -05:00
Catherine
f4b3bb19c1 Add allow_private_error config option 2023-07-18 10:26:22 -05:00
Catherine
75e1329aac New lint [error_impl_error] 2023-07-18 10:26:12 -05:00
bors
9f0cbfd7df Auto merge of #11140 - Centri3:four_forward_slashes, r=blyxyas
New lint [`four_forward_slashes`]

Closes #9212

changelog: New lint [`four_forward_slashes`]
2023-07-18 12:56:18 +00:00
Catherine
0d59d1d617 Rename to needless_return_with_question_mark 2023-07-18 00:23:41 -05:00
Catherine
c13cb54e25 New lint needless_return_with_try 2023-07-18 00:09:22 -05:00
y21
c3881569af new lint: format_collect 2023-07-17 12:13:34 +02:00
Catherine
885ce610fe New lint [four_forward_slashes]
Make it trim the contents
2023-07-12 19:39:24 -05:00
xFrednet
7a3756add5
Changelog: Add disclaimer about the new format 2023-07-12 14:41:39 +02:00
xFrednet
5ea622c8b2
Changelog for Rust 1.71 👑 2023-07-11 19:41:58 +02:00
bors
b46033e9ce Auto merge of #10900 - GuillaumeGomez:needless-pass-by-ref, r=llogiq
Add `needless_pass_by_ref_mut` lint

changelog: [`needless_pass_by_ref_mut`]: This PR add a new lint `needless_pass_by_ref_mut` which emits a warning in case a `&mut` function argument isn't used mutably. It doesn't warn on trait and trait impls functions.

Fixes #8863.
2023-07-09 14:25:10 +00:00
bors
8e261c09bb Auto merge of #11049 - Centri3:manual_is_infinite, r=blyxyas,xFrednet
New lints [`manual_is_infinite`] and [`manual_is_finite`]

Closes #9665

changelog: New lints [`manual_is_infinite`] and [`manual_is_finite`]
[#11049](https://github.com/rust-lang/rust-clippy/pull/11049)
2023-07-08 18:45:35 +00:00
Centri3
844afbfeba use other instead of self 2023-07-08 13:02:54 -05:00
Centri3
004e89d4cf rename to manual_partial_ord_and_ord_impl
cargo dev fmt

cargo test passes

cargo test passes

refactor a lil

Update bool_comparison.stderr

heavily refactor + bump `clippy::version`

refactor

refactor

check bounds to increase accuracy, and add todos
2023-07-08 13:02:54 -05:00
Centri3
2a1fd22f81 implement manual_partial_ord_impl
first try at this
2023-07-08 13:02:38 -05:00
Alex Macleod
28655266b5 Fix changelog PR listings, create them automatically in fetch_prs_between.sh 2023-07-07 12:07:05 +00:00
Catherine
f12edfdb53 manual_float_methods 2023-07-06 20:27:21 -05:00
y21
8fad54e8f9 new lint: read_line_without_trim 2023-07-03 22:51:38 +02:00
Guillaume Gomez
b41fc6784f Add needless_pass_by_ref lint 2023-07-03 22:25:36 +02:00
bors
c46ddeb9e1 Auto merge of #10987 - y21:type_id_on_box, r=llogiq
new lint: `type_id_on_box`

Closes #7687.

A new lint that detects calling `.type_id()` on `Box<dyn Any>` (and not on the underlying `dyn Any`), which can make up for some pretty confusing bugs!

changelog: new lint: [`type_id_on_box`]
2023-07-03 06:16:14 +00:00
Catherine
354172a18e New lint manual_try_fold 2023-07-01 12:36:02 -05:00
bors
c7bf05c1a4 Auto merge of #11020 - Centri3:tuple_array_conversion, r=llogiq
New lint [`tuple_array_conversions`]

Closes #10748

PS, the implementation is a bit ugly 😅 ~~I will likely refactor soon enough :)~~ Done :D

changelog: New lint [`tuple_array_conversions`]
2023-07-01 15:27:35 +00:00
bors
3d4c536e87 Auto merge of #11013 - Centri3:redundant_rest_pattern, r=giraffate
New lint [`redundant_at_rest_pattern`]

Closes #11011

It's always a great feeling when a new lint triggers on clippy itself 😄

changelog: New lint [`redundant_at_rest_pattern`]
2023-06-29 23:54:35 +00:00
Catherine
bfcc8ba444 New lint tuple_array_conversions 2023-06-29 06:46:00 -05:00
Centri3
8296a338db new lints for visibility 2023-06-28 03:20:21 -05:00
y21
b592d39968 manual_range_pattern -> manual_range_patterns 2023-06-27 22:35:54 +02:00
y21
1d4afc5d82 new lint: manual_range_pattern 2023-06-27 22:34:31 +02:00
Catherine
e9ced12512 Rename the lint 2023-06-27 06:31:04 -05:00
Catherine
9a8347ded5 New lint [redundant_rest_pattern] 2023-06-27 06:06:56 -05:00
Centri3
8cb6c86996 change category and refactor
Update raw_strings.rs

Revert "new lints for visibility"

This reverts commit 0e5a537d209727169769dc19cf86aef27122c092.

new lints for visibility
2023-06-27 05:16:40 -05:00
Centri3
cb52d19ce1 don't lint needless_raw_string_hashes when it's unnecessary 2023-06-27 05:12:00 -05:00
Centri3
bc744eb82b new lint needless_raw_string + refactor a bit
Thanks, #112373, for the snippet at line 75!
2023-06-27 05:12:00 -05:00
Centri3
1bf74fc303 add needless_raw_string_hashes lint
add semicolon in doctest
2023-06-27 05:12:00 -05:00
blyxyas
aea731ebdb
update changelog's data ranges 2023-06-26 13:48:49 +02:00
bors
8fd021f504 Auto merge of #10986 - Centri3:undocumented_unsafe_blocks, r=Manishearth
Allow safety comment above attributes

Closes #8679

changelog: Enhancement: [`undocumented_safety_block`]: Added `accept-comment-above-attributes` configuration.
2023-06-20 05:04:46 +00:00
Centri3
cc2e49f695 allow safety comment above attributes 2023-06-19 23:46:57 -05:00
y21
c5a9adc2be new lint: type_id_on_box 2023-06-18 22:20:10 +02:00
Centri3
07dbcbda12 new lint single_call_fn 2023-06-17 20:01:06 -05:00
Renato Lochetti
d6102018bf
Collecting metadata 2023-06-17 09:40:51 -03:00
bors
87b5f89497 Auto merge of #10925 - Centri3:needless_clone_impl2, r=xFrednet
add lint [`incorrect_clone_impl_on_copy_type`]

Split off from #10788.

Closes #10700

----

changelog: new lint [`incorrect_clone_impl_on_copy_type`]
[#10925](https://github.com/rust-lang/rust-clippy/pull/10925)
2023-06-16 08:09:18 +00:00
y21
2748ab9565 new lint: drain_collect 2023-06-15 20:23:11 +02:00
Centri3
10cc1684ce rename lint and disallow clone_from 2023-06-15 07:04:47 -05:00
Centri3
67d5e6ec39 add lint [needless_clone_impl]
Update needless_impls.rs
2023-06-15 07:04:36 -05:00
bors
823d9dd503 Auto merge of #10934 - Centri3:single_range_in_vec_init, r=giraffate
new lint [`single_range_in_vec_init`]

Lints on `vec![0..200]` (or `[0..200]`), suggesting either `(0..200).collect::<Vec<i32>>()` or `[0; 200]`.

Haven't tested it with anything that isn't primitive. Probably should!

Closes #10932

changelog: new lint [`single_range_in_vec_init`]
2023-06-14 23:57:03 +00:00
blyxyas
d5b2f11340
Now cargo collect-metadata updates the CHANGELOG.md 2023-06-13 16:52:18 +02:00
Centri3
6702c7a7a6 Add lint [single_range_in_vec_init] 2023-06-12 11:09:52 -05:00
Pavan Kumar Sunkara
7ed7283e0f Recognize unwrap_or_else method 2023-06-12 16:19:26 +01:00
y21
c8c7a3c79c fix rebase weirdness 2023-06-12 12:21:38 +02:00
y21
760f91f895 cargo dev update_lints 2023-06-12 12:21:38 +02:00
y21
7312a93a06 new lint: large_stack_frames 2023-06-12 12:21:38 +02:00
Centri3
7cdd87ca4a ignore generics and allow arbitrary threshold 2023-06-12 03:22:01 -05:00
Centri3
e2ecb132a5 rename the lint 2023-06-12 03:21:43 -05:00
Centri3
52cfc997af Add lint single_letter_idents 2023-06-12 03:21:43 -05:00
Centri3
26f50395ba Add needless_if lint 2023-06-10 06:51:03 -05:00
bors
476efe92e7 Auto merge of #10672 - Centri3:excessive-width-lints, r=Alexendoo
Add `excessive_nesting` lint

changelog: new lint [`excessive_nesting`]
2023-06-09 20:47:06 +00:00
avborhanian
339cd14f27 Adds new lint arc_with_non_send_or_sync 2023-06-07 20:53:48 -07:00
Centri3
e68dbc3308 add excessive_nesting
Close code block in example
2023-06-07 18:34:34 -05:00
Centri3
97c10075ec add the excessive_* style lints 2023-06-07 18:22:50 -05:00
Alessio Cosenza
01b1057258
Add redundant type annotations lint 2023-06-05 10:22:42 +02:00
bors
eacd095f76 Auto merge of #10826 - Centri3:endian_bytes, r=Manishearth
Add lints for disallowing usage of `to_xx_bytes` and `from_xx_bytes`

Adds `host_endian_bytes`, `little_endian_bytes` and `big_endian_bytes`

Closes #10765

v - not sure what to put here since this adds 3 lints
changelog: Add `host_endian_bytes`, `little_endian_bytes` and `big_endian_bytes` lints
2023-06-05 02:38:41 +00:00
bors
f0dc0bc1c2 Auto merge of #10862 - xFrednet:changelog-1-70, r=flip1995
Update *Current stable* text in `CHANGELOG.md`

Roses are red,
violets are blue,
the new version was released,
and our changelog too

---

changelog: none
2023-06-02 12:37:52 +00:00
ihciah
ad76687b2f add checking for cfg(features = ...) 2023-06-02 09:01:51 +00:00
xFrednet
a28eb5995f
Update *Current stable* text in CHANGELOG.md 2023-06-01 21:14:07 +02:00
Centri3
3ab6aeefb1 to_xx_bytes implemented, from_xx_bytes todo
Mentioned in #10765
2023-05-31 17:30:23 -05:00
y21
f74ec6b1b8 new lint: missing_field_in_debug
move some strings into consts, more tests

s/missing_field_in_debug/missing_fields_in_debug

dont trigger in macro expansions

make dogfood tests happy

minor cleanups

replace HashSet with FxHashSet

replace match_def_path with match_type

if_chain -> let chains, fix markdown, allow newtype pattern

fmt

consider string literal in `.field()` calls as used

don't intern defined symbol, remove mentions of 'debug_tuple'

special-case PD, account for field access through `Deref`
2023-05-31 23:52:02 +02:00
Fridtjof Stoldt
7dd0ae0262
Change changelog typos
Co-authored-by: Takayuki Nakata <f.seasons017@gmail.com>
2023-05-29 18:54:58 +02:00
xFrednet
4d9303df18
Changelog for Rust 1.70 🔨 2023-05-29 12:00:59 +02:00
bors
a0fd17d3f0 Auto merge of #10779 - Centri3:ptr_cast_constness, r=llogiq
Add new lint `ptr_cast_constness`

This adds a new lint which functions as the opposite side of the coin to `ptr_as_ptr`. Rather than linting only as casts that don't change constness, this lints only constness; suggesting to use `pointer::cast_const` or `pointer::cast_mut` instead.

changelog: new lint [`ptr_cast_constness`]
2023-05-23 21:40:50 +00:00
Samuel "Sam" Tardieu
e6646eb5fd needless_else: new lint to check for empty else clauses 2023-05-22 11:52:26 +02:00
Guillaume Gomez
5328852ad7 Update CHANGELOG 2023-05-19 16:16:37 +02:00