Lint comparison to empty slice using `PartialEq` methods
changelog: [`comparison_to_empty`]: Also detect comparaisons using `PartialEq` methods
Fix#13401
Use contiguous spans for empty_line_after_* suggestion
Replacing an empty span (which an empty line is) with an empty string triggers a debug assertion in rustc. This fixes the debug assertion by using contiguous spans, with the same resulting suggestion.
r? `@Alexendoo`
This unblocks the sync
changelog: none
Replacing an empty span (which an empty line is) with an empty string triggers a
debug assertion in rustc. This fixes the debug assertion by using contiguous
spans, with the same resulting suggestion.
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`
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
[`missing_panics_doc`] Fix#13381Fix#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
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.
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
`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.
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
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
Bump ui_test
This should give a bunch of ui improvements when lots of tests are running. Please lmk of any issues with it. Switching to `--quiet` should always avoid any issues, so there's a workaround if anything crops up. Also please check that this does not regress performance for you. It doesn't for me, but that doesn't mean much.
changelog: none
Visit struct fields recursively in uninit fallback check
This makes the fallback a bit more consistent with the other checks and rustc.
Fixes#13364. When using a generic type as the `Vec` element type like the issue title says, rustc's uninit check fails and our fallback is used, which didn't look at struct fields when it could.
changelog: none
[`single_match`, `single_match_else`] fix suggestion when match irrefutable
fixes#13012
changelog:[`single_match`, `single_match_else`]: fix suggestion when `match` irrefutable