Commit Graph

937 Commits

Author SHA1 Message Date
xFrednet
c5820022d5
Changelog for Rust 1.62 🦖 2022-06-28 12:20:24 +02:00
bors
fdd0e727e2 Auto merge of #8649 - ebobrow:imperative_find, r=flip1995
add [`manual_find`] lint for function return case

part of the implementation discussed in #7143

changelog: add [`manual_find`] lint for function return case
2022-06-27 17:15:25 +00:00
kyoto7250
dd3d0fdad3 rename use_retain => manual_retain 2022-06-27 08:11:58 +09:00
kyoto7250
5f2b8e67b3 feat(new lint): new lint use_retain 2022-06-27 08:11:58 +09:00
Evan Typanski
e5ebd3edab Implement manual_rem_euclid lint 2022-06-21 14:13:15 -04:00
kyoto7250
2bb8c45026 feat(lint): add default_iter_empty
Update description in clippy_lints/src/default_iter_empty.rs

Co-authored-by: Fridtjof Stoldt <xFrednet@gmail.com>

Update clippy_lints/src/default_iter_empty.rs

Co-authored-by: Alex Macleod <alex@macleod.io>

Update clippy_lints/src/default_iter_empty.rs

Co-authored-by: Alex Macleod <alex@macleod.io>

renamed default_iter_empty to default_instead_of_iter_empty

Avoid duplicate messages

add tests for regression

rewrite 'Why is this bad?'

cargo dev fmt

delete default_iter_empty lint in renamed_lint.rs

rewrite a message in the suggestion

cargo dev update_lints --check
2022-06-17 21:34:36 +09:00
tamaron
14478bb94b add lint 2022-06-14 23:30:43 +09:00
Dennis Luxen
61d7dd2af0 Update CHANGELOG.md 2022-06-05 22:47:29 +02:00
Dennis Luxen
58a605f453 Rerun cargo dev update_lints 2022-06-05 22:47:08 +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
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
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
Jason Newcomb
ca78e2428e Add lint swap_ptr_to_ref 2022-05-31 13:08:05 -04:00
Jason Newcomb
eb2908b4ea Add lint almost_complete_letter_range 2022-05-30 23:20:04 -04:00
lyj
c5410150eb needless_deref 2022-05-30 01:46:15 +00:00
llogiq
c9be57dbf3
Merge branch 'master' into doc_link_with_quotes 2022-05-28 10:55:25 +02:00
Micha White
d8a281ef73
Added an unused_rounding lint 2022-05-24 22:53:29 -04:00
kyoto7250
1dd026698d feat(lint): impl lint about use first() instead of get(0) 2022-05-25 09:08:23 +09:00
bors
fbb9e565e3 Auto merge of #8754 - guerinoni:no_effect_replace, r=llogiq
New lint `no_effect_replace`

Closes #1595

Signed-off-by: Federico Guerinoni <guerinoni.federico@gmail.com>

changelog: Add [`no_effect_replace`] lint.
2022-05-24 16:55:06 +00:00
Federico Guerinoni
ea62347a5a New lint no_effect_replace
Closes #1595

changelog: Add no_effect_replace lint.
2022-05-24 11:08:41 +02:00
xFrednet
4e6cf0036e
Merge remote-tracking branch 'upstream/master' into rustup 2022-05-20 20:47:31 +02:00
bors
879cd37fde Auto merge of #8840 - xFrednet:0000-mini-changelog-update, r=llogiq
Mini changelog update for Rust 1.61.0

I'll do the full release and sync tomorrow, as I sadly don't have the time today. This is a quick update to ensure that Rust's changelog will link to the correct section in our changelog.  The change is according to [our docs](8751e47bae/book/src/development/infrastructure/release.md (update-changelogmd))

changelog: none
2022-05-19 20:02:29 +00:00
Fridtjof Stoldt
b787f4ce2b
Mini changelog update for Rust 1.61.0 2022-05-19 13:43:17 +02:00
Elliot Bobrow
430575b61a add manual_find lint for function return case 2022-05-16 20:20:49 -07:00
Jason Newcomb
f7378daf71 Add renamed lints to the changelog link list 2022-05-15 17:10:48 -04:00
Jason Newcomb
50eada16f7 Rename eval_order_dependence to mixed_read_write_in_expression 2022-05-15 17:08:45 -04:00
Alex Macleod
1f79a442e5 Add duplicate_mod lint 2022-05-14 22:31:13 +01:00
bors
d422baa30c Auto merge of #8796 - nsunderland1:master, r=giraffate
New lint: [`derive_partial_eq_without_eq`]

