Commit graph

10650 commits

Author SHA1 Message Date
Matthias Krüger
2360a7cad0 cargo clippy dev: collecting one-line clippy warnings works now 2021-01-23 02:18:11 +01:00
Matthias Krüger
69c0757334 clippy cargo dev: fix checking of crates 2021-01-23 02:18:11 +01:00
Matthias Krüger
e69147486e cargo clippy dev: fix extraction of downloaded crates 2021-01-23 02:18:11 +01:00
Matthias Krüger
63176834c2 cargo dev crater: fixes and debug prints 2021-01-23 02:18:11 +01:00
Matthias Krüger
30d85942cf crater: hook into main.rs 2021-01-23 02:18:11 +01:00
Matthias Krüger
5353591b1b cargo dev crater: work on downloading and extracting crate sources 2021-01-23 02:18:11 +01:00
Matthias Krüger
bec916d02d cargo dev crater: lay out the base plan 2021-01-23 02:18:11 +01:00
bors
70386ff352 Auto merge of #6403 - camsteffen:similar-names-underscore, r=Manishearth
Similar names ignore underscore prefixed names

changelog: Ignore underscore-prefixed names for similar_names

IMO, this lint is not very helpful for underscore-prefixed variables. Usually they are unused or are just there to ignore part of a destructuring.
2021-01-22 23:44:12 +00:00
bors
41d750c76c Auto merge of #6619 - camsteffen:collapsible-match, r=camsteffen
Improve collapsible_match

changelog: Fix collapsible_match false negatives

Allow `&` and/or `*` on the binding and make sure the type still matches.
2021-01-22 22:45:43 +00:00
Cameron Steffen
50abde20c9 Fix dogfood 2021-01-22 16:44:47 -06:00
Cameron Steffen
66afdd1f42 Enhance collapsible_match for adjusted bindings 2021-01-22 16:44:47 -06:00
bors
3c3f4a75b4 Auto merge of #6591 - camsteffen:manual-filter-map, r=llogiq
`manual_filter_map` and `manual_find_map`

changelog: Add `manual_filter_map` and replace `find_map` with `manual_find_map`

Replaces #6453

Fixes #3188
Fixes #4193

~Depends on #6567 (to fix an internal lint false positive)~

This replaces `filter_map` and `find_map` with `manual_filter_map` and `manual_find_map` respectively. However, `filter_map` is left in place since it is used for a variety of other cases. See discussion in #6453.
2021-01-22 22:28:41 +00:00
Manish Goregaokar
65d003a112 Clean up suggestion span; clarify help message 2021-01-22 12:08:47 -08:00
Manish Goregaokar
752274eabd Fix indentation of suggestion 2021-01-22 11:59:36 -08:00
Manish Goregaokar
8cb7e85006 Add exhaustive_structs lint 2021-01-22 11:59:36 -08:00
flip1995
8c00304bbb Make more traits of the From/Into family diagnostic items
Following traits are now diagnostic items:
- `From` (unchanged)
- `Into`
- `TryFrom`
- `TryInto`

This also adds symbols for those items:
- `into_trait`
- `try_from_trait`
- `try_into_trait`
2021-01-22 18:07:00 +01:00
Mara Bos
e9b2cf4f64 Rollup merge of #81236 - estebank:everybody-loop-now, r=oli-obk
Gracefully handle loop labels missing leading `'` in different positions

Fix #81192.

* Account for labels when suggesting `loop` instead of `while true`
* Suggest `'a` when given `a` only when appropriate
* Add loop head span to hir
* Tweak error for invalid `break expr`
* Add more misspelled label tests
* Avoid emitting redundant "unused label" lint
* Parse loop labels missing a leading `'`

Each commit can be reviewed in isolation.
2021-01-22 14:30:19 +00:00
bors
fbc374d0a6 Auto merge of #6621 - giraffate:improve_the_example_in_ref_in_deref, r=flip1995
Improve the example in `ref_in_deref`

Add a suggested code to the example in doc

