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 #76034

Merged
merged 175 commits into from
Aug 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
175 commits
Select commit Hold shift + click to select a range
2d1515a
Miri: Renamed "undef" to "uninit"
pnadon Aug 8, 2020
a77e881
should_impl_trait - ignore methods with lifetime params
tnielens Jun 16, 2020
2bc0ecd
should_implement_trait - add test cases for every checked trait method
tnielens Jun 19, 2020
e6b2254
should_implement_trait - pr remarks
tnielens Jun 20, 2020
7cc1a2e
should_implement_trait - filter on explicit lifetime param only
tnielens Jun 23, 2020
166c520
should_impl_trait - pr comments
tnielens Jul 29, 2020
f9ba829
should_impl_trait - self linting
tnielens Aug 9, 2020
3e3e50b
Add example of false positive to PTR_ARG docs.
Ryan1729 Aug 10, 2020
fbf637d
formatting
Ryan1729 Aug 10, 2020
91aa55d
Rollup merge of #75226 - pnadon:miri-undef-uninit, r=RalfJung
JohnTitor Aug 11, 2020
b8713e3
unnecessary-mut-passed: make lint message say if fn is a function or …
matthiaskrgr Aug 11, 2020
3337f79
Auto merge of #5892 - matthiaskrgr:redundant_mut, r=flip1995
bors Aug 11, 2020
c0a9d64
stable-sort-primitive: make lint adhere to lint message convention
matthiaskrgr Aug 11, 2020
ac194ca
map_clone: make lint adhere to lint message convention
matthiaskrgr Aug 11, 2020
04867e0
mutex-atomic: make lint adhere to lint message convention
matthiaskrgr Aug 11, 2020
6af297f
iter-next-slice: make lint adhere to lint message convention
matthiaskrgr Aug 11, 2020
f171f89
int_plus_one: make lint adhere to lint message convention
matthiaskrgr Aug 11, 2020
bdf4dc3
implicit-saturating-sub: make lint adhere to lint message convention
matthiaskrgr Aug 11, 2020
1f17c3b
multiple_inherent_impl: make lint adhere to lint message convention
matthiaskrgr Aug 11, 2020
4236156
pub-enum-variant-names: make lint adhere to lint message convention
matthiaskrgr Aug 11, 2020
2de290d
duration-subsec: make lint adhere to lint message convention
matthiaskrgr Aug 11, 2020
db390f5
enum-clike-unportable-variant: tweak message a bit (Clike -> C-like)
matthiaskrgr Aug 11, 2020
89591a7
enum-variant-names: make lint adhere to lint message convention
matthiaskrgr Aug 11, 2020
605e027
if_let_some_result: make lint adhere to lint message convention
matthiaskrgr Aug 11, 2020
be3e695
if_not_else: make lint adhere to lint message convention
matthiaskrgr Aug 11, 2020
027780c
Merge commit '09bd400243ed6f7059fedc0c1623aae3792521d6' into clippyup
flip1995 Aug 11, 2020
fdc2f87
Auto merge of #75405 - flip1995:clippyup, r=Manishearth
bors Aug 12, 2020
8a96b9c
write.rs: don't clone TokenStream
matthiaskrgr Aug 12, 2020
7d2e42d
fix typo pointed out in review comment
Ryan1729 Aug 12, 2020
318c74a
Merge remote-tracking branch 'upstream/master' into rustup
flip1995 Aug 12, 2020
3ed0a4c
Auto merge of #5898 - flip1995:rustup, r=flip1995
bors Aug 12, 2020
2f4de2f
Auto merge of #5885 - Ryan1729:patch-2, r=flip1995
bors Aug 12, 2020
0fc61be
Add the other overloadable operations to suspicious_arithmetic_impl
Ryan1729 Aug 10, 2020
616682d
formatting
Ryan1729 Aug 10, 2020
c705817
trailing comma
Ryan1729 Aug 10, 2020
f4eeff9
add tests for Rem, BitAnd, BitOr, BitXor, Shl, and Shr
Ryan1729 Aug 12, 2020
c73cf9f
Auto merge of #5893 - matthiaskrgr:lint_msg, r=yaahc
bors Aug 12, 2020
7bd7a46
run tests/ui/update-references.sh to update 'suspicious_arithmetic_im…
Ryan1729 Aug 12, 2020
439bae6
Auto merge of #5884 - Ryan1729:patch-1, r=flip1995
bors Aug 12, 2020
480ccc3
Change Rc<Box<T>> recommendation to be Rc<T> instead of Box<T>
JarredAllen Aug 12, 2020
dc1e09b
Auto merge of #5897 - matthiaskrgr:no_clone_tts, r=flip1995
bors Aug 12, 2020
5634c8d
Fix: keep parenthesis for suggestion in `useless_conversion` lint
ThibsG Aug 12, 2020
4e28d99
Replace panics with early returns
JarredAllen Aug 12, 2020
9f827ab
Add reference to rustc-dev-guide about lint message
giraffate Aug 13, 2020
fc4fd91
Auto merge of #5900 - ThibsG:ParensUselessConversion4750, r=phansch
bors Aug 13, 2020
d5f5487
Auto merge of #5899 - JarredAllen:rc-box-suggestion, r=yaahc
bors Aug 13, 2020
ba363bd
Auto merge of #5901 - giraffate:add_reference_to_rustc_dev_guide, r=m…
bors Aug 13, 2020
429a1ce
merge `as_local_hir_id` with `local_def_id_to_hir_id`
lcnr Aug 12, 2020
48a1425
docs: typo in `temporary_cstring_as_ptr`: s/point/&s
ErichDonGubler Aug 13, 2020
8ecc0fc
Auto merge of #5905 - ErichDonGubler:patch-1, r=flip1995
bors Aug 13, 2020
8514b84
appreciative too_large_for_stack in useless `vec!`
wiomoc Aug 14, 2020
8e54997
Don't use `to_string` in impl Display
Jul 22, 2020
f98ffa2
Fix FP for `same_item_push`
giraffate Aug 14, 2020
72d2c2e
Lint `push_str` with a single-character string literal
wiomoc Aug 9, 2020
ae56e98
Merge lint with `single_char_pattern`
wiomoc Aug 14, 2020
b381ade
elide lifetimes
wiomoc Aug 14, 2020
f0cc006
Auto merge of #5910 - flip1995:rustup, r=flip1995
bors Aug 15, 2020
6d18fe7
Make needless_return a late lint pass
jrqc Aug 12, 2020
85f4ef0
Visitor added
jrqc Aug 12, 2020
65d10c7
Borrow checker added
jrqc Aug 13, 2020
cd6ca72
Known problems changed
jrqc Aug 13, 2020
a7d5c2f
Modifications according to the code review
jrqc Aug 13, 2020
96efaee
cargo dev update_lints
jrqc Aug 13, 2020
baa4cb1
early return removed
jrqc Aug 14, 2020
1a140dc
Improve needless_doctest_main by using the parser
ebroto Aug 15, 2020
f8db258
Auto merge of #5912 - ebroto:needless_doctest_main_improvements, r=Ma…
bors Aug 16, 2020
e522ca3
Auto merge of #5831 - chansuke:to_string_in_display, r=flip1995
bors Aug 16, 2020
c8e05fc
Auto merge of #5881 - wiomoc:feature/single-char-push_str, r=ebroto,f…
bors Aug 16, 2020
dff7e74
Auto merge of #5903 - jrqc:needless_return, r=ebroto,flip1995
bors Aug 16, 2020
78857cc
Auto merge of #5907 - wiomoc:feature/useless-vec-max-size, r=flip1995
bors Aug 16, 2020
3bd9889
Auto merge of #5725 - montrivo:should-impl-trait, r=flip1995
bors Aug 16, 2020
a3ea65c
Implement new lint
bugadani Jun 15, 2020
923d612
Rename the changelog footnote as well
bugadani Jun 15, 2020
848af39
Add note to `or_fun_call`, list checked methods
bugadani Jun 15, 2020
a7cc5d4
Also simplify if the closure body is an index expression
bugadani Jun 15, 2020
d7220db
Run cargo dev update_lints
bugadani Jun 15, 2020
75637c1
Catch function calls in argument lists, add tests that tuples don't g…
bugadani Jun 15, 2020
a7083ee
Removed the extra lifetime parameter
bugadani Jul 26, 2020
94cf90e
Apply suggested change
bugadani Jul 26, 2020
9c41822
Apply suggested change
bugadani Jul 26, 2020
d8f0a14
Fix typo in description of unnecessary_mut_passed
HactarCE Aug 16, 2020
d71b418
Moved to submodule, don't trigger if map_unwrap_or does
bugadani Aug 16, 2020
8a14c11
Cleanup, explain return value
bugadani Aug 16, 2020
3b52d7f
run cargo dev fmt
bugadani Aug 16, 2020
b7ee868
Fix dogfooding test errors
bugadani Aug 16, 2020
5d723d0
Auto merge of #5913 - HactarCE:patch-1, r=flip1995
bors Aug 16, 2020
b175642
Fix missed rename
bugadani Aug 16, 2020
fc1e07e
Rename lint to use plural form
bugadani Aug 16, 2020
8d0d89a
Auto merge of #5720 - bugadani:new-lint, r=flip1995,yaahc
bors Aug 16, 2020
6afa4ef
Introduce function for comparing expression values
tmiasko Aug 16, 2020
9b800b1
Rename SpanlessEq::ignore_fn to deny_side_effects
tmiasko Aug 16, 2020
d1dbf79
Expresions with Assign / AssignOp have side effects
tmiasko Aug 16, 2020
4f4abf4
Warn about explicit self-assignment
tmiasko Aug 16, 2020
8332fe8
Auto merge of #5894 - tmiasko:self-assignment, r=Manishearth
bors Aug 16, 2020
99ba290
Improve code style
giraffate Aug 16, 2020
262db3b
deps: bump cargo_metadata and semver
matthiaskrgr Aug 17, 2020
838c201
Auto merge of #5915 - matthiaskrgr:deps_, r=Manishearth
bors Aug 17, 2020
f13d2bf
clippy: support `QPath::LangItem`
davidtwco Aug 4, 2020
9360ca6
Auto merge of #5908 - giraffate:fix_fp_for_same_item_push, r=flip1995
bors Aug 17, 2020
ae0eb39
rust_ast::ast => rustc_ast
ryzokuken Apr 27, 2020
4b0e6d5
Auto merge of #75120 - JulianKnodt:rm_reps, r=oli-obk
bors Aug 17, 2020
c680602
Merge remote-tracking branch 'upstream/master' into rustup
flip1995 Aug 18, 2020
6220dff
Auto merge of #5922 - flip1995:rustup, r=flip1995
bors Aug 18, 2020
df4d42f
transmute: avoid suggesting from/to bits in const
ebroto Aug 17, 2020
6a12bae
no from/to bits in const: add tests cases for f64
ebroto Aug 18, 2020
902b282
Improve lint message in `to_string_in_display`
giraffate Aug 19, 2020
c236c0f
Fix false positive in `PRECEDENCE` lint
Aug 20, 2020
191b080
Capture tokens for Pat used in macro_rules! argument
Aaron1011 Jul 27, 2020
d891954
Auto merge of #5919 - ebroto:5747_from_bits_in_const, r=matthiaskrgr
bors Aug 20, 2020
4104611
Auto merge of #5928 - mikerite:fix-5924, r=ebroto
bors Aug 20, 2020
11efd75
Fix false negative in `option_as_ref_deref`
Aug 21, 2020
c2799c8
Merge remote-tracking branch 'upstream/master' into sync-from-rust
ebroto Aug 21, 2020
146e352
run cargo dev fmt
ebroto Aug 21, 2020
1a26dbf
Auto merge of #5938 - ebroto:sync-from-rust, r=ebroto
bors Aug 21, 2020
aa3b04f
Auto merge of #5933 - mikerite:fix-5927, r=matthiaskrgr
bors Aug 21, 2020
b57ef14
Auto merge of #5926 - giraffate:improve_lint_message_in_to_string_in_…
bors Aug 22, 2020
03bc7ae
Add async test case for `wrong_self_convention` lint
ThibsG Aug 21, 2020
a8520b0
Auto merge of #5934 - ThibsG:WrongSelfTestCase4037, r=ebroto
bors Aug 22, 2020
191b6c7
Don't lint if it has always inline attribute
ThibsG Aug 22, 2020
5b07b9e
Widen understanding of prelude import
stchris Aug 20, 2020
53508ae
Run sh tests/ui/update-all-references.sh
stchris Aug 20, 2020
e615a26
Use more elegant way to check for prelude string
stchris Aug 21, 2020
f21d10b
Auto merge of #5929 - stchris:issues/5917, r=ebroto
bors Aug 22, 2020
dd07860
Auto merge of #5941 - ThibsG:InlineInCopyPassByRef, r=yaahc
bors Aug 22, 2020
e8d33d7
Fix `let_and_return` bad suggestion
Aug 23, 2020
6dd65b8
Fix cargo dev new_lint for late lint passes
ebroto Aug 20, 2020
eb8ede7
Improve documentation related to the sync process
ebroto Aug 23, 2020
8776db9
Fix ICE in `repeat_once` lint
ebroto Aug 23, 2020
91b200c
Fix fp in `borrow_interior_mutable_const`
rail-rain Aug 23, 2020
2d86cc5
Auto merge of #5930 - ebroto:dev_newlint_fix_lt, r=matthiaskrgr
bors Aug 23, 2020
27ae4d3
Auto merge of #5948 - ebroto:5944_repeat_ice, r=Manishearth
bors Aug 23, 2020
b05077e
Apply suggestions from PR review
ebroto Aug 23, 2020
b2c2266
Fix FP for `redundant_closure_call`
giraffate Aug 18, 2020
9fe0ac3
Avoid period in lint message according to convention
giraffate Aug 24, 2020
ce8915c
typo
rail-rain Aug 24, 2020
3d820f7
Fix incorrect suggestion when `clone_on_ref_ptr` is triggered in macros
ThibsG Aug 24, 2020
680c681
Added a lint which corrects expressions like (a - b) < f32::EPSILON
1c3t3a Aug 24, 2020
e9964f2
stable_sort_primitive: print the type that is being sorted in the lin…
matthiaskrgr Aug 21, 2020
8d9a485
Auto merge of #5935 - matthiaskrgr:unstable_sort_ty_name, r=flip1995
bors Aug 24, 2020
48b4aea
Unbreak the clippy test
scottmcm Aug 24, 2020
64b53f3
Auto merge of #5920 - giraffate:fix_fp_for_redundant_closure_call, r=…
bors Aug 25, 2020
9102832
Fix incorrect comment
Aug 25, 2020
48d4736
Simplify fmt test by using the clippy dev alias
Aug 25, 2020
c7dc9c3
Fix intermittent build error
Aug 25, 2020
179df0b
Added F32::EPSILON and F64::EPSILON to paths.rs
1c3t3a Aug 25, 2020
acc6b6c
Fix typo
flip1995 Aug 25, 2020
5ef345a
Auto merge of #5960 - flip1995:rustup, r=flip1995
bors Aug 25, 2020
ba43a43
Auto merge of #5947 - ebroto:rustup_doc_improvements, r=flip1995
bors Aug 25, 2020
f901559
Auto merge of #5952 - 1c3t3a:1c3t3a-dev-5819, r=Manishearth
bors Aug 25, 2020
f326668
Auto merge of #5958 - mikerite:fix-fmt-20200825, r=flip1995
bors Aug 25, 2020
3b1e5d6
Re-enable len_zero for ranges now that `is_empty` is stable on them
scottmcm Aug 25, 2020
e191151
Auto merge of #5961 - scottmcm:master, r=Manishearth
bors Aug 25, 2020
370fc45
Update clippy_lints/src/methods/mod.rs
ThibsG Aug 25, 2020
ad7a03c
Auto merge of #5951 - ThibsG:FixMacroCloneOnRefPtr2076, r=ebroto
bors Aug 25, 2020
9d18c24
Fix typo
hkmatsumoto Aug 26, 2020
23db542
Auto merge of #5964 - matsujika:matsujika-patch-1, r=ebroto
bors Aug 26, 2020
9ef4479
Auto merge of #5949 - rail-rain:fix_fp_borrow_interior_mutable_const,…
bors Aug 26, 2020
894581b
Auto merge of #5946 - mikerite:fix-5729, r=flip1995
bors Aug 26, 2020
2d85314
Changed the location of the suggestion as well as the way the suggest…
1c3t3a Aug 26, 2020
64c4bb0
Auto merge of #5966 - 1c3t3a:1c3t3a-dev-5819-fix, r=Manishearth
bors Aug 26, 2020
edc05da
Fix the wrong use of `snippet_with_applicability`
rail-rain Aug 26, 2020
e45c59e
Auto merge of #5968 - rail-rain:fix_use_snippet_with_applicability, r…
bors Aug 26, 2020
91024f1
Add new lint to prevent usage of unwrap in fns that return result
yaahc Aug 26, 2020
dead45f
Auto merge of #5957 - xvschneider:AddUnwrapInsideResultLint, r=yaahc
bors Aug 26, 2020
04bff17
Fix FP in `to_string_in_display`
giraffate Aug 27, 2020
2a3ee5f
Fix FP in `new_ret_no_self`: trigger in trait def instead of impl block
ThibsG Jul 7, 2020
3cb75c2
Remove expansion restriction + fix doc and tests naming
ThibsG Aug 25, 2020
5046126
Merge logic of looking for `Self` type
ThibsG Aug 27, 2020
07c5e9e
Auto merge of #5971 - giraffate:fix_fp_in_to_string_in_display, r=ebroto
bors Aug 27, 2020
e8be047
Update clippy_lints/src/utils/mod.rs
ThibsG Aug 28, 2020
ffaadae
Update clippy_lints/src/utils/mod.rs
ThibsG Aug 28, 2020
73b1ee1
Update clippy_lints/src/methods/mod.rs
ThibsG Aug 28, 2020
3d0b0e6
Auto merge of #5774 - ThibsG:FixNewRetNoSelf, r=ebroto
bors Aug 28, 2020
adc7351
Merge commit '3d0b0e66afdfaa519d8855b338b35b4605775945' into clippyup
flip1995 Aug 28, 2020
575e27d
Update Cargo.lock
flip1995 Aug 28, 2020
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
8 changes: 4 additions & 4 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -518,15 +518,15 @@ dependencies = [
name = "clippy"
version = "0.0.212"
dependencies = [
"cargo_metadata 0.9.1",
"cargo_metadata 0.11.1",
"clippy-mini-macro-test",
"clippy_lints",
"compiletest_rs",
"derive-new",
"lazy_static",
"rustc-workspace-hack",
"rustc_tools_util 0.2.0",
"semver 0.9.0",
"semver 0.10.0",
"serde",
"tempfile",
"tester",
Expand All @@ -540,15 +540,15 @@ version = "0.2.0"
name = "clippy_lints"
version = "0.0.212"
dependencies = [
"cargo_metadata 0.9.1",
"cargo_metadata 0.11.1",
"if_chain",
"itertools 0.9.0",
"lazy_static",
"pulldown-cmark",
"quine-mc_cluskey",
"quote",
"regex-syntax",
"semver 0.9.0",
"semver 0.10.0",
"serde",
"smallvec 1.4.2",
"syn",
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/.cargo/config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[alias]
uitest = "test --test compile-test"
dev = "run --package clippy_dev --bin clippy_dev --manifest-path clippy_dev/Cargo.toml --"
dev = "run --target-dir clippy_dev/target --package clippy_dev --bin clippy_dev --manifest-path clippy_dev/Cargo.toml --"

[build]
rustflags = ["-Zunstable-options"]
7 changes: 7 additions & 0 deletions src/tools/clippy/.github/workflows/clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ jobs:
env:
OS: ${{ runner.os }}

- name: Test cargo dev new lint
run: |
cargo dev new_lint --name new_early_pass --pass early
cargo dev new_lint --name new_late_pass --pass late
cargo check
git reset --hard HEAD

# Cleanup
- name: Run cargo-cache --autoclean
run: |
Expand Down
6 changes: 6 additions & 0 deletions src/tools/clippy/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -1498,6 +1498,7 @@ Released 2018-09-13
[`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
[`float_equality_without_abs`]: https://rust-lang.github.io/rust-clippy/master/index.html#float_equality_without_abs
[`fn_address_comparisons`]: https://rust-lang.github.io/rust-clippy/master/index.html#fn_address_comparisons
[`fn_params_excessive_bools`]: https://rust-lang.github.io/rust-clippy/master/index.html#fn_params_excessive_bools
[`fn_to_numeric_cast`]: https://rust-lang.github.io/rust-clippy/master/index.html#fn_to_numeric_cast
Expand Down Expand Up @@ -1690,6 +1691,7 @@ Released 2018-09-13
[`same_functions_in_if_condition`]: https://rust-lang.github.io/rust-clippy/master/index.html#same_functions_in_if_condition
[`same_item_push`]: https://rust-lang.github.io/rust-clippy/master/index.html#same_item_push
[`search_is_some`]: https://rust-lang.github.io/rust-clippy/master/index.html#search_is_some
[`self_assignment`]: https://rust-lang.github.io/rust-clippy/master/index.html#self_assignment
[`serde_api_misuse`]: https://rust-lang.github.io/rust-clippy/master/index.html#serde_api_misuse
[`shadow_reuse`]: https://rust-lang.github.io/rust-clippy/master/index.html#shadow_reuse
[`shadow_same`]: https://rust-lang.github.io/rust-clippy/master/index.html#shadow_same
Expand All @@ -1699,6 +1701,7 @@ Released 2018-09-13
[`should_implement_trait`]: https://rust-lang.github.io/rust-clippy/master/index.html#should_implement_trait
[`similar_names`]: https://rust-lang.github.io/rust-clippy/master/index.html#similar_names
[`single_char_pattern`]: https://rust-lang.github.io/rust-clippy/master/index.html#single_char_pattern
[`single_char_push_str`]: https://rust-lang.github.io/rust-clippy/master/index.html#single_char_push_str
[`single_component_path_imports`]: https://rust-lang.github.io/rust-clippy/master/index.html#single_component_path_imports
[`single_match`]: https://rust-lang.github.io/rust-clippy/master/index.html#single_match
[`single_match_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#single_match_else
Expand All @@ -1723,6 +1726,7 @@ Released 2018-09-13
[`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
[`too_many_arguments`]: https://rust-lang.github.io/rust-clippy/master/index.html#too_many_arguments
[`too_many_lines`]: https://rust-lang.github.io/rust-clippy/master/index.html#too_many_lines
Expand Down Expand Up @@ -1752,6 +1756,7 @@ Released 2018-09-13
[`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_sort_by`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_sort_by
Expand All @@ -1773,6 +1778,7 @@ Released 2018-09-13
[`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
[`unwrap_in_result`]: https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_in_result
[`unwrap_used`]: https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_used
[`use_debug`]: https://rust-lang.github.io/rust-clippy/master/index.html#use_debug
[`use_self`]: https://rust-lang.github.io/rust-clippy/master/index.html#use_self
Expand Down
58 changes: 49 additions & 9 deletions src/tools/clippy/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,35 @@ Clippy in the `rust-lang/rust` repository.
For general information about `subtree`s in the Rust repository see [Rust's
`CONTRIBUTING.md`][subtree].

### Patching git-subtree to work with big repos

Currently there's a bug in `git-subtree` that prevents it from working properly
with the [`rust-lang/rust`] repo. There's an open PR to fix that, but it's stale.
Before continuing with the following steps, we need to manually apply that fix to
our local copy of `git-subtree`.

You can get the patched version of `git-subtree` from [here][gitgitgadget-pr].
Put this file under `/usr/lib/git-core` (taking a backup of the previous file)
and make sure it has the proper permissions:

```bash
sudo cp --backup /path/to/patched/git-subtree.sh /usr/lib/git-core/git-subtree
sudo chmod --reference=/usr/lib/git-core/git-subtree~ /usr/lib/git-core/git-subtree
sudo chown --reference=/usr/lib/git-core/git-subtree~ /usr/lib/git-core/git-subtree
```

_Note:_ The first time running `git subtree push` a cache has to be built. This
involves going through the complete Clippy history once. For this you have to
increase the stack limit though, which you can do with `ulimit -s 60000`.
Make sure to run the `ulimit` command from the same session you call git subtree.

_Note:_ If you are a Debian user, `dash` is the shell used by default for scripts instead of `sh`.
This shell has a hardcoded recursion limit set to 1000. In order to make this process work,
you need to force the script to run `bash` instead. You can do this by editing the first
line of the `git-subtree` script and changing `sh` to `bash`.

### Performing the sync

Here is a TL;DR version of the sync process (all of the following commands have
to be run inside the `rust` directory):

Expand All @@ -198,6 +227,7 @@ to be run inside the `rust` directory):
# Make sure to change `your-github-name` to your github name in the following command
git subtree push -P src/tools/clippy git@github.com:your-github-name/rust-clippy sync-from-rust
```

_Note:_ This will directly push to the remote repository. You can also push
to your local copy by replacing the remote address with `/path/to/rust-clippy`
directory.
Expand All @@ -213,14 +243,30 @@ to be run inside the `rust` directory):
3. Open a PR to `rust-lang/rust-clippy` and wait for it to get merged (to
accelerate the process ping the `@rust-lang/clippy` team in your PR and/or
~~annoy~~ ask them in the [Discord] channel.)
4. Sync the `rust-lang/rust-clippy` master to the rust-copy of Clippy:

### Syncing back changes in Clippy to [`rust-lang/rust`]

To avoid flooding the [`rust-lang/rust`] PR queue, changes in Clippy's repo are synced back
in a bi-weekly basis if there's no urgent changes. This is done starting on the day of
the Rust stable release and then every other week. That way we guarantee that
every feature in Clippy is available for 2 weeks in nightly, before it can get to beta.
For reference, the first sync following this cadence was performed the 2020-08-27.

All of the following commands have to be run inside the `rust` directory.

1. Make sure Clippy itself is up-to-date by following the steps outlined in the previous
section if necessary.

2. Sync the `rust-lang/rust-clippy` master to the rust-copy of Clippy:
```bash
git checkout -b sync-from-clippy
git subtree pull -P src/tools/clippy https://github.com/rust-lang/rust-clippy master
```
5. Open a PR to [`rust-lang/rust`]
3. Open a PR to [`rust-lang/rust`]

### Defining remotes

Also, you may want to define remotes, so you don't have to type out the remote
You may want to define remotes, so you don't have to type out the remote
addresses on every sync. You can do this with the following commands (these
commands still have to be run inside the `rust` directory):

Expand All @@ -241,12 +287,6 @@ You can then sync with the remote names from above, e.g.:
$ git subtree push -P src/tools/clippy clippy-local sync-from-rust
```

_Note:_ The first time running `git subtree push` a cache has to be built. This
involves going through the complete Clippy history once. For this you have to
increase the stack limit though, which you can do with `ulimit -s 60000`. For
this to work, you will need the fix of `git subtree` available
[here][gitgitgadget-pr].

[gitgitgadget-pr]: https://github.com/gitgitgadget/git/pull/493
[subtree]: https://rustc-dev-guide.rust-lang.org/contributing.html#external-dependencies-subtree
[`rust-lang/rust`]: https://github.com/rust-lang/rust
Expand Down
4 changes: 2 additions & 2 deletions src/tools/clippy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ path = "src/driver.rs"
# begin automatic update
clippy_lints = { version = "0.0.212", path = "clippy_lints" }
# end automatic update
semver = "0.9"
semver = "0.10"
rustc_tools_util = { version = "0.2.0", path = "rustc_tools_util"}
tempfile = { version = "3.1.0", optional = true }
lazy_static = "1.0"

[dev-dependencies]
cargo_metadata = "0.9.1"
cargo_metadata = "0.11.1"
compiletest_rs = { version = "0.5.0", features = ["tmp"] }
tester = "0.7"
lazy_static = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_dev/src/new_lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub fn create(pass: Option<&str>, lint_name: Option<&str>, category: Option<&str
fn create_lint(lint: &LintData) -> io::Result<()> {
let (pass_type, pass_lifetimes, pass_import, context_import) = match lint.pass {
"early" => ("EarlyLintPass", "", "use rustc_ast::ast::*;", "EarlyContext"),
"late" => ("LateLintPass", "<'_, '_>", "use rustc_hir::*;", "LateContext"),
"late" => ("LateLintPass", "<'_>", "use rustc_hir::*;", "LateContext"),
_ => {
unreachable!("`pass_type` should only ever be `early` or `late`!");
},
Expand Down
4 changes: 2 additions & 2 deletions src/tools/clippy/clippy_lints/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ keywords = ["clippy", "lint", "plugin"]
edition = "2018"

[dependencies]
cargo_metadata = "0.9.1"
cargo_metadata = "0.11.1"
if_chain = "1.0.0"
itertools = "0.9"
lazy_static = "1.0.2"
Expand All @@ -28,7 +28,7 @@ serde = { version = "1.0", features = ["derive"] }
smallvec = { version = "1", features = ["union"] }
toml = "0.5.3"
unicode-normalization = "0.1"
semver = "0.9.0"
semver = "0.10.0"
# NOTE: cargo requires serde feat in its url dep
# see <https://github.com/rust-lang/rust/pull/63587#issuecomment-522343864>
url = { version = "2.1.0", features = ["serde"] }
Expand Down
14 changes: 6 additions & 8 deletions src/tools/clippy/clippy_lints/src/assign_ops.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::utils::{
get_trait_def_id, implements_trait, snippet_opt, span_lint_and_then, trait_ref_of_method, SpanlessEq,
eq_expr_value, get_trait_def_id, implements_trait, snippet_opt, span_lint_and_then, trait_ref_of_method,
};
use crate::utils::{higher, sugg};
use if_chain::if_chain;
Expand Down Expand Up @@ -70,11 +70,11 @@ impl<'tcx> LateLintPass<'tcx> for AssignOps {
return;
}
// lhs op= l op r
if SpanlessEq::new(cx).ignore_fn().eq_expr(lhs, l) {
if eq_expr_value(cx, lhs, l) {
lint_misrefactored_assign_op(cx, expr, *op, rhs, lhs, r);
}
// lhs op= l commutative_op r
if is_commutative(op.node) && SpanlessEq::new(cx).ignore_fn().eq_expr(lhs, r) {
if is_commutative(op.node) && eq_expr_value(cx, lhs, r) {
lint_misrefactored_assign_op(cx, expr, *op, rhs, lhs, l);
}
}
Expand Down Expand Up @@ -161,14 +161,12 @@ impl<'tcx> LateLintPass<'tcx> for AssignOps {

if visitor.counter == 1 {
// a = a op b
if SpanlessEq::new(cx).ignore_fn().eq_expr(assignee, l) {
if eq_expr_value(cx, assignee, l) {
lint(assignee, r);
}
// a = b commutative_op a
// Limited to primitive type as these ops are know to be commutative
if SpanlessEq::new(cx).ignore_fn().eq_expr(assignee, r)
&& cx.typeck_results().expr_ty(assignee).is_primitive_ty()
{
if eq_expr_value(cx, assignee, r) && cx.typeck_results().expr_ty(assignee).is_primitive_ty() {
match op.node {
hir::BinOpKind::Add
| hir::BinOpKind::Mul
Expand Down Expand Up @@ -253,7 +251,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ExprVisitor<'a, 'tcx> {
type Map = Map<'tcx>;

fn visit_expr(&mut self, expr: &'tcx hir::Expr<'_>) {
if SpanlessEq::new(self.cx).ignore_fn().eq_expr(self.assignee, expr) {
if eq_expr_value(self.cx, self.assignee, expr) {
self.counter += 1;
}

Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use crate::utils::{
span_lint_and_sugg, span_lint_and_then, without_block_comments,
};
use if_chain::if_chain;
use rustc_ast::{AttrKind, AttrStyle, Attribute, Lit, LitKind, MetaItemKind, NestedMetaItem};
use rustc_ast::util::lev_distance::find_best_match_for_name;
use rustc_ast::{AttrKind, AttrStyle, Attribute, Lit, LitKind, MetaItemKind, NestedMetaItem};
use rustc_errors::Applicability;
use rustc_hir::{
Block, Expr, ExprKind, ImplItem, ImplItemKind, Item, ItemKind, StmtKind, TraitFn, TraitItem, TraitItemKind,
Expand Down
10 changes: 5 additions & 5 deletions src/tools/clippy/clippy_lints/src/booleans.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::utils::{
get_trait_def_id, implements_trait, in_macro, is_type_diagnostic_item, paths, snippet_opt, span_lint_and_sugg,
span_lint_and_then, SpanlessEq,
eq_expr_value, get_trait_def_id, implements_trait, in_macro, is_type_diagnostic_item, paths, snippet_opt,
span_lint_and_sugg, span_lint_and_then,
};
use if_chain::if_chain;
use rustc_ast::ast::LitKind;
Expand Down Expand Up @@ -128,7 +128,7 @@ impl<'a, 'tcx, 'v> Hir2Qmm<'a, 'tcx, 'v> {
}
}
for (n, expr) in self.terminals.iter().enumerate() {
if SpanlessEq::new(self.cx).ignore_fn().eq_expr(e, expr) {
if eq_expr_value(self.cx, e, expr) {
#[allow(clippy::cast_possible_truncation)]
return Ok(Bool::Term(n as u8));
}
Expand All @@ -138,8 +138,8 @@ impl<'a, 'tcx, 'v> Hir2Qmm<'a, 'tcx, 'v> {
if implements_ord(self.cx, e_lhs);
if let ExprKind::Binary(expr_binop, expr_lhs, expr_rhs) = &expr.kind;
if negate(e_binop.node) == Some(expr_binop.node);
if SpanlessEq::new(self.cx).ignore_fn().eq_expr(e_lhs, expr_lhs);
if SpanlessEq::new(self.cx).ignore_fn().eq_expr(e_rhs, expr_rhs);
if eq_expr_value(self.cx, e_lhs, expr_lhs);
if eq_expr_value(self.cx, e_rhs, expr_rhs);
then {
#[allow(clippy::cast_possible_truncation)]
return Ok(Bool::Not(Box::new(Bool::Term(n as u8))));
Expand Down
7 changes: 3 additions & 4 deletions src/tools/clippy/clippy_lints/src/copies.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::utils::{eq_expr_value, SpanlessEq, SpanlessHash};
use crate::utils::{get_parent_expr, higher, if_sequence, snippet, span_lint_and_note, span_lint_and_then};
use crate::utils::{SpanlessEq, SpanlessHash};
use rustc_data_structures::fx::FxHashMap;
use rustc_hir::{Arm, Block, Expr, ExprKind, MatchSource, Pat, PatKind};
use rustc_lint::{LateContext, LateLintPass};
Expand Down Expand Up @@ -197,8 +197,7 @@ fn lint_same_cond(cx: &LateContext<'_>, conds: &[&Expr<'_>]) {
h.finish()
};

let eq: &dyn Fn(&&Expr<'_>, &&Expr<'_>) -> bool =
&|&lhs, &rhs| -> bool { SpanlessEq::new(cx).ignore_fn().eq_expr(lhs, rhs) };
let eq: &dyn Fn(&&Expr<'_>, &&Expr<'_>) -> bool = &|&lhs, &rhs| -> bool { eq_expr_value(cx, lhs, rhs) };

for (i, j) in search_same(conds, hash, eq) {
span_lint_and_note(
Expand All @@ -222,7 +221,7 @@ fn lint_same_fns_in_if_cond(cx: &LateContext<'_>, conds: &[&Expr<'_>]) {

let eq: &dyn Fn(&&Expr<'_>, &&Expr<'_>) -> bool = &|&lhs, &rhs| -> bool {
// Do not spawn warning if `IFS_SAME_COND` already produced it.
if SpanlessEq::new(cx).ignore_fn().eq_expr(lhs, rhs) {
if eq_expr_value(cx, lhs, rhs) {
return false;
}
SpanlessEq::new(cx).eq_expr(lhs, rhs)
Expand Down
Loading