Commit Graph

1119 Commits

Author SHA1 Message Date
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
Centri3
8c191add87 the implementation!! 2023-05-14 19:25:23 -05:00
bors
fff790b659 Auto merge of #10691 - jdswensen:jds/fix-doc-empty-line, r=Jarcho
fix: warn on empty line outer AttrKind::DocComment

changelog: [`empty_line_after_doc_comments`]: add lint for checking empty lines after rustdoc comments.

Fixes: #10395
2023-05-12 16:39:02 +00:00
Icxolu
a8834bc46a add lint manual_next_back
checks for manual reverse iteration (`.rev().next()`) of a
`DoubleEndedIterator`
2023-05-11 22:25:14 +02:00
Jake Swensen
0a4cfbf1f8 fix: warn on empty line outer AttrKind::DocComment
changelog: [`empty_line_after_doc_comments`]: add lint for checking
empty lines after rustdoc comments.

Fixes: #10395
2023-05-10 20:41:23 -05:00
NotAPenguin
56e8e1a27d new lint: clippy::ref_patterns 2023-05-08 13:20:33 +02:00
Philipp Krones
88c7632659
Merge remote-tracking branch 'upstream/master' into rustup 2023-05-05 17:29:35 +02:00
bors
f9c1d155b4 Auto merge of #10716 - Icxolu:unitstruct_default_construction, r=Manishearth
Fixes #10609: Adds lint to detect construction of unit struct using `default`

Using `default` to construct a unit struct increases code complexity and adds a function call. This can be avoided by simply removing the call to `default` and simply construct by name.

changelog: [`default_constructed_unit_structs`]: detects construction of unit structs using `default`