Introduces a new lint, [`derive_partial_eq_without_eq`].

See: #1781 (doesn't close it though).

changelog: add lint [`derive_partial_eq_without_eq`]
2022-05-10 13:25:27 +00:00
yonip23
feb6d8cf30 introduce rc_clone_in_vec_init lint 2022-05-10 15:10:13 +03:00
nsunderland1
fe84ff3360 New lint: [derive_partial_eq_without_eq] 2022-05-09 22:13:39 -07:00
Preston From
41c7e4d382 Lint for significant drops who may have surprising lifetimes #1
author Preston From <prestonfrom@gmail.com> 1645164142 -0600
committer Preston From <prestonfrom@gmail.com> 1650005351 -0600
2022-05-06 21:48:17 -06:00
flip1995
7cd86aa1be Merge commit '7c21f91b15b7604f818565646b686d90f99d1baf' into clippyup 2022-05-05 15:12:52 +01:00
Max Baumann
fea177fafe
add trim_split_whitespace 2022-05-04 15:04:05 +02:00
Serial
a85dc87c4c Add large_include_file lint 2022-04-24 10:08:31 -04:00
Gryffon Bellish
8de3fb159d
Add empty_drop lint 2022-04-21 10:03:01 +02:00
bors
e17b97c8e0 Auto merge of #8711 - kyoto7250:new-lint-bytes-count-to-len, r=giraffate
Take over: New lint bytes count to len

take over #8375
close #8083

This PR adds new lint about  considering replacing `.bytes().count()` with `.len()`.

Thank you in advance.

---

r! `@Manishearth`

changelog: adds new lint [`bytes_count_to_len`] to consider replacing `.bytes().count()` with `.len()`
2022-04-19 12:44:07 +00:00
Chase Ruskin
df1ec91d95 adds lint logic and test for bytes_count_to_len
formats code with

fixes single match clippy error to replace with if let

swaps ident.name.as_str to ident.name == sym for count fn
2022-04-19 10:48:10 +09:00
bors
cbdf17c884 Auto merge of #8707 - OneSignal:await-invalid-types, r=llogiq
Add `await_holding_invalid_type` lint

changelog: [`await_holding_invalid_type`]

