Commit graph

6609 commits

Author SHA1 Message Date
bors
9a60a93cac Auto merge of #7897 - camsteffen:in-macro, r=flip1995
Replace `in_macro` usage with `from_expansion`

changelog: none

Generally replace `in_macro(span)` with `span.from_expansion()`. If we're just trying to avoid expanded code, this seems more appropriate because any kind of expanded code is prone to false positives. One place I did not touch is `macro_use.rs`. I think this lint could use a rewrite so I moved `in_macro` there, the only place it is still used.
2021-11-05 14:42:32 +00:00
bors
85e25923e1 Auto merge of #7909 - mikerite:fix-7816, r=camsteffen
Fix false negative in [`match_overlapping_arms`]

changelog: Fix false negative in [`match_overlapping_arms`]
2021-11-05 14:16:38 +00:00
Cameron Steffen
14d54f0f6e Use Span::from_expansion instead of in_macro 2021-11-05 08:50:17 -05:00
flip1995
1cc21db8c6
Merge remote-tracking branch 'upstream/master' into rustup 2021-11-04 12:03:28 +00:00
Serial
0db8c52291 Add suggestion to missing backticks error 2021-11-02 16:50:47 -04:00
Samuel Tardieu
7f8198acad Advise to put a :: prefix inside the ticks 2021-11-02 17:57:50 +01:00
xFrednet
db9e012927 Update clippy dependencies
* semver = "0.11" -> "1.0"
* cargo_metadata = "0.12" -> "0.14"
2021-11-02 14:19:31 +01:00
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
Michael Wright
693df63c7d Ensure match_overlapping_arms warns on first 2021-11-01 06:12:43 +02:00
Michael Wright
c3d45775c4 Fix match_overlapping_arm false negative
Fixes #7816
2021-11-01 06:12:43 +02: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