Commit graph

12036 commits

Author SHA1 Message Date
GnomedDev
acb6748f80 [Clippy] Swap unnecessary_to_owned to use diagnostic item instead of path 2024-09-19 13:13:42 +01:00
GnomedDev
98dc68e85e [Clippy] Swap instant_subtraction to use diagnostic item instead of path 2024-09-19 13:13:42 +01:00
GnomedDev
d63e35ba22 [Clippy] Swap waker_clone_wake to use diagnostic item instead of path 2024-09-19 13:13:42 +01:00
GnomedDev
45c1700e13 [Clippy] Swap filter_map_bool_then to use diagnostic item instead of path 2024-09-19 13:13:42 +01:00
GnomedDev
b0152909d6 [Clippy] Swap manual_while_let_some to use diagnostic items instead of paths 2024-09-19 13:13:42 +01:00
GnomedDev
984bd6fed6 [Clippy] Swap repeat_vec_with_capacity to use diagnostic item instead of path 2024-09-19 13:13:42 +01:00
GnomedDev
545967955a [Clippy] Swap VecArgs::hir to use diagnostic items instead of paths 2024-09-19 13:13:40 +01:00
GnomedDev
f66915e8f8 [Clippy] Swap single_char_add_str/format_push_string to use diagnostic items instead of paths 2024-09-19 13:13:20 +01:00
GnomedDev
959f7a2bbb [Clippy] Swap manual_main_separator_str to use diagnostic item instead of path 2024-09-19 13:13:20 +01:00
GnomedDev
1922a99bc6 [Clippy] Swap redundant_clone to use diagnostic items instead of paths 2024-09-19 13:13:20 +01:00
GnomedDev
8fc9e67cf5 [Clippy] Swap float_equality_without_abs to use diagnostic items instead of paths 2024-09-19 13:13:20 +01:00
GnomedDev
7ffd485be0 [Clippy] Swap option_as_ref_deref to use diagnostic items instead of paths 2024-09-19 13:13:19 +01:00
GnomedDev
71dbfd55a1 [Clippy] Swap lines_filter_map_ok to use a diagnostic item instead of path 2024-09-19 08:26:41 +01:00
GnomedDev
5a13a93d41 [Clippy] Swap map_entry to use diagnostic items instead of paths 2024-09-19 08:26:37 +01:00
GnomedDev
978582be74 [Clippy] Swap manual_retain to use diagnostic items instead of paths 2024-09-18 17:20:44 +01:00
VictorHugoPilled
ae5f857096 fix: Specifying reason in expect(clippy::needless_return) no longer triggers false positive
chore: Moved new tests into needless_return.rs

chore: Ran cargo uibless

Initial commit
2024-09-18 06:10:51 +00:00
Lukas Lueg
c3d58cd5fa Fix if_then_some_else_none sugg missing closure intro
Fixes #13407
2024-09-17 23:19:29 +02:00
bors
903293b199 Auto merge of #13382 - c410-f3r:blah, r=y21
[`missing_panics_doc`] Fix #13381

Fix #13381

Makes `missing_panics_doc` act like other "panicking" lints (`unwrap_used`, `panic`, etc) in constant environments.

changelog: Ignore `missing_panics_doc` in constant environments
2024-09-17 12:34:00 +00:00
Folkert de Vries
b5ea5c23b3 stabilize const_extern_fn 2024-09-14 18:07:06 +02:00
y21
15495ebf42 Look at adjusted types instead of fn signature types in ptr_arg 2024-09-13 18:26:29 +02:00
Trevor Spiteri
7cccef84cf handle transmutes in const context if msrvs::CONST_FLOAT_BITS_CONV 2024-09-13 13:57:41 +02:00
Trevor Spiteri
7fcdebf658 Revert "stabilize const_float_bits_conv" for src/tools/clippy/clippy_lints
This reverts the part of commit 19908ff7a37a9a431399bb6f2868efc22820f2b6 in
subdirectory src/tools/clippy/clippy_lints.
2024-09-13 13:56:41 +02:00
bors
2b7d80b80a Auto merge of #13377 - vHugoObject:master, r=dswij
fix: Fixed incorrect comment form suggestion for too_long_first_doc_paragraph lint

fixes #13309
changelog: none

Comment form is now a variable and a new test for too_long_first_doc_paragraph was added.
2024-09-13 11:55:46 +00:00
Alexey Semenyuk
bc7d323bdf Clarify type_complexity 2024-09-13 16:02:51 +05:00
VictorHugoPilled
d66e9addd6 fix: Fixed incorrect comment form suggestion
chore: Ran cargo dev fmt

chore: Fixed spacing