This lint allows users to create a denylist of types which are not allowed to be
held across await points. This is essentially a re-implementation of the
language-level [`must_not_suspend`
lint](https://github.com/rust-lang/rust/issues/83310). That lint has a lot of
work still to be done before it will reach Rust stable, and in the meantime
there are a lot of types which can trip up developers if they are used
improperly.

I originally implemented this specifically for `tracing::span::Entered`, until I discovered #8434 and read the commentary on that PR. Given this implementation is fully user configurable, doesn't tie clippy to any one particular crate, and introduces no additional dependencies, it seems more appropriate.
2022-04-18 18:36:50 +00:00
bors
e5ebece910 Auto merge of #8665 - InfRandomness:option_take_on_temporary, r=llogiq
Introduce needless_option_take lint

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

Fixes #8618

changelog: Introduce [`needless_option_take`] lint
2022-04-17 18:34:16 +00:00
bors
3abd2c08ab Auto merge of #8698 - xFrednet:0000-changelog-1-61, r=flip1995
Changelog for Rust 1.61 🐙

roses are red,
violets are blue,
this changelog,
is no longer a todo!

---

changelog: none
2022-04-16 08:26:27 +00:00
xFrednet
af721036af
Changelog for Rust 1.61 🐙 2022-04-16 10:25:25 +02:00
Lily Mara
4844325faf Add await_holding_invalid_type lint
changelog: [`await_holding_invalid_type`]

This lint allows users to create a denylist of types which are not allowed to be
held across await points. This is essentially a re-implementation of the
language-level [`must_not_suspend`
lint](https://github.com/rust-lang/rust/issues/83310). That lint has a lot of
work still to be done before it will reach Rust stable, and in the meantime
there are a lot of types which can trip up developers if they are used
improperly.
2022-04-15 14:39:10 -07:00
infrandomness
262b35ea2c Introduce option_take_on_temporary lints
This lint checks if Option::take() is used on a temporary value (a value
that is not of type &mut Option and that is not a Place expression) to
suggest omitting take()
2022-04-14 12:41:47 +02:00
Peter Jaszkowiak
67badbeef6 New lint format_add_strings 2022-04-13 22:48:36 -06:00
bors
b6645d022e Auto merge of #8670 - yoav-lavi:main, r=giraffate
`pub_use` restriction

[`pub_use`]

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

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

changelog: Adds a lint called `pub_use` that restricts the usage of `pub use ...`
2022-04-13 13:03:51 +00:00
Yoav Lavi
66d253f0f2 pub_use 2022-04-13 13:48:27 +02:00
bors
dbcd82885f Auto merge of #8624 - pitaj:is_digit_ascii_radix, r=xFrednet
New lint `is_digit_ascii_radix`

Closes #6399

changelog: Added [`is_digit_ascii_radix`]: recommend `is_ascii_digit()` or `is_ascii_hexdigit()` in place of `is_digit(10)` and `is_digit(16)`
2022-04-11 18:56:21 +00:00
Yoav Lavi
10201370a1 unnecessary_owned_empty_string -> unnecessary_owned_empty_strings 2022-04-11 13:05:42 +02:00
Yoav Lavi
a4d1837f07 unnecessary_string_new 2022-04-11 12:35:44 +02:00
flip1995
71131351de Merge commit '984330a6ee3c4d15626685d6dc8b7b759ff630bd' into clippyup 2022-04-08 10:06:10 +01:00
Peter Jaszkowiak
06cfeb90c1 New lint is_digit_ascii_radix 2022-04-07 14:14:30 -06:00
flip1995
6ab4508350
Allow raw lint descriptions
update_lints now understands raw strings in declare_clippy_lint
descriptions.

Co-authored-by: Alex Macleod <alex@macleod.io>
2022-04-07 18:05:46 +01:00
bors
abc59bb914 Auto merge of #8656 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2022-04-07 15:30:27 +00:00
flip1995
a2fdbb5f53
Bump changelog stable version -> 1.60 2022-04-07 16:26:43 +01:00
Paolo Borelli
b0edbca0e6 new lint cast_abs_to_unsigned
Add a lint to detect cast to unsigned for abs() and suggest
unsigned_abs() to avoid panic when called on MIN.
2022-04-07 11:28:14 +02:00
bors
0d66404941 Auto merge of #8630 - Jarcho:forget_non_drop, r=Manishearth
Add lints `drop_non_drop` and `forget_non_drop`

fixes #1897

changelog: Add lints `drop_non_drop` and `forget_non_drop`
2022-04-06 23:04:20 +00:00
Jason Newcomb
5cd711b4f1 Add lints drop_non_drop and forget_non_drop 2022-04-04 12:30:09 -04:00
Max Baumann
2953cba116 unit_like_struct_brackets -> empty_structs_with_brackets 2022-03-30 20:13:16 +02:00
Max Baumann
528ada958b add unit_like_struct_brackets 2022-03-30 20:12:58 +02:00
bors
fe7254ff6f Auto merge of #8576 - smoelius:crate_in_macro_def, r=llogiq
Add `crate_in_macro_def` lint

This PR adds a lint to check for `crate` as opposed to `$crate` used in a macro definition.

I think this can close #4798. That issue focused on the case where the macro author "imports something into said macro."

But I think use of `crate` is likely to be a bug whether it appears in a `use` statement or not. There could be some use case I am failing to see, though. (cc: `@nilscript` `@flip1995)`

changelog: `crate_in_macro_def`
2022-03-30 16:57:24 +00:00
Takayuki Nakata
e5fa22e350 Fix version in changelog 2022-03-28 21:48:34 +09:00
xFrednet
55feb4c4aa
Changelog for Rust 1.60.0 🦀 2022-03-25 17:58:39 +01:00
flip1995
1fa3d66e62 Merge commit 'd0cf3481a84e3aa68c2f185c460e282af36ebc42' into clippyup 2022-03-24 14:50:04 +01:00
Yoav Lavi
b60a7fb7b6
unnecessary_join lint 2022-03-24 13:18:18 +01:00
Samuel E. Moelius III
65a26692fd Add crate_in_macro_def lint 2022-03-24 05:08:10 -04:00
bors
4a07662d94 Auto merge of #8561 - FoseFx:use_unwrap_or, r=xFrednet
add `or_then_unwrap`

Closes #8557

changelog: New lint [`or_then_unwrap`]
2022-03-21 20:08:29 +00:00
Max Baumann
3c4192f3e9
fix: ran update_lints 2022-03-18 01:12:39 +01:00
Max Baumann
05e05eaed7
refactor: rename lint to or_then_unwrap 2022-03-18 01:04:33 +01:00
Jason Newcomb
39329d1d40 Add lint cast_enum_constructor 2022-03-17 19:57:35 -04:00
Max Baumann
f49a2c3457
feat: add use_unwrap_or 2022-03-17 18:57:28 +01:00
flip1995
d1b087fdee Merge commit 'dc5423ad448877e33cca28db2f1445c9c4473c75' into clippyup 2022-03-14 12:02:53 +01:00
bors
e2e492c10e Auto merge of #8422 - buttercrab:only_used_in_recursion, r=llogiq
new lint: `only_used_in_recursion`

changed:
- added `only_used_in_recursion`.
- fixed code that variables are only used in recursion.
- this would not lint when `unused_variable`

This fixes: #8390

-----

changelog: add lint [`only_used_in_recursion`]
2022-03-13 16:11:25 +00:00
bors
75b616e92f Auto merge of #8471 - J-ZhengLi:master-issue7040, r=llogiq
new lint that detects useless match expression

fixes #7040

changelog: Add new  lint [`needless_match`] under complexity lint group
2022-03-13 14:49:56 +00:00
J-ZhengLi
ec9116412a rename lint to needless_match
and change its lint group to "complexity"
2022-03-10 09:44:25 +08:00
bors
0c483f69db Auto merge of #8445 - asquared31415:slice_ptr_cast, r=llogiq
Llint for casting between raw slice pointers with different element sizes

This lint disallows using `as` to convert from a raw pointer to a slice (e.g. `*const [i32]`, `*mut [Foo]`) to any other raw pointer to a slice if the element types have different sizes.  When a raw slice pointer is cast, the data pointer and count metadata are preserved.  This means that when the size of the inner slice's element type changes, the total number of bytes pointed to by the count changes.  For example a `*const [i32]` with length 4 (four `i32` elements) is cast `as *const [u8]` the resulting pointer points to four `u8` elements at the same address, losing most of the data.  When the size *increases* the resulting pointer will point to *more* data, and accessing that data will be UB.

On its own, *producing* the pointer isn't actually a problem, but because any use of the pointer as a slice will either produce surprising behavior or cause UB I believe this is a correctness lint.  If the pointer is not intended to be used as a slice, the user should instead use any of a number of methods to produce just a data pointer including an `as` cast to a thin pointer (e.g. `p as *const i32`) or if the pointer is being created from a slice, the `as_ptr` method on slices.  Detecting the intended use of the pointer is outside the scope of this lint, but I believe this lint will also lead users to realize that a slice pointer is only for slices.

There is an exception to this lint when either of the slice element types are zero sized (e.g `*mut [()]`).  The total number of bytes pointed to by the slice with a zero sized element is zero.  In that case preserving the length metadata is likely intended as a workaround to get the length metadata of a slice pointer though a zero sized slice.

The lint does not forbid casting pointers to slices with the *same* element size as the cast was likely intended to reinterpret the data in the slice as some equivalently sized data and the resulting pointer will behave as intended.

---

changelog: Added ``[`cast_slice_different_sizes`]``, a lint that disallows using `as`-casts to convert between raw pointers to slices when the elements have different sizes.
2022-03-06 07:46:56 +00:00
bors
48d54942f5 Auto merge of #8504 - xFrednet:8502-allow-lint-without-reason, r=flip1995
Add lint to detect `allow` attributes without reason

I was considering putting this lint into the pedantic group. However, that would result in countless warnings for existing projects. Having it in restriction also seems good to me 🙃 (And now I need sleep 💤 )

---

changelog: New lint [`allow_lint_without_reason`] (Requires the `lint_reasons` feature)

Closes: rust-lang/rust-clippy#8502
2022-03-04 19:23:39 +00:00
asquared31415
f932c304bb lint for casting raw pointers to slices with different element sizes 2022-03-04 13:23:06 -05:00
xFrednet
ab6ffb6371
Add lint to detect allow attributes without reason 2022-03-04 17:45:43 +01:00
Liu Dingming
6cc2eeaa56 Suggest into_iter() over drain(..)
Add doc

Add description

iter_with_drain dogfood

Disable emiting on struct field.

Fix clippy

Add eq_path for SpanlessEq

Fix tests

Better error message

Fix doc test

Fix version

Apply suggestions
2022-03-03 13:10:19 +08:00
bors
6e211eac7c Auto merge of #8489 - smoelius:unnecessary-find-map, r=llogiq
Add `unnecessary_find_map` lint

This PR adds an `unnecessary_find_map` lint. It is essentially just a minor enhancement of `unnecessary_filter_map`.

Closes #8467

changelog: New lint `unnecessary_find_map`
2022-03-02 19:50:27 +00:00
Andre Bogus
9f1080cc6e new lint: missing-spin-loop 2022-03-02 19:31:06 +01:00
Samuel E. Moelius III
2a588d810f Add unnecessary_find_map lint 2022-03-01 19:24:55 -05:00
flip1995
35020280a0 Merge commit 'e329249b6a3a98830d860c74c8234a8dd9407436' into clippyup 2022-02-26 14:26:21 +01:00
Alex Macleod
52f3d61a2a Add print_in_format_impl lint 2022-02-25 21:10:06 +00:00
J-ZhengLi
30fb8229e1 add tests, add base bone for the new lint 2022-02-25 18:08:52 +08:00
Jason Newcomb
90bb7a3476 New lint cast_enum_truncation 2022-02-18 09:16:17 -05:00
bors
668b3e47f9 Auto merge of #8218 - Jarcho:redundant_slicing_deref, r=camsteffen
Improve `redundant_slicing` lint

fixes #7972
fixes #7257

This can supersede #7976

changelog: Fix suggestion for `redundant_slicing` when re-borrowing for a method call
changelog: New lint `deref_as_slicing`
2022-02-17 16:08:45 +00:00
Jason Newcomb
113ac6e15e Split off new lint deref_by_slicing from redundant_slicing 2022-02-17 00:02:26 -05:00
James McMurray
b162b11abc Add recursive_format_impl lint
The to_string_in_display lint is renamed to recursive_format_impl
A check is added for the use of self formatted with Display or Debug
inside any format string in the same impl
The to_string_in_display check is kept as is - like in the
format_in_format_args lint

For now only Display and Debug are checked
This could also be extended to other Format traits (Binary, etc.)
2022-02-14 18:49:51 +01:00
Jaeyong Sung
4f96ca353e
add only_used_in_recursion lint
- fix code that have variables that is "only used in recursion"
- add test
2022-02-13 02:32:09 +09:00
flip1995
611d039814 Merge commit '57b3c4b90f4346b3990c1be387c3b3ca7b78412c' into clippyup 2022-02-10 18:40:06 +01:00
bors
093e32052e Auto merge of #8398 - Jarcho:unordered_transmute, r=llogiq
Add lint `transmute_undefined_repr`

Partially implements #3999 and #546

This doesn't consider `enum`s at all right now as those are going to be a pain to deal with. This also allows `#[repr(Rust)]` structs with only one non-zero sized fields. I think those are technically undefined when transmuted.

changelog: Add lint `transmute_undefined_repr`
2022-02-06 16:05:00 +00:00
Jason Newcomb
3403b3e717 Add lint transumte_undefined_repr 2022-02-05 16:28:25 -05:00
bors
b8c80ddbb5 Auto merge of #8330 - flip1995:changelog, r=llogiq
Update Changelog

[Rendered](https://github.com/flip1995/rust-clippy/blob/changelog/CHANGELOG.md)

changelog: none
2022-02-01 19:30:25 +00:00
cameron
cb29e3effb add doc_link_with_quotes lint 2022-02-01 11:21:42 +00:00
bors
7ceffdee9b Auto merge of #8289 - jubnzv:unspecified-layout-union, r=camsteffen
Add `default_union_representation` lint

Closes #8235

changelog: Added a new lint  [`default_union_representation`]
2022-01-29 10:58:16 +00:00
Georgy Komarov
b7000b2a53 Add default_union_representation lint
Closes #8235
2022-01-29 07:02:28 +03:00
flip1995
bf66aeda0a Merge commit 'a98e7ab8b94485be6bd03e0c6b8682ecab5b52e6' into clippyup 2022-01-27 15:12:45 +01:00