Commit Graph

6405 Commits

Author SHA1 Message Date
bors
18cc4e74f8 Auto merge of #7907 - Alexendoo:non-ascii-restriction, r=flip1995
Move non_ascii_literal to restriction

It feels like the more apt category, since cases where you'd want it enabled would be pretty specific

changelog: Move [`non_ascii_literal`] to `restriction`
2021-11-02 10:36:26 +00:00
bors
9720619432 Auto merge of #7901 - samueltardieu:fix-7893, r=xFrednet,flip1995
Prevent clippy::needless_lifetimes false positive in async function definition

Scan `OpaqueDef` bounds for lifetimes as well. Those `OpaqueDef` instances are generated while desugaring an `async` function definition.

This fixes #7893

changelog: Prevent [`clippy::needless_lifetimes`] false positive in `async` function definition
2021-11-02 10:23:15 +00:00
bors
276e8951f1 Auto merge of #7851 - nbdd0121:master, r=flip1995
Fix manual_assert and match_wild_err_arm for `#![no_std]` and Rust 2021

Rust 2015 `std::panic!` has a wrapping block while `core::panic!` and Rust 2021 `std::panic!` does not. See rust-lang/rust#88919 for details.

Note that the test won't pass until clippy changes in rust-lang/rust#88860 is synced.

---

changelog: Fix [`manual_assert`] and [`match_wild_err_arm`] for `#![no_std]` and Rust 2021.

Fixes #7723
2021-11-02 10:09:47 +00:00
bors
38d80257d0 Auto merge of #7726 - dswij:unseparated-literal-suffix, r=flip1995
Unseparated literal suffix

Closes #7658

Since `literal_suffix` style is opinionated, we should disable by default and only enforce if it's stated as so.

changelog: [`unseparated_literal_suffix`] is renamed to `literal_suffix`, adds a new configuration `literal-suffix-style` to enforce a certain style writing literal_suffix. Possible values for `literal-suffix-style`: `"separated"`, `"unseparated"`
2021-11-02 09:57:12 +00:00
Samuel Tardieu
3f84010688 Examine lifetimes in OpaqueDef bounds as well
Fix #7893.
2021-11-02 10:54:58 +01:00
bors
4e355ebb6e Auto merge of #7819 - rust-lang:avoid-linting-impossible-truncation, r=flip1995
avoid linting `possible_truncation` on bit-reducing operations

---

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: avoid linting `possible_truncation` on bit-reducing operations
2021-11-02 09:44:27 +00:00
Takayuki Nakata
ec456de2a3 Small fixes for missing backticks in doc 2021-11-02 09:09:22 +09:00
Gary Guo
7e5f99ab58 Fix manual_assert for #![no_std] and Rust 2021 2021-11-01 15:47:33 +00:00
Dharma Saputra Wijaya
1085df58ac Add separated_literal_suffix as an alternative for
`unseparated_literal_suffix`

This commit adds a configuration `literal-suffix-style` to enforce a
specific style for unseparated_literal_suffix. The configuration accepts
two values:
- "separated"
    enforce all literals to be written separately (e.g. `123_i32`)
- "unseparated"
    enforce all literals to be written as unseparated (e.g. `123i32`)

Not specifying a value means that there is no preference on style and
any style should not be warned.
2021-11-01 22:26:13 +08:00
Alex Macleod
28c225f775 Move non_ascii_literal to restriction 2021-10-31 12:59:53 +00:00
bors
4c70c182c0 Auto merge of #7895 - ahmedkrmn:master, r=Manishearth
Disable "if_not_else" lints from firing on else-ifs

Fixes #7892

1. Convert `['if_not_else']` to `LateLintPass` and use `clippy_utils::is_else_clause` for checking.
2. Update tests.

changelog: [`if_not_else`] now ignores else if statements.
2021-10-29 20:31:51 +00:00
Ahmed Karaman
2f327aaba5
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.
2021-10-29 22:07:05 +02:00
Andre Bogus
00ea73e162 avoid linting possible_truncation on bit-reducing operations 2021-10-29 21:59:24 +02:00
bors
dbe167daaa Auto merge of #7890 - Alexendoo:ptr-arg-alias, r=camsteffen
Ignore references to type aliases in ptr_arg

Works using the fact that the hir path will point to a TyAlias, rather than being resolved to the underlying type

Fixes #7699

changelog: [`ptr_arg`] No longer lints references to type aliases
2021-10-29 19:45:26 +00:00
Cameron Steffen
022146d2c3 Rename if_then_panic to manual_assert 2021-10-28 09:41:53 -05:00
Cameron Steffen
d8fcfd7d64 Move if_then_panic to pedantic 2021-10-28 09:38:01 -05:00
bors
7788af9c47 Auto merge of #7891 - giraffate:fix_ice_for_undocumented_unsafe_blocks, r=flip1995
Fix ice in `undocumented_unsafe_blocks`

Fix https://github.com/rust-lang/rust-clippy/issues/7868

changelog: Fix ice in [`undocumented_unsafe_blocks`]
2021-10-28 13:37:40 +00:00
Takayuki Nakata
35bf041c21 Fix ICE in undocumented_unsafe_blocks 2021-10-28 22:10:59 +09:00
bors
89a11564cc Auto merge of #7847 - mikerite:fix-7829, r=flip1995
Fix false positive in `match_overlapping_arm`

