Michael Wright [Sat, 30 Oct 2021 04:22:19 +0000 (06:22 +0200)]
Simplify FullInt Ord impl
`cmp_s_u` is a tiny helper function only used by `cmp` and isn't useful on
it's own. Making it a nested function of `cmp` makes that clear and as a
bonus it's easier to call and doesn't require a `#[must_use]` attribute.
Ahmed Karaman [Fri, 29 Oct 2021 02:11:43 +0000 (04:11 +0200)]
Disable "if_not_else" lints firing on else-ifs
1. Convert IfNotElse to LateLintPass and use clippy_utils::is_else_clause for checking.
2. Handle the case where the span comes from desugaring.
3. Update tests.
bors [Wed, 27 Oct 2021 14:37:54 +0000 (14:37 +0000)]
Auto merge of #7875 - mbStavola:unit-hash, r=xFrednet
Add unit-hash lint
changelog: [`unit_hash`] Add lint for hashing unit values
This will lint for situations where the end user is attempting to hash a unit value (`()`), as the implementation in `std` simply [does nothing][impl]. Closes #7159 .
Example:
```rust
().hash(&mut state);
// Should (probably) be replaced with:
0_u8.hash(&mut state);
```
bors [Wed, 27 Oct 2021 07:33:00 +0000 (07:33 +0000)]
Auto merge of #7880 - Alexendoo:newlint-add-pass, r=flip1995
Register the generated lints from `cargo dev new_lint`
How to register a lint was something that took me a couple reads to figure out, this will hopefully make that easier. It appends the created lint to the end of the list when running `cargo dev new_lint`
bors [Tue, 26 Oct 2021 23:46:21 +0000 (23:46 +0000)]
Auto merge of #7860 - dswij:question-mark-fp, r=giraffate
Fix `question_mark` FP on custom error type
Closes #7859
#7840 aims to ignore `question_mark` when the return type is custom, which is [covered here](https://github.com/rust-lang/rust-clippy/blob/df65291edd6b89a241fed483ab165c32df468746/tests/ui/question_mark.rs#L144-L149). But this fails when there is a call in conditional predicate
changelog: [`question_mark`] Fix false positive when there is call in conditional predicate
bors [Mon, 25 Oct 2021 21:34:11 +0000 (21:34 +0000)]
Auto merge of #7865 - Herschel:fix-match-str-case-mismatch, r=xFrednet
Fix `match_str_case_mismatch` on uncased chars
False positives would result because `char::is_lowercase` and friends will return `false` for non-alphabetic chars and alphabetic chars lacking case (such as CJK scripts). Care also has to be taken for handling titlecase characters (`Dz`) and lowercased chars with no uppercase equivalent (`ʁ`).
For example, when verifying lowercase:
* Check `!any(char::is_ascii_uppercase)` instead of `all(char::is_ascii_lowercase)` for ASCII.
* Check that `all(|c| c.to_lowercase() == c)` instead of `all(char::is_lowercase)` for non-ASCII
Fixes #7863.
changelog: Fix false positives in [`match_str_case_mismatch`] on uncased characters
bors [Mon, 25 Oct 2021 19:20:05 +0000 (19:20 +0000)]
Auto merge of #7873 - xFrednet:7869-string-index-ice, r=Manishearth
Update `str` utils to prevent ICEs and FNs
This PR reworks some string handling for lints regarding enum naming. I hope the refactoring will prevent future ICEs and help with new bug free implementations.
It might be better to review this PR by going through the commits, as `clippy_utils::camel_case` was renamed to `clippy_utils::str_utils` and then changed further. GH sadly doesn't really make the changes that obvious :upside_down_face:
Not too much more to say. Have a nice day :sun_with_face:
bors [Mon, 25 Oct 2021 08:46:51 +0000 (08:46 +0000)]
Auto merge of #7872 - calebcartwright:sync-use-new-branch, r=flip1995
recommend new branch or deleting branch when synching from rust
changelog: none
r? `@flip1995` - thanks again for your assistance in zulip earlier, figured I'd take a pass at incorporating your recommendation to delete or use a new branch into the excellent docs here
bors [Thu, 21 Oct 2021 21:51:24 +0000 (21:51 +0000)]
Auto merge of #7856 - Manishearth:impl-safety, r=xFrednet
missing_safety_doc: Handle 'implementation safety' headers as well
We hit some FPs on this in `yoke`, it's somewhat normal to mark trait impl safety with "implementation safety". We could also broaden the check for headers which contain the word "safety" somehow, or split out impl safety stuff to only apply to traits.
changelog: handle 'implementation safety' headers in `missing_safety_doc`
bors [Wed, 20 Oct 2021 20:35:58 +0000 (20:35 +0000)]
Auto merge of #7838 - nhamovitz:trailing_zs_arr_wo_repr, r=Manishearth
Warn on structs with a trailing zero-sized array but no `repr` attribute
Closes #2868
changelog: Implement ``[`trailing_empty_array`]``, which warns if a struct is defined where the last field is a zero-sized array but there are no `repr` attributes. Zero-sized arrays aren't very useful in Rust itself, so such a struct is likely being created to pass to C code or in some other situation where control over memory layout matters. Either way, a `repr` attribute is needed.
Michael Wright [Wed, 20 Oct 2021 04:13:42 +0000 (06:13 +0200)]
Fix false positive in `match_overlapping_arm`
The bug was dues to the constant bytes being compared instead of their
values. This meant that negative values were being treated as larger
than some positive values.
bors [Tue, 19 Oct 2021 23:47:20 +0000 (23:47 +0000)]
Auto merge of #7833 - Dmitry-Borodin:patch-1, r=giraffate
Add reference to another doc with explanation
Add reference to another doc that explains which repository should be passed in this command since this is not covered in the command help itself.
changelog: none