Commit graph

6633 commits

Author SHA1 Message Date
xFrednet
8565fc468e
Add clippy version to Clippy's lint list 2021-11-10 19:48:30 +01:00
xFrednet
7c1e62d962
Added clippy::version attribute as lint metadata 2021-11-10 19:48:29 +01:00
dswij
a003ca6853 semicolon_if_nothing_returned now checks if the stmt ends with semicolon 2021-11-10 14:46:00 +08:00
bors
93f13d532f Auto merge of #7951 - mikerite:matches-20211109, r=llogiq
`match_overlapping_arm` refactoring

The main purpose of this pull request is to remove the unneeded and scary `unimplented!()` in the `match_arm_overlapping` code.

The rest is gratuitous refactoring.

changelog: none
2021-11-09 19:28:48 +00:00
bors
f69721f37c Auto merge of #7950 - Serial-ATA:issue-7920, r=llogiq
Fix `explicit_counter_loop` suggestion for non-usize types

changelog: Add a new suggestion for non-usize types in [`explicit_counter_loop`]

closes: #7920
2021-11-09 19:14:24 +00:00
bors
c94d62b153 Auto merge of #7949 - Serial-ATA:issue-7921, r=flip1995
Fix suggestion for deref expressions in redundant_pattern_matching

changelog: Fix suggestion for deref expressions in [`redundant_pattern_matching`]

closes: #7921
2021-11-09 12:37:49 +00:00
Serial
e54c341d05 Fix suggestion for deref expressions in redundant_pattern_matching 2021-11-09 07:25:09 -05:00
Michael Wright
8b7691551a matches: remove pub from some items
There is no reason for these to be `pub`. They aren't used anywhere
else.
2021-11-09 05:44:02 +02:00
Michael Wright
81fa758356 Improve variable naming 2 2021-11-09 05:44:02 +02:00
Michael Wright
c8f909ee54 Improve variable naming 2021-11-09 05:44:02 +02:00
Michael Wright
f829523340 Simplify range comparison code
Reword the `Kind` type so that the `cmp` function is simpler.
2021-11-09 05:44:02 +02:00
Michael Wright
949b25981c Change Bound to EndBound
Only the end bounds of ranges can actually be included or excluded. This
commit changes the SpannedRange type to reflect that. Update `Kind::value`
to and `Kind::cmp` for this change. `Kind::cmp` gets flipped to check value
first and then the bound details and is much shorter.
2021-11-09 05:44:02 +02:00
Michael Wright
98416d7f6c Remove unimplemented!() case in matches code
This unbounded case never actually happens because `all_ranges(..)` uses
the scrutinee type bounds for open ranges. Switch to our own `Bound`
enum so that we don't have this case.
2021-11-09 05:44:02 +02:00
Serial
680923491a Fix explicit_counter_loop suggestion for non-usize types 2021-11-08 22:21:05 -05:00
bors
830f2205d4 Auto merge of #7944 - Serial-ATA:deprecated-cfg-attr-msrv, r=giraffate
Add MSRV to deprecated_cfg_attr

changelog: Add MSRV to [`deprecated_cfg_attr`]

closes: #7922
2021-11-09 00:58:37 +00:00
Serial
413d255916 Add MSRV to deprecated_cfg_attr 2021-11-08 17:53:50 -05:00
bors
94517d397c Auto merge of #7938 - camsteffen:visitors, r=xFrednet
Introduce `expr_visitor` and `expr_visitor_no_bodies`

changelog: none

A couple utils that satisfy a *lot* of visitor use cases. Factoring in every possible usage would be really big so I just focused on cleaning clippy_utils.
2021-11-08 13:39:58 +00:00
Serial
2c6f03d48b Fix ICE in undocumented_unsafe_blocks 2021-11-07 14:28:30 -05:00
Serial
c96cd359f5 Extend author lint 2021-11-06 03:08:14 -04:00
Cameron Steffen
2c7b7e8c56 Remove if let check for match_ref_pats 2021-11-05 14:50:23 -05:00
Cameron Steffen
5239a90f70 Factor in some expr_visitor usages 2021-11-05 14:39:39 -05:00
Cameron Steffen
1c4dd8d3eb Remove trim_semicolon 2021-11-05 11:39:50 -05:00
bors
445c83f8f3 Auto merge of #7937 - flip1995:rustfmt-skip-artefact, r=Manishearth
Remove rustfmt::skip attribute from register_plugins function

r? `@Manishearth` since you added this in #540 😄

changelog: none
2021-11-05 15:34:46 +00:00
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
93ffc9d233
Remove rustfmt::skip attribute from register_plugins function 2021-11-05 10:54:37 +00: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