fix: Fixed spacing for comment suggestion

fix: Added new module level test to too_long_first_doc_paragraph

chore: Ran cargo uibless
2024-09-12 23:33:22 +00:00
Samuel Tardieu
6371b308d8 Make it clearer that the suggestion is an alternative one
`needless_pass_by_value` sometimes suggest marking the concerned type as
`Copy`. Adding a `or` before this suggestion makes it clearer that this
is not the second part of the original suggestion, but an alternative one.
2024-09-12 16:32:56 +02:00
bors
e039e72d85 Auto merge of #13386 - alex-semenyuk:no_lint_on_duplicate_reason, r=xFrednet
Not trigger `duplicated_attributes` on duplicate reasons

As at #13355 we shoudn't  trigger `duplicated_attributes` on duplicate reasons attr
changelog: [`duplicated_attributes`]: not trigger `duplicated_attributes` on duplicate reasons
2024-09-12 10:26:14 +00:00
Alexey Semenyuk
7097830a9b Not trigger duplicated_attributes on duplicate reasons 2024-09-12 11:49:16 +05:00
Caio
0905a7786e Fix #13381 2024-09-11 13:58:05 -03:00
bors
131681b4b9 Auto merge of #13369 - samueltardieu:issue-13361, r=y21
Special-case suggestions for null pointers constness cast

This implements the suggestions from #13361. It fits into the existing `ptr_cast_constness` lint, as this is a specialized version. However,

1. I have not modified the lint MSRV, so the documentation for this lint will still show that it applies only from Rust 1.72.0. This is true in the general case, but the lint for null pointers will trigger even before this version as `null()` and `null_mut()` were already present in Rust 1.0 and there is no reason not to apply this lint. I guess this is only a minor documentation issue that can be ignored.
2. I have not covered the `core::ptr::null::<T>().cast_mut()` (could be made into `core::ptr::null_mut::<T>()`) and `cotr::ptr::null_mut::<T>().cast_const()` (could be made into `core::ptr::null::<T>()`) cases. Should they be covered? If they should, here or in a separate PR?

changelog: [`ptr_cast_constness`]: special-case suggestions for null pointers constness cast

Fix #13361
2024-09-11 15:43:48 +00:00
bors
8be0b36687 Auto merge of #13344 - lukaslueg:issue13339, r=Alexendoo
Expand missing_transmute_annotations docs

Fixes #13339

changelog: [`missing_transmute_annotations `]: Expand docs, raison d'être
2024-09-11 12:07:13 +00:00
Alexey Semenyuk
49a501856d Fix WHILE_LET_LOOP doc 2024-09-11 12:40:20 +05:00
cuishuang
b0db9c285d Remove unnecessary symbols and add missing symbols
Signed-off-by: cuishuang <imcusg@gmail.com>
2024-09-09 21:48:12 +08:00
Samuel Tardieu
30608732c2 Handle null pointer constness cast through methods
This covers two cases:

- `core::ptr::null::<T>().cast_mut()` -> `core::ptr::null_mut::<T>()`
- `core::ptr::null_mut::<T>().cast_const()` -> `core::ptr::null::<T>()`
2024-09-09 10:18:31 +02:00
Samuel Tardieu
9e9526c6ab Special-case suggestions for null pointers constness cast 2024-09-09 10:18:31 +02:00
bors
0ee2650e07 Auto merge of #13370 - jtherrmann:master, r=dswij
Fix possible typo in `ptr_arg` lint