changelog: none
2021-01-22 14:04:31 +00:00
Takayuki Nakata
23662d1353 Improve the example in ref_in_deref 2021-01-22 22:51:06 +09:00
bors
a1b89f07f0 Auto merge of #81135 - jyn514:no-backticks, r=flip1995
Fix formatting for removed lints

- Don't add backticks for the reason a lint was removed. This is almost
never a code block, and when it is the backticks should be in the reason
itself.
- Don't assume clippy is the only tool that needs to be checked for
backwards compatibility

I split this out of https://github.com/rust-lang/rust/pull/80527/ because it kept causing tests to fail, and it's a good change to have anyway.

r? `@flip1995`
2021-01-22 06:13:19 +00:00
Esteban Küber
3a5ede6ef4 Fix clippy and comment 2021-01-21 21:43:28 -08:00
Esteban Küber
612a7fc18e Add loop head span to hir 2021-01-21 21:41:46 -08:00
Cameron Steffen
82bab19a01 Deprecate find_map lint 2021-01-21 18:19:55 -06:00
Cameron Steffen
a22915bf48 Remove unneeded allow's 2021-01-21 18:19:53 -06:00
Cameron Steffen
a752d31e0a Replace find_map with manual_find_map 2021-01-21 18:18:21 -06:00
Cameron Steffen
c92bdc4dbb Split filter_map into manual_filter_map 2021-01-21 18:18:18 -06:00
Cameron Steffen
7a8660861e Add expr_fallback to SpanlessEq 2021-01-21 18:17:25 -06:00
Cameron Steffen
e89ad4ba71 Fix comment 2021-01-21 18:17:25 -06:00
Cameron Steffen
2d509f8b40 Check if let guard in collapsible_match 2021-01-21 18:13:36 -06:00
xFrednet
a905cf6737 Added documentation for common abbreviations
This list was created as a collaborative effort on Zulip and the [thread] is definitely worth a read as we had quite some fun. A big **THANK YOU** goes out to everyone who participated you make this project fun to work on!!!

The Zulip [thread]: https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Common.20abbreviations.20in.20basics.2Emd/near/223548065
2021-01-22 00:25:24 +01:00
Manish Goregaokar
09d4d49299 ExhaustiveEnums -> ExhaustiveItems 2021-01-21 13:39:00 -08:00
Manish Goregaokar
f6cb96ef07 Make exhaustive_enums only warn on exported items 2021-01-21 13:34:44 -08:00
Manish Goregaokar
dc93188805 Make exhaustive_enums a late pass 2021-01-21 13:31:15 -08:00
Manish Goregaokar
f1ab3024b2 New lint: exhaustive_enums 2021-01-21 13:31:06 -08:00
bors
043cf97abc Auto merge of #6609 - giraffate:fix_wrong_suggestion_of_ref_in_deref, r=llogiq
Fix a wrong suggestion of `ref_in_deref`

Fix #6358.

changelog: Fix a wrong suggestion of `ref_in_deref`
2021-01-21 19:16:11 +00:00
bors
4d381c3a84 Auto merge of #6605 - kawogi:doc-markdown, r=llogiq
Doc markdown

I added "WebGL" along the lines of the existing "OpenGL" to the whitelist of `doc_markdown` as I found this to be a pretty common term.