fixes #10609
2023-05-03 21:43:02 +00:00
Icxolu
4e04903631 rename to plural form 2023-05-03 19:25:25 +02:00
y21
8d8178f931 rename lint to manual_while_let_some 2023-04-29 18:59:07 +02:00
y21
bb58083ce5 new lint: while_pop_unwrap 2023-04-29 18:59:06 +02:00
Icxolu
9428138562 adds lint to detect construction of unit struct using default
Using `default` to construct a unit struct increases code complexity and
adds a function call. This can be avoided by simply removing the call to
`default` and simply construct by name.
2023-04-26 21:12:59 +02:00
xFrednet
637d10b292
Catching, stray, commas, (I'll, never, learn, to, use, them, correctly) 😅 2023-04-25 17:33:27 +02:00
bors
7a870aef1a Auto merge of #10432 - samueltardieu:issue-10430, r=Manishearth
New lint: detect `if` expressions with simple boolean assignments to the same target

Closes #10430

changelog: [`needless_bool_assign`] new lint to detect simple boolean assignment to the same target in `if` branches
2023-04-23 15:47:00 +00:00
Samuel Tardieu
69da902f41 Detect if expressions with boolean assignments to the same target 2023-04-23 13:44:49 +02:00
Philipp Krones
a1b75c5108 Merge commit 'a3ed905928a03b6e433d0b429190bf3a847128b3' into clippyup 2023-04-23 13:28:56 +02:00
blyxyas
0354cee137
Add lint items_after_test_module 2023-04-22 21:12:45 +02:00
xFrednet
6ce346c942
Changelog for Rust 1.69 🌸 2023-04-19 16:37:28 +02:00
Philipp Krones
6b95029f17 Merge commit '83e42a2337dadac915c956d125f1d69132f36425' into clippyup 2023-04-11 15:31:08 +02:00
y21
5d01e6e96c new lint: suspicious_doc_comments 2023-04-07 12:04:55 +02:00
Michael Schubart
b66aa09b95 Add [manual_slice_size_calculation] 2023-04-06 11:48:20 +01:00
blyxyas
b2856a763e
Add tests_outside_test_module lint 2023-04-02 00:35:46 +02:00
Samuel "Sam" Tardieu
6601d85c22 Flag bufreader.lines().filter_map(Result::ok) as suspicious 2023-03-31 14:43:30 +02:00
bors
799732cbd8 Auto merge of #10414 - csmoe:large-future, r=xFrednet
add large future lint

Closes #5263

---

changelog: new lint: [`large_futures`]
[#10414](https://github.com/rust-lang/rust-clippy/pull/10414)
<!-- changelog_checked -->
2023-03-30 08:51:29 +00:00
bors
ef3867f394 Auto merge of #9102 - botahamec:unused-box, r=xFrednet
Added the `[unnecessary_box_returns]` lint

fixes #5

I'm not confident in the name of this lint. Let me know if you can think of something better

---

changelog: New lint: ``[`unnecessary_box_returns`]``
[#9102](https://github.com/rust-lang/rust-clippy/pull/9102)
<!-- changelog_checked -->
2023-03-30 08:22:16 +00:00
Micha White
022f76d432
Added the new lint with some docs and tests 2023-03-26 17:49:46 -04:00
bluthej
1d168b31c3
Merge branch 'rust-lang:master' into clear-with-drain 2023-03-26 19:11:38 +02:00
Philipp Krones
8df896c076 Merge commit 'd5e2a7aca55ed49fc943b7a07a8eba05ab5a0079' into clippyup 2023-03-24 14:26:19 +01:00
Samuel "Sam" Tardieu
d7d3dbf060 New lint: detect unnecessary struct building 2023-03-23 20:56:45 +01:00
bluthej
7f44530f54 Create clear_with_drain lint 2023-03-21 22:51:51 +01:00
csmoe
4fdae81c70 add large future lint 2023-03-20 22:51:01 +08:00
Samuel "Sam" Tardieu
ffabdab8cf New lint to detect &std::path::MAIN_SEPARATOR.to_string() 2023-03-16 21:42:04 +01:00
blyxyas
4b9cb857f9
Rename lint 2023-03-15 23:18:25 +01:00
blyxyas
0f1474ea27
Add allow_attribute lint 2023-03-11 00:30:30 +01:00
Philipp Krones
c34d04a3dd
Update changelog for beta-accepted labels 2023-03-10 11:28:10 +01:00
Philipp Krones
cf8a67d9ad Merge commit '3c06e0b1ce003912f8fe0536d3a7fe22558e38cf' into clippyup 2023-03-10 10:53:50 +01:00
xFrednet
7ce9ca0508
Mark Rust 1.68.0 as release in the changelog 2023-03-09 23:09:51 +01:00
blyxyas
ca3bf94c43
Add let_with_type_underscore lint 2023-03-09 17:18:03 +01:00
Samuel Tardieu
d5429eab8a Add new redundant_async_block lint 2023-03-08 10:48:54 +01:00
Burak Varlı
ea2547b8c6 Add missing_assert_message lint
Co-authored-by: Weihang Lo <me@weihanglo.tw>
2023-03-08 08:50:21 +00:00
bors
41fa24cef8 Auto merge of #10415 - schubart:collection_is_never_read, r=llogiq
Add `collection_is_never_read`

Fixes #9267

`@flip1995` and `@llogiq,` I talked with you about this one at Rust Nation in London last week. :-)

This is my first contribution to Clippy, so lots of feedback would be greatly appreciated.

- \[ ] 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`

`dogfood` found one true positive (see #9509) and no false positives.

`lintcheck` found no (true or false) positives, even when running on an extended set of crates.

---

changelog: new lint [`collection_is_never_read`]
[#10415](https://github.com/rust-lang/rust-clippy/pull/10415)
<!-- changelog_checked -->
2023-03-07 13:35:07 +00:00
xFrednet
917ebc3af6
Changelog for Rust 1.68 🐶 2023-02-28 22:06:53 +01:00
Michael Schubart
2a9c254e23 Add collection_is_never_read 2023-02-27 07:14:55 +00:00
Jason Newcomb
0413fb35ba Merge commit '149392b0baa4730c68f3c3eadf5c6ed7b16b85a4' into clippyup 2023-02-25 19:28:50 -05:00
Krishna Sundarram
00c294ad05 Add new lint no_mangle_with_rust_abi 2023-02-23 17:35:06 +00:00
bors
5ef3cc8ca1 Auto merge of #10197 - blyxyas:impl_trait_param, r=Jarcho
Add `impl_trait_in_params` lint

As this is a lint about style, and using `impl Trait` is purely cosmetical (even with downsides), a lot of unrelated files needed to allow this lint.

---

Resolves #10030

changelog: New lint: [`impl_trait_in_params`]
[10197](https://github.com/rust-lang/rust-clippy/pull/10197)
<!-- changelog_checked -->
2023-02-21 03:02:48 +00:00
Jirka Vebr
6d0df84f6f
Add the transmute_int_to_non_zero lint 2023-02-16 16:58:05 +01:00
bors
52c8b536c9 Auto merge of #10342 - mitsuhiko:feature/question-mark-used, r=Alexendoo
Add question-mark-used lint

This lint complains when the question mark operator (try operator) is used.  This is a restriction lint that can be useful on local scopes where a custom error handling macro is supposed to be used to augment the error based on local scope data before returning.

Fixes #10340

---

changelog: New lint [`question_mark_used`]
[#10342](https://github.com/rust-lang/rust-clippy/pull/10342)
<!-- changelog_checked -->
2023-02-16 14:21:43 +00:00
bors
99d4ea4f39 Auto merge of #10356 - JirkaVebr:let_underscore_untyped, r=llogiq
Add `let_underscore_untyped`

Fixes #6842

This adds a new pedantic `let_underscore_untyped` lint which checks for `let _ = <expr>`, and suggests to either provide a type annotation, or to remove the `let` keyword. That way the author is forced to specify the type they intended to ignore, and thus get forced to re-visit the decision should the type of `<expr>` change. Alternatively, they can drop the `let` keyword to truly just ignore the value no matter what.

r? `@llogiq`

changelog: New lint: [let_underscore_untyped]
2023-02-16 12:58:43 +00:00
bors
4369a67a9b Auto merge of #10163 - c410-f3r:lock-1, r=llogiq
[significant_drop_tightening] Add MVP

cc #9399

Creates the lint with minimum functionalities, which is a good start IMO.

---

changelog: new lint: [`significant_drop_tightening`]
[#10163](https://github.com/rust-lang/rust-clippy/pull/10163)
<!-- changelog_checked -->
2023-02-16 12:30:26 +00:00
Jirka Vebr
2d4d39de53
Add the let_underscore_untyped lint 2023-02-16 13:05:33 +01:00
blyxyas
6c9983b936
Exec cargo dev update_lints 2023-02-15 21:34:47 +01:00
blyxyas
ade4c9b2b6
Rename lint to better fit lint naming conventions 2023-02-15 21:34:47 +01:00
blyxyas
8ec9543f13
Add impl_trait_param lint
As this is a lint about "style", and a purely cosmetical choice (using `<A: Trait>` over `impl Trait`), a lot of other files needed to be allowed this lint.
2023-02-15 21:29:58 +01:00
Armin Ronacher
89314a0805 Add question-mark-used lint
This lint complains when the question mark operator (try operator)
is used.  This is a restriction lint that can be useful on local
scopes where a custom error handling macro is supposed to be used
to augment the error based on local scope data before returning.
2023-02-13 20:59:26 +01:00
Caio
078f149aa4 [significant_drop_tightening] Add MVP 2023-02-10 15:07:34 -03:00
Mara Bos
8f56767c94 Update lints. 2023-02-10 19:03:20 +01:00
Philipp Krones
e7fe1f9c14 Merge commit '0f7558148c22e53cd4608773b56cdfa50dcdeac3' into clippyup 2023-02-10 14:01:19 +01:00
Michael Krasnitski
fba16e2e3a Add extra_unused_type_parameters lint 2023-02-02 19:37:34 -05:00
Philipp Krones
5c7a65251a Merge commit '1480cea393d0cee195e59949eabdfbcf1230f7f9' into clippyup 2023-01-27 21:09:08 +01:00
xFrednet
4441753127
Mark Rust 1.67 as released in the changelog 2023-01-26 17:13:40 +01:00
xFrednet
a7ae84bc84
Address PR feedback and change text for early merge 2023-01-20 09:21:41 +01:00
xFrednet
f64efd4d31
Changelog for Rust 1.67 🐞 2023-01-19 22:28:12 +01:00
Niki4tap
875e36f7e4 Add multiple_unsafe_ops_per_block lint 2023-01-18 10:00:31 +03:00
Philipp Krones
d21616737b Merge commit '7f27e2e74ef957baa382dc05cf08df6368165c74' into clippyup 2023-01-12 19:48:13 +01:00
Robert Bastian
8ca900b01c rename 2023-01-10 11:12:54 +01:00
Philipp Krones
4ccafea92d Merge commit '4f3ab69ea0a0908260944443c739426cc384ae1a' into clippyup 2022-12-29 14:28:34 +01:00
Philipp Krones
08535408e8
Merge remote-tracking branch 'upstream/master' into rustup 2022-12-29 14:24:30 +01: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
Lukas Lueg
d7b9e195c2 Add size_of_ref lint
Fixes #9995
2022-12-24 23:39:54 +01:00
alexey semenyuk
faebca37e9
Changelog fix 2022-12-23 14:24:23 +03:00
dboso
30e6e85508 add [permissions_set_readonly_false] #9702 2022-12-20 00:37:51 +09:00
Niki4tap
42106e0495 Add lint fn_null_check 2022-12-18 03:02:45 +03:00
Niki4tap
6afe5471cf Add lint transmute_null_to_fn 2022-12-18 03:02:37 +03:00
Philipp Krones
1c422524c7 Merge commit '4bdfb0741dbcecd5279a2635c3280726db0604b5' into clippyup 2022-12-17 14:12:54 +01:00
bors
3905f51230 Auto merge of #10073 - xFrednet:changelog-1-66, r=Alexendoo
Changelog 1.66

It's really nice to see a changelog with so many suggestion fixes and improvements. Not much else to say. This should be merged with the coming release on 2022-12-15. For the reviewer, please review it and approve it if it looks good. The merge should wait until the release :)

---

changelog: none

<!-- changelog_checked -->
2022-12-15 16:12:12 +00:00
Fridtjof Stoldt
71019aa076
Address review comments <3
Co-authored-by: Takayuki Nakata <f.seasons017@gmail.com>
Co-authored-by: Alex Macleod <alex@macleod.io>
2022-12-14 19:48:49 +01:00
xFrednet
2855a0f117
Changelog for Rust 1.66 🎅 2022-12-13 23:48:27 +01:00
Hannah Town
4c80f210c3 Add lint almost_complete_range
This replaces and expands `almost_complete_letter_range`.
2022-12-09 13:29:50 -05:00
bors
d4cd91c288 Auto merge of #9826 - Veykril:semi-blocks, r=Alexendoo
Add semicolon-outside/inside-block lints

changelog: Add `semicolon_outside_block` and `semicolon_inside_block` lints

Fixes https://github.com/rust-lang/rust-clippy/issues/7322

An earlier attempt at this can be found here https://github.com/rust-lang/rust-clippy/pull/7564. This PR still implements two separate lints but I am open to merging them into a single one that's configurable.
2022-12-09 11:41:24 +00:00
Philipp Krones
d05e2865a0 Merge commit 'd822110d3b5625b9dc80ccc442e06fc3cc851d76' into clippyup 2022-12-01 18:29:38 +01:00
Lukas Wirth
93b5c893e6 Add semicolon-outside/inside-block lints 2022-11-25 17:10:10 +01:00
Lukas Wirth
a116b9bdba Lint unnecessary safety comments on items 2022-11-25 10:09:34 +01:00
Philipp Krones
46c5a5d234 Merge commit 'f4850f7292efa33759b4f7f9b7621268979e9914' into clippyup 2022-11-21 20:51:52 +01:00
Sosthène Guédon
3428da6e00 Fix typo missnamed -> misnamed 2022-11-20 13:45:12 +01:00
Sosthène Guédon
31b83d0895 Add missnamed_getters lint 2022-11-20 13:45:11 +01:00
bors
5b0d727bad Auto merge of #9570 - nfejzic:lint-unchecked-duration-subtraction, r=llogiq
feat: lint unchecked subtraction of a 'Duration' from an 'Instant'

Hello all, I tried to tackle the open issue #9371 and this is what I came up with.

I have a difficulty currently - some tests are failing:

```
failures:
    [ui] ui/manual_instant_elapsed.rs
```

The `manual_instant_elapsed` is failing because of `Instant::now() - duration` test, this now gets also picked by `unchecked_duration_subtraction` lint.
What is the correct way to proceed in this case? Simply update the `.stderr` file for `manual_instant_elapsed` lint?

changelog: [`unchecked_duration_subtraction`]: Add lint for unchecked subtraction of a `Duration` from an `Instant`.

fixes #9371
2022-11-15 06:09:10 +00:00
Nadir Fejzic
708c2d95c1 feat: add and implement unchecked_duration_subtraction lint 2022-11-10 15:46:41 +01:00