This fixes a possible typo in the [`ptr_arg`](https://rust-lang.github.io/rust-clippy/master/index.html#/ptr_arg) lint. I'm new to Rust, so apologies if I misunderstood the meaning of this lint.

changelog: [`ptr_arg`]: Fix typo ("size" -> "type")
2024-09-08 15:11:09 +00:00
bors
bcf528bdef Auto merge of #13324 - WeiTheShinobi:single_match, r=dswij
[`single_match`, `single_match_else`] fix suggestion when match irrefutable

fixes #13012

changelog:[`single_match`, `single_match_else`]: fix suggestion when `match` irrefutable
2024-09-08 15:02:35 +00:00
bors
41dc86d4d3 Auto merge of #13214 - apoisternex:issue12907, r=Centri3
Fix [`needless_return`] false negative

Fixes #12907

changelog: Fix [`needless_return`] false negative when returned expression borrows a value.
2024-09-07 21:47:32 +00:00
Matthias Krüger
c8f5136fe8 Rollup merge of #129555 - RalfJung:const_float_bits_conv, r=dtolnay
stabilize const_float_bits_conv

This stabilizes `const_float_bits_conv`, and thus fixes https://github.com/rust-lang/rust/issues/72447. With https://github.com/rust-lang/rust/pull/128596 having landed, this is entirely a libs-only question now.

```rust
impl f32 {
    pub const fn to_bits(self) -> u32;
    pub const fn from_bits(v: u32) -> Self;
    pub const fn to_be_bytes(self) -> [u8; 4];
    pub const fn to_le_bytes(self) -> [u8; 4]
    pub const fn to_ne_bytes(self) -> [u8; 4];
    pub const fn from_be_bytes(bytes: [u8; 4]) -> Self;
    pub const fn from_le_bytes(bytes: [u8; 4]) -> Self;
    pub const fn from_ne_bytes(bytes: [u8; 4]) -> Self;
}

impl f64 {
    pub const fn to_bits(self) -> u64;
    pub const fn from_bits(v: u64) -> Self;
    pub const fn to_be_bytes(self) -> [u8; 8];
    pub const fn to_le_bytes(self) -> [u8; 8]
    pub const fn to_ne_bytes(self) -> [u8; 8];
    pub const fn from_be_bytes(bytes: [u8; 8]) -> Self;
    pub const fn from_le_bytes(bytes: [u8; 8]) -> Self;
    pub const fn from_ne_bytes(bytes: [u8; 8]) -> Self;
}
````

Cc `@rust-lang/wg-const-eval` `@rust-lang/libs-api`
2024-09-07 23:30:11 +02:00
Jake Herrmann
25efc04ea5
Fix typo 2024-09-07 12:00:34 -08:00
Samarth1696
af3346a85f Check for get method and new test case in unfixable 2024-09-07 13:21:14 +05:30
Samarth1696
d43acb803f Added checks for binary expr and added different test cases for unfixable cases 2024-09-07 13:21:14 +05:30
Samarth1696
bed44418ec refactored the code 2024-09-07 13:21:14 +05:30
Samarth1696
0f99aa992e all tests passed 2024-09-07 13:21:14 +05:30
Samarth1696
6f01273d5d dogfood test passed 2024-09-07 13:21:14 +05:30
Samarth1696
73039f654e test cases added including some edge cases 2024-09-07 13:21:14 +05:30
Samarth1696
46f8d360de Lint ready 2024-09-07 13:21:09 +05:30
WeiTheShinobi
e3ca249e96
fix single_match suggestion 2024-09-06 23:10:42 +08:00
bors
fb9913ef3b Auto merge of #13327 - Sour1emon:master, r=llogiq
Add new lint `manual_is_power_of_two`

Suggest using `is_power_of_two()` instead of the manual implementations for some basic cases

Part of https://github.com/rust-lang/rust-clippy/issues/12894

----

changelog: new [`manual_is_power_of_two`] lint
2024-09-06 10:36:57 +00:00
bors
7d7b298a4e Auto merge of #13352 - kpreid:patch-1, r=xFrednet
Correct version of `too_long_first_doc_paragraph`

`too_long_first_doc_paragraph` is, empirically, not in the Rust 1.81.0 release.

changelog: [`too_long_first_doc_paragraph`]: correct Rust version number in documentation.
2024-09-06 07:16:18 +00:00
Sour1emon
f994797e46 Add support for different orders of expression 2024-09-05 18:38:12 -07:00
Isaac Bess
6ecb48f6d0 Fixed extra backtick
Co-authored-by: Ruby Lazuli <general@patchmixolydic.com>
2024-09-05 18:38:12 -07:00
Isaac Bess
5515566829 Improve "Why this is bad" section
Co-authored-by: Ruby Lazuli <general@patchmixolydic.com>
2024-09-05 18:38:12 -07:00
Sour1emon
d7996da9da Add manual_is_power_of_two 2024-09-05 18:38:06 -07:00
Artem Belyakov
9415e6e6eb Add manual_div_ceil 2024-09-06 00:55:42 +02:00
bors
c41be9e125 Auto merge of #13345 - Alexendoo:manual-non-exhaustive-visibility, r=y21
Only lint `manual_non_exhaustive` for exported types

For types that are not exported the attribute doesn't make a difference, but the manual pattern can still be used to achieve module level non exhaustiveness

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

changelog: none
2024-09-05 21:52:42 +00:00
Pavel Grigorenko
0b8cb4a1eb Make Ty::boxed_ty return an Option 2024-09-06 00:30:36 +03:00
Kevin Reid
79081f1271
Correct version of too_long_first_doc_paragraph
`too_long_first_doc_paragraph` is, empirically, not in the Rust 1.81.0 release.
2024-09-05 14:30:27 -07:00
Philipp Krones
40fca8f7a8
Bump Clippy version -> 0.1.83 2024-09-05 17:00:55 +02:00
Philipp Krones
87ce1d8069
Merge remote-tracking branch 'upstream/master' into rustup 2024-09-05 17:00:37 +02:00
bors
c95c767663 Auto merge of #13323 - xFrednet:chnagelog-1-81, r=flip1995
Changelog for Clippy 1.81 🔰

Roses are red,
Violets are blue,
Expectations are stable,
And reasons are set

---

### The cat of this release is *Keepy* submitted by `@blyxyas:`

<img height=500 src="https://github.com/rust-lang/rust-clippy/assets/73757586/902dd802-5ac8-471e-bb93-e195526ba580" alt="The cats of this Clippy release" />

Cats for the next release can be nominated in the comments :D

---

changelog: none
2024-09-05 09:17:12 +00:00
Alex Macleod
f7f550561e Only lint manual_non_exhaustive for exported types 2024-09-04 21:22:28 +00:00
Lukas Lueg
7d2e6ebcbe Expand missing_transmute_annotations docs
Fixes #13339
2024-09-04 19:37:59 +02:00
bors
58cbf09e86 Auto merge of #13332 - nyurik:nits, r=xFrednet
Minor code simplification

changelog: none
2024-09-03 20:47:48 +00:00
bors
f2ef26d239 Auto merge of #13263 - y21:warn_manual_c_str_literals, r=Centri3
move `manual_c_str_literals` to complexity

IMO the suggestion to use `c""` literals over a hardcoded `\0` byte string literal has some fairly strong upsides (no need to manually null-terminate it and the compiler checks for intermediary null bytes) that this should just be enabled by default.

It's also written slightly conservatively to only emit a warning when we can be reasonably confident that the lint is *actually* applicable (that is, lint on e.g. `b"foo\0".as_ptr()` but not `b"foo\0"`. The latter looks like a c-string but its type is `&[u8; _]`, and if it's used in a context where a byte slice is needed then you have no nice way to convert to it from a `c"foo"` literal of type `&CStr`).

changelog: move [`manual_c_str_literals`] to complexity (now warn-by-default)
2024-09-03 18:29:20 +00:00
Soveu
273b561609 add pointers_in_nomem_asm_block lint 2024-09-03 18:58:05 +02:00
Yuri Astrakhan
cd28176025 Minor code simplification 2024-09-01 20:58:14 -04:00
Ralf Jung
ba2577f23c stabilize const_float_bits_conv 2024-09-01 12:38:59 +02:00
bors
a81f1c8277 Auto merge of #13325 - alex-semenyuk:wrong_self_convention_doc_fix, r=y21
Provide more clear example for `WRONG_SELF_CONVENTION`

Provide more clear example for `WRONG_SELF_CONVENTION`

changelog: none
2024-09-01 08:28:00 +00:00
alexey semenyuk
989ebae2ba Provide more clear example for WRONG_SELF_CONVENTION 2024-08-31 23:06:03 +05:00
bors
ac914d3457 Auto merge of #12476 - GuillaumeGomez:add-manual_arithmetic_check, r=y21
Extend `implicit_saturating_sub` lint

Fixes #10070.

It can serve as base if we want to add equivalent checks for other arithmetic operations.

Also one important note: when writing this lint, I realized that I could check for wrong conditions performed beforehand on subtraction and added another part in the lint. Considering they both rely on the same checks, I kept both in the same place. Not sure if it makes sense though...

changelog: Extend `implicit_saturating_sub` lint
2024-08-31 16:03:42 +00:00
Guillaume Gomez
2832faf895 Move MSRV check later in implicit_saturating_sub 2024-08-31 16:24:17 +02:00
Guillaume Gomez
e845366c82 Add MSRV check for saturating_sub lints in const contexts 2024-08-31 16:24:17 +02:00
WeiTheShinobi
04d70d04fc
[single_match, single_match_else] fix suggestion when match irrefutable 2024-08-31 05:25:59 +08:00
xFrednet
9e7473f08d
Update version attribute for 1.81 lints 2024-08-29 21:36:43 +02:00
Guillaume Gomez
d20fc38f0a Create new inverted_saturating_sub lint 2024-08-29 20:20:13 +02:00
Guillaume Gomez
74a2344dc1 Extend implicit_saturation_sub lint 2024-08-29 20:20:13 +02:00
Michael Goulet
5bbb0d41f1 Stop using ty::GenericPredicates for non-predicates_of queries 2024-08-29 00:17:40 -04:00
bors
04bded5d6e Auto merge of #13235 - kyoto7250:fix_issue_13191, r=llogiq
Use `is_diagnostic_item` for checking a def_id in `unnecessary_min_or_max`.

close #13191
This PR fixes the false positives in `unnecessary_min_or_max `.
We should use `is_diagnostic_item` for checking def_ids in this lint.

----

changelog: fix false positive in `unnecessary_min_or_max `.
2024-08-28 14:50:20 +00:00
y21
e8ac4ea418 new lint: zombie_processes 2024-08-27 21:51:02 +02:00
bors
603d5a19c9 Auto merge of #13294 - WeiTheShinobi:new_lint_used_underscore_items, r=llogiq
Add new lint: `used_underscore_items`

Closes #13260

---

changelog: new [`used_underscore_items`] lint against using items with a single leading underscore
2024-08-27 10:59:31 +00:00
bors
f194e684b1 Auto merge of #13311 - alex-semenyuk:fix_manual_range_patterns, r=Manishearth
Fix manual_range_patterns case with one element at OR

Close #11825
As mentioned #11825 `OR` can be used for stylistic purposes with one element, we can filter this case from triggering lint

changelog: [`manual_range_patterns`]: not trigger when `OR` has only one element
2024-08-26 21:10:54 +00:00
Alexey Semenyuk
494112e51f Fix manual_range_patterns case with one element at OR 2024-08-27 01:32:07 +05:00
bors
b3fc578ca6 Auto merge of #13300 - kyoto7250:issue_13292, r=llogiq
check std::panic::panic_any in panic lint

close #13292
This PR detects `std::panic::panic_any` in panic lint.

changelog: check std::panic::panic_any in panic lint
2024-08-26 19:32:11 +00:00
bors
ebcd6bc785 Auto merge of #13091 - Alexendoo:empty-line-after-rewrite, r=dswij
Rewrite `empty_line_after_doc_comments` and `empty_line_after_outer_attr`, move them from `nursery` to `suspicious`

changelog: [`empty_line_after_doc_comments`], [`empty_line_after_outer_attr`]: rewrite and move them from `nursery` to `suspicious`

They now lint when there's a comment between the last attr/doc comment and the empty line, to cover the case:

```rust
/// Docs for `old_code
// fn old_code() {}

fn new_code() {}
```

When these lints or `suspicious_doc_comments` trigger we no longer trigger any other doc lint as a broad fix for #12917, reverts some of #13002 as the empty line lints cover it

I ended up not doing https://github.com/rust-lang/rust-clippy/issues/12917#issuecomment-2161828859 as I don't think it's needed
2024-08-25 17:47:09 +00:00
bors
083e20a6dc Auto merge of #13113 - nyurik:ignore-pass-by-val-for-pfx, r=blyxyas
Ignore underscore-prefixed args for needless_pass_by_value lint

When a user explicitly tags a param as unused (yet?), there is no need to raise another lint on it.

fixes #7295

Note that I had to rename all `_*` params in the tests, but kept the variable name length to avoid extra changes in the expected output.

changelog: [`needless_pass_by_value`]: do not warn if the argument name starts with an `_`
2024-08-25 17:28:51 +00:00
WeiTheShinobi
d40e04a1cb
used_underscore_items will not lint exteranl item 2024-08-26 00:52:52 +08:00
bors
508a7b4b38 Auto merge of #129531 - Jarcho:clippyup, r=Manishearth
Clippy subtree update

r? `@Manishearth`
2024-08-25 11:56:57 +00:00
bors
40bca0d944 Auto merge of #13285 - alex-semenyuk:ignore_todo_for_diverging_sub_expression, r=xFrednet
Diverging subexpression lint should not fire on todo!()

As per #10243  it is not that helpful to point out that a subexpression diverges, so do not fire on todo

changelog: [`diverging_sub_expression`]: do not trigger on todo
2024-08-25 09:51:40 +00:00
Jason Newcomb
173d5a6af0 Merge commit '0f8eabd6231366bfc1bb1464601297c2d48f8f68' into clippyup 2024-08-24 18:33:44 -04:00
Jason Newcomb
e348fe2233 Merge branch 'master' into rustup 2024-08-24 16:31:01 -04:00
Alex Macleod
3474df6a8e Rewrite empty_line_after_doc_comments and empty_line_after_outer_attr 2024-08-24 18:07:31 +00:00
Pavel Grigorenko
3c4367a80f Fix elided_named_lifetimes in code 2024-08-24 19:21:32 +03:00
kyoto7250
b179c3e7f7 check std::panic::panic_any in panic lint 2024-08-25 00:56:02 +09:00
bors
30e0b69908 Auto merge of #12993 - GuillaumeGomez:too_long_first_doc_paragraph, r=Centri3
Add new `too_long_first_doc_paragraph` first paragraph lint

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

changelog: Add new `too_long_first_doc_paragraph` first paragraph lint
2024-08-24 15:23:34 +00:00
bors
497177fa50 Auto merge of #13296 - Jarcho:get_src_display3, r=Alexendoo
Replace more uses of `snippet_opt`.

Almost all calls are removed after this.

changelog: none
2024-08-24 12:42:32 +00:00
Alexey Semenyuk
f4fc3858bc Fix suggestion unwrap_or_else 2024-08-24 15:43:00 +05:00
Jason Newcomb
9450b4af48 Replace more uses of snippet_opt. 2024-08-21 14:41:18 -04:00
Jason Newcomb
8a4c34a5b7 Start removing snippet_opt 2024-08-21 12:25:10 -04:00
Bruce Mitchener
3f97261fba Fix a couple of typos. 2024-08-21 21:42:57 +07:00
WeiTheShinobi
b615c82180
Add new lint: used_underscore_items 2024-08-21 19:57:41 +08:00
bors
e5a1ef0795 Auto merge of #13290 - Jarcho:interior_mut_quick, r=Alexendoo
`declare_interior_mutable_const`: Ignore pointer types.

fixes #12951
fixes #13233

changelog: `declare_interior_mutable_const`: Ignore pointer types.
2024-08-20 18:04:47 +00:00
Jason Newcomb
687d4e3d16 declare_interior_mutable_const: Ignore pointer types. 2024-08-20 12:01:24 -04:00
bors
70650de720 Auto merge of #13241 - alex-semenyuk:fix_double_must_use, r=xFrednet
Fix confusing message in double_must_use lint

Close #13003
As mentioned at #13003 it isn't quite clear what it means "an empty `#[must_use]` attribute" so clarify it

changelog: [none]
2024-08-20 15:58:30 +00:00
Milo Moisson
fc8a025f17
fix(cfg_not_test): lint description typo 2024-08-20 12:10:32 +02:00
bors
d0e637da19 Auto merge of #13281 - alex-semenyuk:string_slice_fix, r=y21
Trigger [`string_slice`] if expression is reference to `&str`

Close #12708
changelog: [`string_slice`]: trigger lint if expression is reference to `&str`
2024-08-19 20:12:36 +00:00
bors
e7d9fcf8b2 Auto merge of #13288 - kyoto7250:fix-13184, r=y21
fix false positive in explicit_iter_loop with msrv

close #13184

This PR fix false positive in explicit_iter_loop when msrv < 1.80

changelog: fix false positive in explicit_iter_loop when msrv < 1.80
2024-08-19 20:03:46 +00:00
Alexey Semenyuk
7b7cf440cb string_slice should detect on Cow 2024-08-19 23:25:45 +05:00
bors
ba6bc81277 Auto merge of #13278 - Alexendoo:misc-cleanup, r=y21
Misc cleanup

changelog: none
2024-08-19 17:42:25 +00:00
kyoto7250
1958e1acd4 fix false position in explicit_iter_loop with msrv 2024-08-20 01:51:32 +09:00
Alexey Semenyuk
9732128e83 Diverging subexpression lint should not fire on todo!() 2024-08-18 22:05:57 +05:00
sobolevn
4e6fc6fa05
Improve collapsible_match error message syntax 2024-08-18 19:40:56 +03:00
Guillaume Gomez
a2033428c4 Do not emit TOO_LONG_FIRST_DOC_PARAGRAPH lint if item is generated from proc-macro and simplify code to emit lint 2024-08-18 14:14:00 +02:00
bors
bfe7f070bd Auto merge of #13248 - Alexendoo:format-arg-ast-fallback, r=xFrednet
Remove `find_format_arg_expr` AST fallback

If the function fails where it shouldn't we can fix that directly, but the fallback path is untested as I'm not aware of a case where it would fail

changelog: none
2024-08-18 09:11:03 +00:00
bors
233b5f2083 Auto merge of #13273 - alex-semenyuk:assigning_clones_disable_for_test, r=blyxyas
Disable assigning_clones for tests

Close: #12752
As mentioned at #12752 when a test struct is initialized with some default string, this inverts the order of assignee/assignment and makes a bit harder to read/write code

changelog: [`assigning_clones.rs`]: disable assigning_clones for tests
2024-08-18 02:15:36 +00:00
Alex Macleod
6993752607 Replace some iteration with get_[type_]diagnostic_name 2024-08-17 18:52:55 +00:00
Alex Macleod
9aa656df9f Remove redundant doc comments 2024-08-17 18:44:26 +00:00
Alex Macleod
ed46141081 Remove duplicate type_diagnostic_name function 2024-08-17 18:10:46 +00:00
Alex Macleod
4f661302c6 Replace span_suggestion_with_style with _verbose 2024-08-17 18:09:28 +00:00
Alex Macleod
c0373616d0 Fix code snippet in from_str_radix_10 docs 2024-08-16 15:28:42 +00:00
Alexey Semenyuk
953c7ed41e Disable assigning_clones for tests 2024-08-16 16:21:03 +05:00
bors
73819440ea Auto merge of #13193 - alex-semenyuk:fix_doc_unused_io_amount, r=xFrednet
Fix doc example for UNUSED_IO_AMOUNT

Cosmetic changes. Unify example for UNUSED_IO_AMOUNT

changelog: none
2024-08-14 08:17:18 +00:00
bors
70457f637d Auto merge of #13253 - alex-semenyuk:fix_message_unnecessary_unwrap, r=llogiq
Clarify suggestion message for unwrap lint

Close #10217
As mentioned at #10217 message for `unwrap` uses `..` like `Some(..)` which can confuse with slice and other places mostly use `<item>` like `for (i, <item>) in target_groups_json.iter().enumerate().skip(1) {` So replace  `..` to `<item>`

changelog: [`unnecessary_unwrap`] clarify suggestion message
2024-08-13 23:50:05 +00:00
Antoni Spaanderman
5fee840875
fix indentation in docs 2024-08-13 13:13:02 +02:00
y21
a5e3a3f9b6 move manual_c_str_literals to complexity 2024-08-12 22:54:20 +02:00
Alex Macleod
a22ce2d005 Remove HashSets from Conf 2024-08-12 20:24:47 +00:00
Alex Macleod
182cd5f278 Replace the metadata collector with tests 2024-08-12 20:24:46 +00:00
bors
e07078482b Auto merge of #13261 - antonilol:fix-doc-code-blocks, r=xFrednet
fix code blocks in doc comments inconsistently using 3 or 4 spaces of indentation

The metadata collector script was treating the space lines all start with as indentation. This caused code block's triple backticks to get a space in front of it, like this:
```
 ```rust
^ this space
```
Code after that that is indented with 4 spaces will only have 3 of those rendered.
Example (taken from [here](https://rust-lang.github.io/rust-clippy/master/index.html#/missing_panics_doc)):
```rust
...
pub fn divide_by(x: i32, y: i32) -> i32 {
   if y == 0 {                      // 3 spaces
       panic!("Cannot divide by 0") // 7 spaces
...
```

Also added 'compile_fail' alongside the other rustdoc directives (second code block [here](https://rust-lang.github.io/rust-clippy/master/index.html#/macro_metavars_in_unsafe) had no highlighting), fixed a doc comment using 'rs' instead of 'rust' and removed some spaces causing an extra missing space of indentation (see second code block [here](https://rust-lang.github.io/rust-clippy/master/index.html#/map_err_ignore)).

changelog: none
2024-08-12 19:14:50 +00:00
bors
1984752623 Auto merge of #13255 - Jarcho:get_src_display2, r=Manishearth
Remove more `snippet_opt` calls

First commit is the same as #13244

changelog: none
2024-08-12 18:50:19 +00:00
Antoni Spaanderman
d7f1252ddf
fix code blocks in doc comments inconsistently using 3 or 4 spaces of indentation 2024-08-12 18:42:13 +02:00
bors
52192aa321 Auto merge of #13243 - Alexendoo:rustcversion, r=flip1995
Replace `rustc_semver` with `rustc_session::RustcVersion`

Allows dropping a dependency but there is a behaviour change here, the following versions are no longer accepted:

* `1` (would need to be `1.0` or `1.0.0`)
* `1.0.0-alpha`
* `1.0.0-alpha.2`
* `1.0.0-beta`

But this seems unlikely to effect anybody, I did some GitHub searching and found no occurrences outside our UI tests

r? `@flip1995`

changelog: none
2024-08-12 08:24:00 +00:00
Jason Newcomb
ddf2ba5886 Remove more instances of snippet_opt. 2024-08-11 18:07:53 -04:00
Alexey Semenyuk
f93fb9a417 Clarify message for unwrap lint 2024-08-11 20:33:28 +05:00
bors
c8b0923a73 Auto merge of #13163 - GuillaumeGomez:fix-13097, r=Alexendoo
Fix case where doc_markdown is triggered on words ending with "ified"

Fixes #13097.

r? `@Alexendoo`

changelog: Fix case where doc_markdown is triggered on words ending with "ified"
2024-08-10 17:51:56 +00:00
bors
37f98fffe7 Auto merge of #13220 - y21:issue13219, r=dswij
[`macro_metavars_in_unsafe`]: recognize metavariables in tail expressions

Fixes #13219

`macro_metavars_in_unsafe` keeps track of the current "expansion depth" (incremented/decremented when entering/leaving a macro span) to tell if an expression from the root context is contained within a macro (see the doc comment I added for a hopefully better explanation)

Before this PR, we didn't increment said `expn_depth` for `unsafe` blocks within macros, because we already do that in `visit_stmt` anyway, so it would work fine for statements, but that's not enough for tail expressions of an unsafe block.

So we now also increment it for macro unsafe blocks.
Also updated the comment for `expn_depth` while I'm at it because "This is not necessary for correctness" isn't correct now that I think about it

------

changelog: none
2024-08-10 12:43:43 +00:00
Alex Macleod
4231e93bf7 Remove find_format_arg_expr AST fallback 2024-08-10 10:50:47 +00:00
Jason Newcomb
f9509d3574 Refactor absolute_paths:
* Check the path length first
* Use `is_from_proc_macro`
* Use symbols instead of strings when checking crate names
2024-08-09 22:08:29 -04:00
Jason Newcomb
9afab36ca9 Rename get_source_text to get_source_range. Add new get_source_text which returns a displayable string-like type. 2024-08-09 09:27:00 -04:00
Alex Macleod
b32a0176fa Replace rustc_semver with rustc_session::RustcVersion 2024-08-09 13:00:24 +00:00
bors
1c81105b43 Auto merge of #13211 - rzvxa:respect_allow_inconsistent_struct_constructor_on_adt, r=Alexendoo
Respect allow `inconsistent_struct_constructor` on the struct definition

Closes #13203

Now we check if the target type is marked with `#[allow(clippy:inconsistent_struct_constructor)]` before lining.
As a side-effect of this change, The rule in the subject no longer runs on non-local `AdtDef`s. However, as suggested by `@Jarcho` it shouldn't be a big deal since most of the time we didn't have access to this information anyway.

> You can't get lint attributes from other crates. I would probably just restrict the lint to only work with types from the current crate while you're at it. Upstream crates don't have a definition order from the point of view of the current crate (with the exception of #[repr(C)] structs).

changelog: Respect allow `inconsistent_struct_constructor` on the struct definition.
2024-08-09 12:23:53 +00:00
rzvxa
d85cf0bacd use fulfill_or_allowed over is_lint_allowed. 2024-08-09 12:18:56 +03:30
Nicholas Nethercote
e785219238 Shrink TyKind::FnPtr.
By splitting the `FnSig` within `TyKind::FnPtr` into `FnSigTys` and
`FnHeader`, which can be packed more efficiently. This reduces the size
of the hot `TyKind` type from 32 bytes to 24 bytes on 64-bit platforms.
This reduces peak memory usage by a few percent on some benchmarks. It
also reduces cache misses and page faults similarly, though this doesn't
translate to clear cycles or wall-time improvements on CI.
2024-08-09 14:33:25 +10:00
Alexey Semenyuk
9948b423a0 Fix confusing message in double_must_use lint 2024-08-09 01:35:28 +05:00
Philipp Krones
1ac76a2062 Merge commit 'cb806113e0f83a8f9b47d35b453b676543bcc40e' into clippy-subtree-update 2024-08-08 19:13:50 +02:00
Philipp Krones
7a73a101e9
Merge remote-tracking branch 'upstream/master' into rustup 2024-08-08 18:54:43 +02:00
kyoto7250
c2ed04be16 check the def_id with using diagnostic_item in unnecessary_min_or_max lint
https://github.com/rust-lang/rust-clippy/issues/13191
2024-08-09 00:48:38 +09:00
bors
b1e87922c1 Auto merge of #13200 - Jarcho:constant_no_typeck, r=Alexendoo
Don't use `LateContext` in the constant evaluator

This also changes the interface to require explicitly creating the context. `constant` could be added back in, but the others are probably not worth it.

A couple of bugs have been fixed. The wrong `TypeckResults` was used once when evaluating a constant, and the wrong `ParamEnv` was used by some callers (there wasn't a way to use the correct one).

changelog: none
2024-08-08 14:42:42 +00:00
Jason Newcomb
e4ad36d6a8 Require ConstEvalCtxt to be constructed. 2024-08-08 10:37:10 -04:00
Jason Newcomb
d2cb227eb4 Don't store LateContext in ConstEvalLateContext 2024-08-08 10:34:53 -04:00
bors
ffc391c766 Auto merge of #13231 - Jarcho:no_tree_walk_in_const, r=Alexendoo
Don't walk the HIR tree when checking for a const context

changelog: none
2024-08-08 13:47:18 +00:00