(this is a follow-up of the now closed https://github.com/rust-lang/rust-clippy/pull/6388)

changelog: Whitelist "WebGL" in `doc_markdown`.
2021-01-21 19:05:50 +00:00
bors
a982ab4cee Auto merge of #6532 - matthiaskrgr:mlmm, r=llogiq
match_like_matches_macro: strip refs in suggestion

fixes #6503

changelog: match_like_matches_macro: strip refs in suggestion (#6503)
2021-01-21 18:34:55 +00:00
bors
7b50a4ead7 Auto merge of #6408 - pro-grammer1:master, r=oli-obk
Fix false positive in write_literal and print_literal (numeric literals)

changelog: No longer lint numeric literals in [`write_literal`] and [`print_literal`].

Fixes #6335
2021-01-21 14:23:25 +00:00
bors
16d13a5a4b Auto merge of #6611 - pastchick3:master, r=flip1995
Fix the reversed suggestion message of `stable_sort_primitive`.

Now Clippy emits `stable_sort_primitive` warning as follows:

```
warning: used sort instead of sort_unstable to sort primitive type `usize`
  --> src\asm.rs:41:13
   |
41 |             self.successors.sort();
   |             ^^^^^^^^^^^^^^^^^^^^^^ help: try: `self.successors.sort_unstable()`
   |
   = note: `#[warn(clippy::stable_sort_primitive)]` on by default
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#stable_sort_primitive
```

I think the position of `sort` and `sort_unstable` in the first line should be reversed.

changelog: Fix the reversed suggestion message of `stable_sort_primitive`.
2021-01-21 14:12:43 +00:00
pastchick3
e42208f1b7 Improve the suggestion message of stable_sort_primitive. 2021-01-21 20:44:52 +08:00
Aaron Hill
2be935d396 Force token collection to run when parsing nonterminals
Fixes #81007

Previously, we would fail to collect tokens in the proper place when
only builtin attributes were present. As a result, we would end up with
attribute tokens in the collected `TokenStream`, leading to duplication
when we attempted to prepend the attributes from the AST node.

We now explicitly track when token collection must be performed due to
nomterminal parsing.
2021-01-20 18:09:32 -05:00
bors
d990c31990 Auto merge of #6567 - camsteffen:path-to-res-enum, r=Manishearth
Fix path_to_res for enum inherent items

changelog: none

I tried to add `Option::is_some` to the paths but got a false positive from the invalid paths lint. Turns out the `path_to_res` function does not find inherent impls for enums. I fixed this and took the liberty to do some additional cleanup in the method.
2021-01-20 21:35:11 +00:00
bors
e6665e42a3 Auto merge of #6475 - matsujika:capitalized_acronyms, r=flip1995
Add new lint `upper_case_acronyms`

Close #1335
I need some reviews on the English sentences because I feel they're messed up. ;)

changelog: Add new lint `upper_case_acronyms`
2021-01-20 10:26:01 +00:00
Hirochika Matsumoto
0ccb491caa
Remove nightly-gate of split_inclusive
Co-authored-by: Philipp Krones <hello@philkrones.com>
2021-01-20 18:14:09 +09:00
Hirochika Matsumoto
ab1da8f865 Add new lint upper_case_acronyms 2021-01-20 18:03:06 +09:00
Hirochika Matsumoto
6c830ff9e4 Run cargo dev new_lint 2021-01-20 18:02:29 +09:00
bors
fb0d7f1714 Auto merge of #6578 - MarijnS95:size-in-element-count-divide-by-byte-size, r=flip1995
size_of_in_element_count: Disable lint on division by byte-size

Fixes #6511

It is fairly common to divide some length in bytes by the byte-size of a single element before creating a `from_raw_parts` slice or similar operation. This lint would erroneously disallow such expressions.

Just in case, instead of simply disabling this lint in the RHS of a division, keep track of the inversion and enable it again on recursive division.

---

changelog: Do not trigger size_of_in_element_count when dividing by element size
2021-01-20 07:24:34 +00:00
Marijn Suijten
d4bf59b6ef size_of_in_element_count: Disable lint on division by byte-size
It is fairly common to divide some length in bytes by the byte-size of a
single element before creating a `from_raw_parts` slice or similar
operation. This lint would erroneously disallow such expressions.

Just in case, instead of simply disabling this lint in the RHS of a
division, keep track of the inversion and enable it again on recursive
division.
2021-01-19 20:05:40 +01:00
Marijn Suijten
391bb218b5 size_of_in_element_count: Separate test file in expressions and functions
An upcoming test case for new expresssion variants make the stderr file
go over 200 lines. Split this test case in two to have a clear
distinction between checking whether the lint is still applying on
all the functions with member counts as argument, versus validating
various member-count expressions that may or may not be invalid.
2021-01-19 20:05:39 +01:00
Takayuki Nakata
966320642b Fix a wrong suggestion of ref_in_deref 2021-01-20 00:21:33 +09:00