Fixes #7829

changelog: Fix false positive in [`match_overlapping_arm`].
2021-10-28 08:59:21 +00:00
bors
ed71addee7 Auto merge of #7885 - devonhollowood:deprecated-cleanup, r=llogiq
Clean up `tests/ui/deprecated.rs`

Clean up `tests/ui/deprecated.rs`

Along with #7884, this fixes #7057

changelog: none
2021-10-27 18:38:38 +00:00
Alex Macleod
e2c30f05c1 Ignore references to type aliases in ptr_arg
Works using the fact that the hir path will point to a TyAlias, rather
than being resolved to the underlying type
2021-10-27 19:08:42 +01:00
bors
962e21cf15 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);
```

[impl]: a5f164faad/library/core/src/hash/mod.rs (L656)
2021-10-27 14:37:54 +00:00
Matt Stavola
36d4a4ea82
Add unit-hash lint 2021-10-27 06:32:37 -07:00
bors
444ef3e4d5 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`

changelog: none
2021-10-27 07:33:00 +00:00
bors
ba2ac3e263 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](df65291edd/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
2021-10-26 23:46:21 +00:00
bors
a48367e21c Auto merge of #7884 - devonhollowood:rename-cleanup, r=xFrednet
Clean up tests/ui/rename.rs

Part one of #7057, cleaning up `tests/ui/rename.rs`. `tests/ui/deprecated.rs` will be updated in a subsequent PR.

changelog: none
2021-10-26 21:16:44 +00:00
xFrednet
dea940259e Remove hidden code lines in Clippy's lint list 2021-10-26 22:33:46 +02:00
Alex Macleod
bd778e216d Register the generated lints from cargo dev new_lint 2021-10-26 19:05:29 +01:00
Devon Hollowood
e48ab448f9 Clean up tests/ui/deprecated.rs
This also removes the uplifted lints from this test suite -- these are now
tested in `tests/ui/rename.rs`
2021-10-26 10:52:35 -07:00
Dharma Saputra Wijaya
fb0fbad5ca Rename variable name in question_mark 2021-10-26 21:22:22 +08:00
dswij
a1a399d168 Fix question_mark FP on calls 2021-10-26 21:21:46 +08:00
bors
075996efd7 Auto merge of #7878 - rust-lang:string-slice, r=giraffate
new lint: string-slice

This is a restriction lint to highlight code that should have tests containing non-ascii characters. See #6623.

changelog: new lint: [`string-slice`]
2021-10-26 08:11:49 +00:00
Devon Hollowood
d0c04b4d78 Clean up tests/ui/rename.rs 2021-10-26 00:53:53 -07:00
Andre Bogus
999b3004c4 new lint: string-slice 2021-10-26 09:05:28 +02:00
bors
cb0132d209 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
2021-10-25 21:34:11 +00:00
bors
3ef1f19d60 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 🙃

Not too much more to say. Have a nice day 🌞

---

Fixes: rust-lang/rust-clippy#7869

changelog: ICE Fix: [`enum_variant_names`] #7869
2021-10-25 19:20:05 +00:00
xFrednet
1ad04f4054 Move non_send_fields_in_send_ty to suspicious
Also updated one configuration for nicer formatting
2021-10-25 19:32:17 +02:00
xFrednet
7517ae2fb3 Refactored some string handling to prevent ICEs and FNs 2021-10-24 22:47:39 +02:00
xFrednet
d38fddd899 Refactor camel_case util functions for new StrIndex 2021-10-24 21:13:43 +02:00
Cameron Steffen
20fb7f2916 Update rustfmt 2021-10-24 12:52:38 -05:00
xFrednet
1b91d986ea Rename clippy_utils::camal_case to clippy_utils::str_utils 2021-10-24 17:42:13 +02:00
Mike Welsh
e953dff536 Fix match_str_case_mismatch false positives
Properly consider uncased and titlecased characters.
Fixes #7863.
2021-10-23 02:03:15 -07:00
bors
df65291edd 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`
2021-10-21 21:51:24 +00:00
Manish Goregaokar
9def82d382 use a variable 2021-10-21 14:40:33 -07:00
bors
2ba1a6a331 Auto merge of #7801 - aDotInTheVoid:empty-format, r=camsteffen
Make useless_format recognize format!("")

Closes #7796

changelog: [`useless_format`] Fix for false negitive for `format!("")`
2021-10-21 18:15:23 +00:00
bors
c97a06d9af Auto merge of #7850 - ThibsG:PossibleCastTruncation5395, r=camsteffen
Fix FP: no lint when cast is coming from `signum` method call for `cast_possible_truncation` lint

Fixes a FP when cast is coming from `signum` method call

fixes: #5395

changelog: [`cast_possible_truncation`] Fix FP when cast is coming from `signum` method call
2021-10-21 18:01:39 +00:00
Nixon Enraght-Moony
081d0f82f4 Make useless_format recognize format!("")
Closes #7796
2021-10-21 19:01:28 +01:00
ThibsG
566244a8bc Do not lint when cast is coming from signum method call 2021-10-21 19:15:26 +02:00
Manish Goregaokar
1e8d9fb18c Handle 'implementation safety' headers as well 2021-10-21 08:50:50 -07:00
flip1995
085181e29d
Merge remote-tracking branch 'upstream/master' into rustup 2021-10-21 12:18:12 +02:00