Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Clippy #84427

Merged
merged 106 commits into from
Apr 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
1768efa
Fix FP in `single_component_path_imports` lint
ThibsG Mar 14, 2021
6985d13
Take into account sub modules
ThibsG Mar 28, 2021
c05760f
Fix `macro_use_import` ICE
Jarcho Apr 3, 2021
81dfb9e
Check path imports per module
ThibsG Apr 4, 2021
1573d10
tabs_in_doc_comments: Fix ICE due to char indexing
phansch Apr 6, 2021
6b5778e
Fix `explicit_into_iter_loop`
Jarcho Mar 27, 2021
7468542
Introduce is_lang_ctor
camsteffen Apr 2, 2021
f6d1f36
Merge commit 'b40ea209e7f14c8193ddfc98143967b6a2f4f5c9' into clippyup
flip1995 Apr 8, 2021
c40fa00
Auto merge of #7022 - Jarcho:macro_use_import_ice, r=flip1995
bors Apr 8, 2021
4f7fc11
Add invalid null pointer usage lint.
boxdot Oct 18, 2020
75efc14
Auto merge of #7023 - boxdot:invalid-null-usage-v2, r=camsteffen
bors Apr 8, 2021
012f9d4
Use `register_renamed` instead of `register_removed` for uplifted lints
jyn514 Apr 9, 2021
f7c2c44
Auto merge of #7056 - jyn514:register-renamed, r=flip1995
bors Apr 9, 2021
297e84f
Handle imports which are nested directly
ThibsG Apr 10, 2021
dde46c9
Replace complex conditional with pattern matching
phansch Apr 10, 2021
8b9331b
Fix rustfmt error / Add comment for tab character
phansch Apr 10, 2021
47a4865
Fix dogfood
phansch Apr 10, 2021
43e6c65
Remove `debug_assert` from `panic_in_result_fn`
daxpedda Apr 10, 2021
8f4417f
Fix rustfmt
daxpedda Apr 10, 2021
271c163
Fix false-positive `debug_assert`
daxpedda Apr 10, 2021
fd5cf4e
Auto merge of #7060 - daxpedda:debug-assert-panic-in-result-fn, r=fli…
bors Apr 10, 2021
cb14e7e
Fix false-positive `debug_assert` in `panic`
daxpedda Apr 10, 2021
a45faf6
Deprecate filter_map
camsteffen Apr 9, 2021
75e20ba
Auto merge of #7063 - daxpedda:debug-assert-panic, r=Manishearth
bors Apr 10, 2021
3ce6f0d
Fix FP in `wrong_self_convention` lint
ThibsG Apr 11, 2021
67fad01
Auto merge of #6905 - ThibsG:fpSingleComponentPathImports5210, r=gira…
bors Apr 11, 2021
a6b514c
Auto merge of #7059 - camsteffen:filter-map, r=flip1995
bors Apr 11, 2021
fb54b70
Add a note on the issue #5953
rail-rain Apr 10, 2021
f0ceb28
Auto merge of #7065 - rail-rain:warn_copy_pass_by_ref, r=Manishearth
bors Apr 12, 2021
aecccbc
Auto merge of #7047 - camsteffen:lang-ctor, r=flip1995
bors Apr 12, 2021
c3ef585
Auto merge of #6982 - Jarcho:explicit_into_iter_loop_fp, r=flip1995
bors Apr 12, 2021
53260df
fix a false negative on `needless_return`
TaKO8Ki Apr 12, 2021
0218a3b
add tests for a false negative on `needless_return`
TaKO8Ki Apr 12, 2021
e6c67ad
fix limit_stderr_length error
TaKO8Ki Apr 12, 2021
411c0df
Auto merge of #7064 - ThibsG:WrongSelfFix, r=giraffate
bors Apr 12, 2021
d6beb18
Remove paths::STD_PTR_NULL
boxdot Apr 12, 2021
2a96bc4
Auto merge of #7067 - TaKO8Ki:fix-false-negative-on-needless-return, …
bors Apr 12, 2021
e9728b8
Auto merge of #7068 - boxdot:remove-std-ptr-null, r=camsteffen
bors Apr 12, 2021
76bd5d2
Refactor diagnostic item methods
camsteffen Apr 12, 2021
0d14429
Improve changelog check error handling
camsteffen Apr 12, 2021
8f3c245
Auto merge of #7074 - camsteffen:diag-methods, r=llogiq
bors Apr 13, 2021
26a1989
Fix a FP in `missing_const_for_fn`
rail-rain Apr 13, 2021
cbdebd9
Explain why we use `char_indices()` instead of `chars()`
phansch Apr 14, 2021
19740d9
Auto merge of #7076 - rail-rain:missing_const_for_fn, r=phansch
bors Apr 14, 2021
24921df
Auto merge of #7039 - phansch:melt-ice, r=flip1995
bors Apr 14, 2021
b1c675f
Auto merge of #7070 - camsteffen:changelog-stderr, r=flip1995
bors Apr 14, 2021
cbde4f2
parent_node_is_if_expr now also recognizes if let as parent if
xFrednet Apr 10, 2021
7e90bb6
Fixed website inline code background
xFrednet Apr 13, 2021
2992b19
Added inferred local type comparion to SpanlessEq
xFrednet Apr 13, 2021
0b4af72
PR suggestions and removing utils::parent_node_is_if_expr
xFrednet Apr 14, 2021
ce5e927
Improve `map_entry` lint
Jarcho Mar 25, 2021
b63a5b5
`map_entry` improvements
Jarcho Mar 25, 2021
3323ff7
`map_entry` improvements
Jarcho Mar 25, 2021
bcf3488
Minor cleanup of `map_entry` and a few additional tests.
Jarcho Mar 30, 2021
779d98f
Don't allow adjustments for `manual_map`
Jarcho Apr 15, 2021
014bf43
Add note for pre-expansion passes
camsteffen Apr 15, 2021
52c8c9c
Auto merge of #7090 - camsteffen:pre-expansion-note, r=Manishearth
bors Apr 15, 2021
f6c5d8d
Remove all usages of `match_path`, `match_qpath` and `match_path_ast`…
Jarcho Apr 7, 2021
586a993
Auto merge of #7049 - Jarcho:remove_match_path, r=camsteffen
bors Apr 15, 2021
b658163
Improve `redundant_pattern_matching`
Jarcho Jan 3, 2021
c02baba
`redundant_pattern_matching` fix inverted boolean when missing `Drop`…
Jarcho Apr 2, 2021
9a55c0c
Fix `single_match`
Jarcho Apr 16, 2021
faa9756
Auto merge of #7085 - Jarcho:manual_map_autoderef, r=giraffate
bors Apr 16, 2021
696562d
Remove #[main] attribute.
crlf0710 Apr 8, 2021
ddc2598
Auto merge of #7093 - Jarcho:single_match_fp, r=llogiq
bors Apr 16, 2021
1e0a3ff
Auto merge of #6937 - Jarcho:map_entry_suggestion, r=giraffate
bors Apr 16, 2021
61230f4
Fixed incosistent_struct_constructor triggers in macro-generated code
yawara Apr 16, 2021
0462666
Add cloned_instead_of_copied lint
camsteffen Apr 16, 2021
b049c88
Eat dogfood
camsteffen Apr 16, 2021
7f2068c
Auto merge of #6568 - Jarcho:redundant_pattern_matching, r=flip1995
bors Apr 16, 2021
28dbcd8
Auto merge of #7098 - camsteffen:cloned-copied, r=Manishearth
bors Apr 16, 2021
2d050f4
add type in help of from over Into
ABouttefeux Apr 16, 2021
ccd0f0b
added missing line in test ouput
ABouttefeux Apr 16, 2021
eaf0f3d
Auto merge of #7075 - xFrednet:7054-fp-branches-sharing-code, r=camst…
bors Apr 16, 2021
559dedd
Allow allman style braces in `suspicious_else_formatting`
Jarcho Apr 15, 2021
831c157
Auto merge of #7087 - Jarcho:allman_style_else, r=camsteffen
bors Apr 16, 2021
5af078a
Add flat_map_option lint
camsteffen Apr 16, 2021
e441b33
Auto merge of #7099 - ABouttefeux:master, r=llogiq
bors Apr 16, 2021
8b5faf4
Switch transmute_ptr_to_ptr to "pedantic" class.
taralx Apr 16, 2021
9137803
Do not ignore path segments in the middle in `#[allow]`/`#[warn]`/`#[…
Apr 10, 2021
8c37e19
Auto merge of #84064 - hyd-dev:unknown-lints, r=petrochenkov
bors Apr 18, 2021
024a49a
Fix clippy test using `ErrorKind`
CDirkx Mar 29, 2021
392d549
Auto merge of #78880 - CDirkx:not_supported, r=joshtriplett
bors Apr 18, 2021
243dc46
un-double `return` on try_err
llogiq Apr 18, 2021
c569d33
Auto merge of #7108 - rust-lang:fix-return-try-err, r=Manishearth
bors Apr 18, 2021
fe5cefc
Auto merge of #7101 - camsteffen:flat-map-option, r=giraffate
bors Apr 19, 2021
b20cbff
Fix links in doc
giraffate Apr 19, 2021
2d65b2d
Update pull request template
giraffate Apr 19, 2021
a3b1efd
Auto merge of #7112 - giraffate:update_pull_request_template, r=camst…
bors Apr 19, 2021
c6b381c
useless use of format! should return function directly
basavesh Apr 19, 2021
42d0702
Ignore aarch64 for this test as it's x86 assembly only. Fixes #7091
ctennis Apr 18, 2021
8f77e20
Auto merge of #7111 - giraffate:fix_link_in_doc, r=Manishearth
bors Apr 19, 2021
419bf6b
fix suggestion for unsized function parameters
lcnr Apr 18, 2021
e2e104b
Add lint to check for boolean comparison in assert macro calls
GuillaumeGomez Apr 15, 2021
b7c12f3
Auto merge of #7092 - basavesh:fix#7066, r=giraffate
bors Apr 19, 2021
6eae905
Add a test for FP in macro expansion
yawara Apr 20, 2021
ec38ea1
Auto merge of #7097 - yawara:fix/7069, r=llogiq
bors Apr 20, 2021
926286a
Auto merge of #7109 - ctennis:ct/asm_syntax_aarch64, r=flip1995
bors Apr 21, 2021
bbc22e2
Auto merge of #7083 - GuillaumeGomez:bool-assert-eq, r=camsteffen
bors Apr 21, 2021
224881b
add unnecessary_self_imports lint
ebobrow Apr 13, 2021
79b9eb5
Auto merge of #7072 - ebobrow:imports-ending-with-self, r=camsteffen
bors Apr 21, 2021
1f7aef3
Auto merge of #7102 - taralx:taralx-patch-1, r=flip1995
bors Apr 22, 2021
44c8057
Merge remote-tracking branch 'upstream/master' into rustup
flip1995 Apr 22, 2021
876897d
Bump nightly version -> 2021-04-22
flip1995 Apr 22, 2021
98e2b9f
Auto merge of #7119 - flip1995:rustup, r=flip1995
bors Apr 22, 2021
9482caf
Merge commit '98e2b9f25b6db4b2680a3d388456d9f95cb28344' into clippyup
flip1995 Apr 22, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/tools/clippy/.github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ Thank you for making Clippy better!
We're collecting our changelog from pull request descriptions.
If your PR only includes internal changes, you can just write
`changelog: none`. Otherwise, please write a short comment
explaining your change.
explaining your change. Also, it's helpful for us that
the lint name is put into brackets `[]` and backticks `` ` ` ``,
e.g. ``[`lint_name`]``.

If your PR fixes an issue, you can add "fixes #issue_number" into this
PR description. This way the issue will be automatically closed when
Expand All @@ -29,4 +31,5 @@ Delete this line and everything above before opening your PR.
---

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

changelog:
13 changes: 7 additions & 6 deletions src/tools/clippy/.github/workflows/clippy_bors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,16 @@ jobs:
run: |
MESSAGE=$(git log --format=%B -n 1)
PR=$(echo "$MESSAGE" | grep -o "#[0-9]*" | head -1 | sed -e 's/^#//')
output=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -s "https://api.github.com/repos/rust-lang/rust-clippy/pulls/$PR" | \
python -c "import sys, json; print(json.load(sys.stdin)['body'])" | \
grep "^changelog: " | \
sed "s/changelog: //g")
if [[ -z "$output" ]]; then
body=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -s "https://api.github.com/repos/rust-lang/rust-clippy/pulls/$PR" | \
python -c "import sys, json; print(json.load(sys.stdin)['body'])")
output=$(grep "^changelog:\s*\S" <<< "$body" | sed "s/changelog:\s*//g") || {
echo "ERROR: PR body must contain 'changelog: ...'"
exit 1
elif [[ "$output" = "none" ]]; then
}
if [[ "$output" = "none" ]]; then
echo "WARNING: changelog is 'none'"
else
echo "changelog: $output"
fi
env:
PYTHONIOENCODING: 'utf-8'
Expand Down
34 changes: 16 additions & 18 deletions src/tools/clippy/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ Current stable, released 2021-03-25

* Replace [`find_map`] with [`manual_find_map`]
[#6591](https://github.com/rust-lang/rust-clippy/pull/6591)
* [`unknown_clippy_lints`] Now integrated in the `unknown_lints` rustc lint
* `unknown_clippy_lints` Now integrated in the `unknown_lints` rustc lint
[#6653](https://github.com/rust-lang/rust-clippy/pull/6653)

### Enhancements
Expand Down Expand Up @@ -280,7 +280,7 @@ Released 2021-02-11

* Previously deprecated [`str_to_string`] and [`string_to_string`] have been un-deprecated
as `restriction` lints [#6333](https://github.com/rust-lang/rust-clippy/pull/6333)
* Deprecate [`panic_params`] lint. This is now available in rustc as `panic_fmt`
* Deprecate `panic_params` lint. This is now available in rustc as `non_fmt_panic`
[#6351](https://github.com/rust-lang/rust-clippy/pull/6351)
* Move [`map_err_ignore`] to `restriction`
[#6416](https://github.com/rust-lang/rust-clippy/pull/6416)
Expand Down Expand Up @@ -419,7 +419,7 @@ Released 2020-12-31
[#6037](https://github.com/rust-lang/rust-clippy/pull/6037)
* Rename `zero_width_space` to [`invisible_characters`]
[#6105](https://github.com/rust-lang/rust-clippy/pull/6105)
* Deprecate [`drop_bounds`] (uplifted)
* Deprecate `drop_bounds` (uplifted)
[#6111](https://github.com/rust-lang/rust-clippy/pull/6111)
* Move [`string_lit_as_bytes`] to `nursery`
[#6117](https://github.com/rust-lang/rust-clippy/pull/6117)
Expand Down Expand Up @@ -1018,7 +1018,7 @@ Released 2020-03-12
[#5015](https://github.com/rust-lang/rust-clippy/pull/5015)
* Move [`range_plus_one`] to pedantic group [#5057](https://github.com/rust-lang/rust-clippy/pull/5057)
* Move [`debug_assert_with_mut_call`] to nursery group [#5106](https://github.com/rust-lang/rust-clippy/pull/5106)
* Deprecate [`unused_label`] [#4930](https://github.com/rust-lang/rust-clippy/pull/4930)
* Deprecate `unused_label` [#4930](https://github.com/rust-lang/rust-clippy/pull/4930)

### Enhancements

Expand Down Expand Up @@ -1046,7 +1046,7 @@ Released 2020-03-12
* [`wildcard_enum_match_arm`] [#4934](https://github.com/rust-lang/rust-clippy/pull/4934)
* [`cognitive_complexity`] [#4935](https://github.com/rust-lang/rust-clippy/pull/4935)
* [`decimal_literal_representation`] [#4956](https://github.com/rust-lang/rust-clippy/pull/4956)
* [`unknown_clippy_lints`] [#4963](https://github.com/rust-lang/rust-clippy/pull/4963)
* `unknown_clippy_lints` [#4963](https://github.com/rust-lang/rust-clippy/pull/4963)
* [`explicit_into_iter_loop`] [#4978](https://github.com/rust-lang/rust-clippy/pull/4978)
* [`useless_attribute`] [#5022](https://github.com/rust-lang/rust-clippy/pull/5022)
* [`if_let_some_result`] [#5032](https://github.com/rust-lang/rust-clippy/pull/5032)
Expand Down Expand Up @@ -1080,7 +1080,7 @@ Released 2020-01-30
[Inside Rust Blog](https://blog.rust-lang.org/inside-rust/2019/11/04/Clippy-removes-plugin-interface.html) for
details [#4714](https://github.com/rust-lang/rust-clippy/pull/4714)
* Move [`use_self`] to nursery group [#4863](https://github.com/rust-lang/rust-clippy/pull/4863)
* Deprecate [`into_iter_on_array`] [#4788](https://github.com/rust-lang/rust-clippy/pull/4788)
* Deprecate `into_iter_on_array` [#4788](https://github.com/rust-lang/rust-clippy/pull/4788)
* Expand [`string_lit_as_bytes`] to also trigger when literal has escapes
[#4808](https://github.com/rust-lang/rust-clippy/pull/4808)
* Fix false positive in `comparison_chain` [#4842](https://github.com/rust-lang/rust-clippy/pull/4842)
Expand Down Expand Up @@ -1282,7 +1282,7 @@ Released 2019-05-20

[1fac380..37f5c1e](https://github.com/rust-lang/rust-clippy/compare/1fac380...37f5c1e)

* New lint: [`drop_bounds`] to detect `T: Drop` bounds
* New lint: `drop_bounds` to detect `T: Drop` bounds
* Split [`redundant_closure`] into [`redundant_closure`] and [`redundant_closure_for_method_calls`] [#4110](https://github.com/rust-lang/rust-clippy/pull/4101)
* Rename `cyclomatic_complexity` to [`cognitive_complexity`], start work on making lint more practical for Rust code
* Move [`get_unwrap`] to the restriction category
Expand Down Expand Up @@ -1375,7 +1375,7 @@ Released 2019-01-17

* New lints: [`slow_vector_initialization`], [`mem_discriminant_non_enum`],
[`redundant_clone`], [`wildcard_dependencies`],
[`into_iter_on_ref`], [`into_iter_on_array`], [`deprecated_cfg_attr`],
[`into_iter_on_ref`], `into_iter_on_array`, [`deprecated_cfg_attr`],
[`mem_discriminant_non_enum`], [`cargo_common_metadata`]
* Add support for `u128` and `i128` to integer related lints
* Add float support to `mistyped_literal_suffixes`
Expand Down Expand Up @@ -1649,7 +1649,7 @@ Released 2018-09-13

## 0.0.166
* Rustup to *rustc 1.22.0-nightly (b7960878b 2017-10-18)*
* New lints: [`explicit_write`], `identity_conversion`, [`implicit_hasher`], [`invalid_ref`], [`option_map_or_none`],
* New lints: [`explicit_write`], `identity_conversion`, [`implicit_hasher`], `invalid_ref`, [`option_map_or_none`],
[`range_minus_one`], [`range_plus_one`], [`transmute_int_to_bool`], [`transmute_int_to_char`],
[`transmute_int_to_float`]

Expand Down Expand Up @@ -2037,7 +2037,7 @@ Released 2018-09-13

## 0.0.64 — 2016-04-26
* Rustup to *rustc 1.10.0-nightly (645dd013a 2016-04-24)*
* New lints: [`temporary_cstring_as_ptr`], [`unsafe_removed_from_name`], and [`mem_forget`]
* New lints: `temporary_cstring_as_ptr`, [`unsafe_removed_from_name`], and [`mem_forget`]

## 0.0.63 — 2016-04-08
* Rustup to *rustc 1.9.0-nightly (7979dd608 2016-04-07)*
Expand Down Expand Up @@ -2091,7 +2091,7 @@ Released 2018-09-13

## 0.0.49 — 2016-03-09
* Update to *rustc 1.9.0-nightly (eabfc160f 2016-03-08)*
* New lints: [`overflow_check_conditional`], [`unused_label`], [`new_without_default`]
* New lints: [`overflow_check_conditional`], `unused_label`, [`new_without_default`]

## 0.0.48 — 2016-03-07
* Fixed: ICE in [`needless_range_loop`] with globals
Expand Down Expand Up @@ -2124,6 +2124,7 @@ Released 2018-09-13
[`blacklisted_name`]: https://rust-lang.github.io/rust-clippy/master/index.html#blacklisted_name
[`blanket_clippy_restriction_lints`]: https://rust-lang.github.io/rust-clippy/master/index.html#blanket_clippy_restriction_lints
[`blocks_in_if_conditions`]: https://rust-lang.github.io/rust-clippy/master/index.html#blocks_in_if_conditions
[`bool_assert_comparison`]: https://rust-lang.github.io/rust-clippy/master/index.html#bool_assert_comparison
[`bool_comparison`]: https://rust-lang.github.io/rust-clippy/master/index.html#bool_comparison
[`borrow_interior_mutable_const`]: https://rust-lang.github.io/rust-clippy/master/index.html#borrow_interior_mutable_const
[`borrowed_box`]: https://rust-lang.github.io/rust-clippy/master/index.html#borrowed_box
Expand All @@ -2148,6 +2149,7 @@ Released 2018-09-13
[`clone_double_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#clone_double_ref
[`clone_on_copy`]: https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy
[`clone_on_ref_ptr`]: https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_ref_ptr
[`cloned_instead_of_copied`]: https://rust-lang.github.io/rust-clippy/master/index.html#cloned_instead_of_copied
[`cmp_nan`]: https://rust-lang.github.io/rust-clippy/master/index.html#cmp_nan
[`cmp_null`]: https://rust-lang.github.io/rust-clippy/master/index.html#cmp_null
[`cmp_owned`]: https://rust-lang.github.io/rust-clippy/master/index.html#cmp_owned
Expand Down Expand Up @@ -2178,7 +2180,6 @@ Released 2018-09-13
[`double_must_use`]: https://rust-lang.github.io/rust-clippy/master/index.html#double_must_use
[`double_neg`]: https://rust-lang.github.io/rust-clippy/master/index.html#double_neg
[`double_parens`]: https://rust-lang.github.io/rust-clippy/master/index.html#double_parens
[`drop_bounds`]: https://rust-lang.github.io/rust-clippy/master/index.html#drop_bounds
[`drop_copy`]: https://rust-lang.github.io/rust-clippy/master/index.html#drop_copy
[`drop_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#drop_ref
[`duplicate_underscore_argument`]: https://rust-lang.github.io/rust-clippy/master/index.html#duplicate_underscore_argument
Expand Down Expand Up @@ -2216,6 +2217,7 @@ Released 2018-09-13
[`filter_next`]: https://rust-lang.github.io/rust-clippy/master/index.html#filter_next
[`find_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#find_map
[`flat_map_identity`]: https://rust-lang.github.io/rust-clippy/master/index.html#flat_map_identity
[`flat_map_option`]: https://rust-lang.github.io/rust-clippy/master/index.html#flat_map_option
[`float_arithmetic`]: https://rust-lang.github.io/rust-clippy/master/index.html#float_arithmetic
[`float_cmp`]: https://rust-lang.github.io/rust-clippy/master/index.html#float_cmp
[`float_cmp_const`]: https://rust-lang.github.io/rust-clippy/master/index.html#float_cmp_const
Expand Down Expand Up @@ -2264,10 +2266,9 @@ Released 2018-09-13
[`int_plus_one`]: https://rust-lang.github.io/rust-clippy/master/index.html#int_plus_one
[`integer_arithmetic`]: https://rust-lang.github.io/rust-clippy/master/index.html#integer_arithmetic
[`integer_division`]: https://rust-lang.github.io/rust-clippy/master/index.html#integer_division
[`into_iter_on_array`]: https://rust-lang.github.io/rust-clippy/master/index.html#into_iter_on_array
[`into_iter_on_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#into_iter_on_ref
[`invalid_atomic_ordering`]: https://rust-lang.github.io/rust-clippy/master/index.html#invalid_atomic_ordering
[`invalid_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#invalid_ref
[`invalid_null_ptr_usage`]: https://rust-lang.github.io/rust-clippy/master/index.html#invalid_null_ptr_usage
[`invalid_regex`]: https://rust-lang.github.io/rust-clippy/master/index.html#invalid_regex
[`invalid_upcast_comparisons`]: https://rust-lang.github.io/rust-clippy/master/index.html#invalid_upcast_comparisons
[`invisible_characters`]: https://rust-lang.github.io/rust-clippy/master/index.html#invisible_characters
Expand Down Expand Up @@ -2402,7 +2403,6 @@ Released 2018-09-13
[`overflow_check_conditional`]: https://rust-lang.github.io/rust-clippy/master/index.html#overflow_check_conditional
[`panic`]: https://rust-lang.github.io/rust-clippy/master/index.html#panic
[`panic_in_result_fn`]: https://rust-lang.github.io/rust-clippy/master/index.html#panic_in_result_fn
[`panic_params`]: https://rust-lang.github.io/rust-clippy/master/index.html#panic_params
[`panicking_unwrap`]: https://rust-lang.github.io/rust-clippy/master/index.html#panicking_unwrap
[`partialeq_ne_impl`]: https://rust-lang.github.io/rust-clippy/master/index.html#partialeq_ne_impl
[`path_buf_push_overwrite`]: https://rust-lang.github.io/rust-clippy/master/index.html#path_buf_push_overwrite
Expand Down Expand Up @@ -2488,7 +2488,6 @@ Released 2018-09-13
[`suspicious_unary_op_formatting`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_unary_op_formatting
[`tabs_in_doc_comments`]: https://rust-lang.github.io/rust-clippy/master/index.html#tabs_in_doc_comments
[`temporary_assignment`]: https://rust-lang.github.io/rust-clippy/master/index.html#temporary_assignment
[`temporary_cstring_as_ptr`]: https://rust-lang.github.io/rust-clippy/master/index.html#temporary_cstring_as_ptr
[`to_digit_is_some`]: https://rust-lang.github.io/rust-clippy/master/index.html#to_digit_is_some
[`to_string_in_display`]: https://rust-lang.github.io/rust-clippy/master/index.html#to_string_in_display
[`todo`]: https://rust-lang.github.io/rust-clippy/master/index.html#todo
Expand Down Expand Up @@ -2517,13 +2516,13 @@ Released 2018-09-13
[`unit_arg`]: https://rust-lang.github.io/rust-clippy/master/index.html#unit_arg
[`unit_cmp`]: https://rust-lang.github.io/rust-clippy/master/index.html#unit_cmp
[`unit_return_expecting_ord`]: https://rust-lang.github.io/rust-clippy/master/index.html#unit_return_expecting_ord
[`unknown_clippy_lints`]: https://rust-lang.github.io/rust-clippy/master/index.html#unknown_clippy_lints
[`unnecessary_cast`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
[`unnecessary_filter_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_filter_map
[`unnecessary_fold`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_fold
[`unnecessary_lazy_evaluations`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_lazy_evaluations
[`unnecessary_mut_passed`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_mut_passed
[`unnecessary_operation`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_operation
[`unnecessary_self_imports`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_self_imports
[`unnecessary_sort_by`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_sort_by
[`unnecessary_unwrap`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_unwrap
[`unnecessary_wraps`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_wraps
Expand All @@ -2541,7 +2540,6 @@ Released 2018-09-13
[`unstable_as_slice`]: https://rust-lang.github.io/rust-clippy/master/index.html#unstable_as_slice
[`unused_collect`]: https://rust-lang.github.io/rust-clippy/master/index.html#unused_collect
[`unused_io_amount`]: https://rust-lang.github.io/rust-clippy/master/index.html#unused_io_amount
[`unused_label`]: https://rust-lang.github.io/rust-clippy/master/index.html#unused_label
[`unused_self`]: https://rust-lang.github.io/rust-clippy/master/index.html#unused_self
[`unused_unit`]: https://rust-lang.github.io/rust-clippy/master/index.html#unused_unit
[`unusual_byte_groupings`]: https://rust-lang.github.io/rust-clippy/master/index.html#unusual_byte_groupings
Expand Down
6 changes: 3 additions & 3 deletions src/tools/clippy/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ All contributors are expected to follow the [Rust Code of Conduct].
- [IntelliJ Rust](#intellij-rust)
- [Rust Analyzer](#rust-analyzer)
- [How Clippy works](#how-clippy-works)
- [Syncing changes between Clippy and [`rust-lang/rust`]](#syncing-changes-between-clippy-and-rust-langrust)
- [Syncing changes between Clippy and `rust-lang/rust`](#syncing-changes-between-clippy-and-rust-langrust)
- [Patching git-subtree to work with big repos](#patching-git-subtree-to-work-with-big-repos)
- [Performing the sync from [`rust-lang/rust`] to Clippy](#performing-the-sync-from-rust-langrust-to-clippy)
- [Performing the sync from Clippy to [`rust-lang/rust`]](#performing-the-sync-from-clippy-to-rust-langrust)
- [Performing the sync from `rust-lang/rust` to Clippy](#performing-the-sync-from-rust-langrust-to-clippy)
- [Performing the sync from Clippy to `rust-lang/rust`](#performing-the-sync-from-clippy-to-rust-langrust)
- [Defining remotes](#defining-remotes)
- [Issue and PR triage](#issue-and-pr-triage)
- [Bors and Homu](#bors-and-homu)
Expand Down
5 changes: 2 additions & 3 deletions src/tools/clippy/clippy_lints/src/assertions_on_constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,9 @@ fn match_assert_with_message<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>)
_ => &block.expr,
};
// function call
if let Some(args) = match_panic_call(cx, begin_panic_call);
if args.len() == 1;
if let Some(arg) = match_panic_call(cx, begin_panic_call);
// bind the second argument of the `assert!` macro if it exists
if let panic_message = snippet_opt(cx, args[0].span);
if let panic_message = snippet_opt(cx, arg.span);
// second argument of begin_panic is irrelevant
// as is the second match arm
then {
Expand Down
75 changes: 75 additions & 0 deletions src/tools/clippy/clippy_lints/src/bool_assert_comparison.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
use clippy_utils::diagnostics::span_lint_and_sugg;
use clippy_utils::{ast_utils, is_direct_expn_of};
use rustc_ast::ast::{Expr, ExprKind, Lit, LitKind};
use rustc_errors::Applicability;
use rustc_lint::{EarlyContext, EarlyLintPass};
use rustc_session::{declare_lint_pass, declare_tool_lint};

declare_clippy_lint! {
/// **What it does:** This lint warns about boolean comparisons in assert-like macros.
///
/// **Why is this bad?** It is shorter to use the equivalent.
///
/// **Known problems:** None.
///
/// **Example:**
///
/// ```rust
/// // Bad
/// assert_eq!("a".is_empty(), false);
/// assert_ne!("a".is_empty(), true);
///
/// // Good
/// assert!(!"a".is_empty());
/// ```
pub BOOL_ASSERT_COMPARISON,
style,
"Using a boolean as comparison value in an assert_* macro when there is no need"
}

declare_lint_pass!(BoolAssertComparison => [BOOL_ASSERT_COMPARISON]);

fn is_bool_lit(e: &Expr) -> bool {
matches!(
e.kind,
ExprKind::Lit(Lit {
kind: LitKind::Bool(_),
..
})
) && !e.span.from_expansion()
}

impl EarlyLintPass for BoolAssertComparison {
fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &Expr) {
let macros = ["assert_eq", "debug_assert_eq"];
let inverted_macros = ["assert_ne", "debug_assert_ne"];

for mac in macros.iter().chain(inverted_macros.iter()) {
if let Some(span) = is_direct_expn_of(e.span, mac) {
if let Some([a, b]) = ast_utils::extract_assert_macro_args(e) {
let nb_bool_args = is_bool_lit(a) as usize + is_bool_lit(b) as usize;

if nb_bool_args != 1 {
// If there are two boolean arguments, we definitely don't understand
// what's going on, so better leave things as is...
//
// Or there is simply no boolean and then we can leave things as is!
return;
}

let non_eq_mac = &mac[..mac.len() - 3];
span_lint_and_sugg(
cx,
BOOL_ASSERT_COMPARISON,
span,
&format!("used `{}!` with a literal bool", mac),
"replace it with",
format!("{}!(..)", non_eq_mac),
Applicability::MaybeIncorrect,
);
return;
}
}
}
}
}
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/booleans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ fn simplify_not(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option<String> {
}
METHODS_WITH_NEGATION
.iter()
.cloned()
.copied()
.flat_map(|(a, b)| vec![(a, b), (b, a)])
.find(|&(a, _)| {
let path: &str = &path.ident.name.as_str();
Expand Down
Loading