Commit graph

11949 commits

Author SHA1 Message Date
Philipp Krones
3ab1da8bab
Formatting 2024-09-22 20:52:15 +02:00
Philipp Krones
d140e26cc0
Merge remote-tracking branch 'upstream/master' into rustup 2024-09-22 20:51:17 +02:00
bors
abdf173ef2 Auto merge of #13322 - RuairidhWilliamson:anon-trait-import, r=y21
Unused trait imports (formerly anonymous trait import)

For #11969

I'm looking for help and feedback on implementing a new lint for suggesting `use ... as _` for traits where possible.

I have had a go at implementing this but I don't know if this is the best way to do it as I am new to clippy.

There are some edge cases I can think of where this doesn't work but have aired on the side of false negatives instead of false positives.

An example of a false negative. I couldn't figure out the best way to resolve an import from within clippy. The sub module imports MyAny so that cannot be anonymized but `use std::any::Any` could be. In this case it is not caught because `Any` and `MyAny` have the same DefId.
```rust
mod nested_mod_used_bad1 {
    use std::any::Any;
    use std::any::Any as MyAny;
    mod foo {
        use crate::nested_mod_used_bad1::MyAny;
        fn foo() {
            println!("{:?}", MyAny::type_id("foo"));
        }
    }
}
```

Any feedback is much appreciated.

-------
changelog: new lint: `unused_trait_names`
2024-09-22 14:22:40 +00:00
bors
612ae353d7 Auto merge of #13409 - lukaslueg:issue13407, r=dswij
Fix `if_then_some_else_none` sugg missing closure intro

Fixes #13407

#13407 works in current stable. The suggestion-generating code got trampled over in 0532104247 :-)

changelog: [`if_then_some_else_none`]: Fix missing closure in suggestion
2024-09-22 11:59:12 +00:00
bors
2c5e600386 Auto merge of #13392 - alex-semenyuk:doc_type_complexity, r=dswij
Clarify example for `type_complexity`

As mentioned #13387 it's not clear how to fix issue with complexity so add example for this

changelog: none
2024-09-22 11:51:07 +00:00
Ruairidh Williamson
739ef7bf0d
Add unused_trait_names tests 2024-09-21 00:57:47 +01:00
Ruairidh Williamson
05ebce8e1a
Add lint unused_trait_names 2024-09-21 00:56:38 +01:00
GnomedDev
4f319002cd [Clippy] Remove final std paths for diagnostic item 2024-09-20 10:39:31 +01:00
Lukas Lueg
290a01e448 Initial impl of unnecessary_first_then_check
Fixes #11212
2024-09-19 21:27:39 +02:00
GnomedDev
c7453b4280 [Clippy] Swap open_options to use diagnostic items instead of paths 2024-09-19 13:13:43 +01:00
GnomedDev
917775fff1 [Clippy] Swap iter_over_hash_type to use diagnostic items instead of paths 2024-09-19 13:13:43 +01:00
GnomedDev
37e38320b4 [Clippy] Swap non_octal_unix_permissions to use diagnostic item instead of path 2024-09-19 13:13:43 +01:00
GnomedDev
f1fc9c07c4 [Clippy] Swap unnecessary_owned_empty_strings to use diagnostic item instead of path 2024-09-19 13:13:43 +01:00
GnomedDev
1b76ae683c [Clippy] Swap manual_strip to use diagnostic items instead of paths 2024-09-19 13:13:43 +01:00
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
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