Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
149 commits
Select commit Hold shift + click to select a range
be81608
split `interior_mutable_const` tests and clean it
rail-rain Sep 30, 2020
f58a169
fix a FP in `interior_mutable_const`
rail-rain Sep 30, 2020
7c74d87
Fix vec_box scope error
camsteffen Oct 30, 2020
c0d1002
Fix unnecessary_lazy_eval suggestion applicability
camsteffen Oct 30, 2020
158bf9a
Fix incorrect suggestion for macro expansion in `deref_addrof` lint
ThibsG Oct 31, 2020
343bdb3
Give better suggestion by working on span on `deref_addrof` lint
ThibsG Nov 2, 2020
ce98468
Fix incorrect suggestion when from expansion in `try_err` lint
ThibsG Nov 2, 2020
a6611de
Include bindings as machine applicable
camsteffen Nov 2, 2020
89fa373
rustc_ast: Do not panic by default when visiting macro calls
petrochenkov Nov 3, 2020
c2a769f
rustc_ast: `visit_mac` -> `visit_mac_call`
petrochenkov Nov 3, 2020
a4acb31
Fix example for cargo common data
Urcra Nov 4, 2020
fd8dece
Readme improvements
camsteffen Nov 3, 2020
bc27d14
Add string_from_utf8_as_bytes linter
patrickelectric Oct 8, 2020
f83762b
Skip rustfmt as it is wanted for this test
ThibsG Nov 2, 2020
3424419
Merge commit 'b20d4c155d2fe3a8391f86dcf9a8c49e17188703' into clippyup
flip1995 Nov 5, 2020
83e75f9
Fix incorrect suggestion for `try_err` lint when `Err` arg is itself …
ThibsG Nov 5, 2020
1e4ce0f
Fix `await_holding_refcell_ref` examples for clarify
JohnTitor Nov 5, 2020
1624b00
Fix suggestion to add unneeded space in `manual_async`
giraffate Nov 5, 2020
5f57608
do not trigger map_clone in the case of &mut
alex-700 Nov 6, 2020
b7892c6
Refactor to make getting position just before RArrow a common function
giraffate Nov 6, 2020
8242b2f
Remove needless allow
ThibsG Oct 30, 2020
2ea08e1
Auto merge of #6294 - giraffate:fix_suggestion_to_add_space_in_manual…
bors Nov 6, 2020
5253595
FROM_ITER_INSTEAD_OF_COLLECT: avoid unwrapping unconditionally
matthiaskrgr Nov 6, 2020
4bbef42
Auto merge of #6272 - camsteffen:unnecesary-lazy-eval-type, r=llogiq
bors Nov 7, 2020
694cec1
Auto merge of #6110 - rail-rain:care_enums_non_copy_const, r=llogiq
bors Nov 7, 2020
92ba075
Auto merge of #6134 - patrickelectric:as_utf8, r=llogiq
bors Nov 7, 2020
4aca13f
Auto merge of #6287 - camsteffen:readme, r=llogiq
bors Nov 7, 2020
5effc99
Auto merge of #6298 - JohnTitor:fix-example, r=llogiq
bors Nov 7, 2020
c015622
Auto merge of #6304 - matthiaskrgr:crash_6302, r=llogiq
bors Nov 7, 2020
96d5f45
Auto merge of #6301 - alex-700:fix-map-clone, r=matthiaskrgr
bors Nov 8, 2020
c6a91df
Enable empty_loop lint for no_std crates
josephlr Oct 23, 2020
3579b7d
Update clippy_lints/src/loops.rs
josephlr Nov 4, 2020
00dee9d
Update reference files
flip1995 Nov 8, 2020
abfa331
Auto merge of #6205 - josephlr:empty-loop2, r=flip1995
bors Nov 8, 2020
f1f780c
Add let_underscore_drop
smoelius Nov 7, 2020
b1faa7f
Auto merge of #6271 - camsteffen:vec-box-import, r=flip1995
bors Nov 8, 2020
9c6a0b9
Update references
smoelius Nov 8, 2020
7079de9
Auto merge of #6293 - Urcra:lint-example-fix, r=flip1995
bors Nov 8, 2020
7c612c1
Force contributors/reviewers to set _some_ changelog entry
flip1995 Nov 8, 2020
040d0ca
Auto merge of #6288 - flip1995:changelog_internal, r=matthiaskrgr
bors Nov 8, 2020
b099406
Make KNOW_TYPES static
camsteffen Oct 29, 2020
9cab084
Fix or_fun_call for index operator
camsteffen Oct 29, 2020
2067a01
Auto merge of #6267 - camsteffen:or-fun-idx, r=flip1995
bors Nov 8, 2020
aa6bf1f
Update clippy_lints/src/let_underscore.rs
smoelius Nov 8, 2020
9751cba
Update clippy_lints/src/let_underscore.rs
smoelius Nov 8, 2020
8211b59
Update clippy_lints/src/let_underscore.rs
smoelius Nov 8, 2020
40d7af5
Update lints
smoelius Nov 8, 2020
8845f10
Do not collect tokens for doc comments
petrochenkov Nov 5, 2020
06e81bb
Update references
smoelius Nov 8, 2020
d212c38
Auto merge of #6278 - ThibsG:DerefAddrOf, r=llogiq
bors Nov 9, 2020
4852cca
Allow `let_underscore_drop` in `filter_methods` test
smoelius Nov 9, 2020
6294300
Rollup merge of #78710 - petrochenkov:macvisit, r=davidtwco
Dylan-DPC Nov 9, 2020
dd826b4
Auto merge of #6305 - smoelius:master, r=flip1995
bors Nov 9, 2020
3ea6f77
Merge remote-tracking branch 'upstream/master' into rustup
ebroto Nov 10, 2020
effcb52
Run cargo dev fmt
ebroto Nov 10, 2020
467bf95
Auto merge of #6319 - ebroto:rustup, r=ebroto
bors Nov 10, 2020
d0858d0
Auto merge of #6303 - ThibsG:OptionOptionSerde, r=ebroto
bors Nov 10, 2020
7690944
Fix map_clone with deref and clone
camsteffen Oct 30, 2020
c4fc076
Auto merge of #6269 - camsteffen:map-clone-deref, r=ebroto
bors Nov 11, 2020
a1cf2d3
Added a lint as suggested in 6010 which recommends using `contains()`
rsulli55 Oct 6, 2020
431fcbc
Moved the tests for lint `search_is_some` to new files
rsulli55 Oct 17, 2020
55dc822
Ran `tests/ui/update-all-references.sh" and `cargo dev fmt`
rsulli55 Oct 17, 2020
e9612f3
Remove `to_string` on msg
rsulli55 Oct 26, 2020
fb74b48
Remove borrow
rsulli55 Oct 26, 2020
ee1b959
Added period back to lint `search_is_some` and ran
rsulli55 Oct 31, 2020
fd30313
Cleaned up message and suggestion for `lint_search_is_some`
rsulli55 Nov 7, 2020
56d252c
Update clippy_lints/src/methods/mod.rs
rsulli55 Nov 11, 2020
5c1c50e
Change variable named `foo` and rerun `update-all-references`
rsulli55 Nov 11, 2020
f92f8d0
Fix typo in comment
eltociear Nov 11, 2020
5f310d9
Implement destructuring assignment for structs and slices
fanzier Nov 7, 2020
5f64867
Fix suggestion in `manual_range_contains` when using float
giraffate Nov 11, 2020
92ece84
Auto merge of #78782 - petrochenkov:nodoctok, r=Aaron1011
bors Nov 12, 2020
bd13a35
Auto merge of #6325 - flip1995:rustup, r=flip1995
bors Nov 12, 2020
3a648ff
Rollup merge of #78836 - fanzier:struct-and-slice-destructuring, r=pe…
m-ou-se Nov 12, 2020
c6b74df
Fix dogfood test
giraffate Nov 13, 2020
cf7b4b0
Auto merge of #6329 - giraffate:sync-from-rust, r=matthiaskrgr
bors Nov 13, 2020
7987f39
update clippy test ouput
vn-ki Nov 13, 2020
408b615
Auto merge of #6320 - giraffate:fix_suggestion_in_manual_range_contai…
bors Nov 14, 2020
864e554
Add underscore expressions for destructuring assignments
fanzier Nov 11, 2020
0c7a48c
Auto merge of #78809 - vn-ki:fix-issue-76064, r=oli-obk
bors Nov 14, 2020
cbb6b1c
Introduce `TypeVisitor::BreakTy`
LeSeulArtichaut Nov 5, 2020
1b55cc7
Set the default `BreakTy` to `!`
LeSeulArtichaut Nov 14, 2020
27a1572
Rollup merge of #79016 - fanzier:underscore-expressions, r=petrochenkov
jonas-schievink Nov 15, 2020
db04641
Auto merge of #6334 - flip1995:rustup, r=flip1995
bors Nov 15, 2020
0e80341
Add `rustfmt::skip` as a work around
giraffate Nov 16, 2020
df3bb58
Auto merge of #6336 - giraffate:sync-from-rust, r=flip1995
bors Nov 16, 2020
ad4f829
Auto merge of #6119 - rsulli55:find_is_some_on_strs, r=flip1995
bors Nov 16, 2020
3567ea5
clippy: fold by value
lcnr Oct 24, 2020
5b8f2b6
Remove `expect()` calls to avoid ICEs in `deref_addrof` lint
ThibsG Nov 16, 2020
a467c51
Auto merge of #78779 - LeSeulArtichaut:ty-visitor-return, r=oli-obk
bors Nov 17, 2020
a7ac441
Add new lint to detect unnecessarily wrapped value
hkmatsumoto Sep 19, 2020
750c118
Add suggestion on type signatures
hkmatsumoto Sep 20, 2020
0335b8d
Fix lint example
hkmatsumoto Sep 20, 2020
0e9d227
Add test cases
hkmatsumoto Sep 20, 2020
ebdd4e2
Refactor code according to reivews
hkmatsumoto Sep 22, 2020
6a62390
Optout rustfix test
hkmatsumoto Sep 22, 2020
3ed8902
Fix typo
hkmatsumoto Sep 22, 2020
c775856
Call `diag.multipart_suggestion` instead
hkmatsumoto Sep 22, 2020
a433d46
Run rustfmt
hkmatsumoto Sep 22, 2020
cdb72df
Split lint suggestion into two
hkmatsumoto Sep 26, 2020
6b55f3f
Add test case
hkmatsumoto Sep 26, 2020
df0d565
Move `find_all_ret_expressions` into `utils`
hkmatsumoto Oct 2, 2020
eec7f5c
Update clippy_lints/src/unnecessary_wrap.rs
hkmatsumoto Oct 12, 2020
1bdac87
Improve lint message
hkmatsumoto Oct 12, 2020
8392bc7
Run `cargo dev fmt`
hkmatsumoto Oct 12, 2020
2f85aa7
Make lint skip closures
hkmatsumoto Oct 18, 2020
12474c6
Add support for methods
hkmatsumoto Oct 18, 2020
c5447eb
Make lint skip macros
hkmatsumoto Oct 18, 2020
c7692cf
Skip function with no exprs contained
hkmatsumoto Oct 18, 2020
30632fb
Allow this lint on lint tests
hkmatsumoto Oct 18, 2020
e998d61
Downgrade applicability to MaybeIncorrect
hkmatsumoto Oct 18, 2020
9d96311
Remove wildcard use
hkmatsumoto Oct 18, 2020
532d205
Skip functions in PartialOrd
hkmatsumoto Oct 18, 2020
bf46f78
Fix clippy error
hkmatsumoto Oct 18, 2020
86331a4
Update stderr files
hkmatsumoto Nov 2, 2020
4c8d248
Update stderr files
hkmatsumoto Nov 14, 2020
4e5c02e
Ignore trait implementations
hkmatsumoto Nov 14, 2020
1f577c0
Fix embarrassing grammatical error
hkmatsumoto Nov 14, 2020
c7445d7
Pluralize lint name
hkmatsumoto Nov 17, 2020
bf2d31d
Run cargo dev fmt
flip1995 Nov 17, 2020
a8cafc6
Auto merge of #6338 - flip1995:rustup, r=flip1995
bors Nov 17, 2020
5464cbe
Auto merge of #6337 - ThibsG:FixIce6332, r=Manishearth
bors Nov 17, 2020
4e4c4fb
Fix handling of panic calls
camelid Nov 17, 2020
44d9445
Auto merge of #6070 - matsujika:unnecessary_wrap, r=flip1995
bors Nov 17, 2020
0502ac2
Improve doc about `map_clone`
giraffate Nov 17, 2020
8c2e2fd
Auto merge of #6340 - giraffate:improve_doc_for_map_clone, r=Manishearth
bors Nov 18, 2020
6494bd0
Revert "Add `rustfmt::skip` as a work around"
giraffate Nov 18, 2020
577ebc8
Rollup merge of #79145 - camelid:clippy-fix-panics, r=flip1995
m-ou-se Nov 18, 2020
b2aefb8
Auto merge of #6345 - giraffate:follow_up_of_rustup, r=flip1995
bors Nov 19, 2020
4bf58bd
Add CHANGELOG for 1.48
flip1995 Nov 19, 2020
a98acdb
Fix trailing whitespaces in CHANGELOG file
flip1995 Nov 19, 2020
e9afdf0
Improve changlog update documentation
flip1995 Nov 19, 2020
78faaef
Remove the clippy::panic-params lint.
m-ou-se Nov 19, 2020
113c147
Clippy: Match on assert!() expansions without an inner block.
m-ou-se Nov 19, 2020
dd4e471
Properly deprecate panic_params lint
flip1995 Nov 20, 2020
5ee0a40
Fix dogfood errors
flip1995 Nov 20, 2020
8325d48
Auto merge of #6351 - flip1995:rustup, r=flip1995
bors Nov 20, 2020
70ffebf
Auto merge of #6347 - flip1995:changelog, r=Manishearth
bors Nov 20, 2020
8b21241
Revert "Convert the await holding lints to correctness"
Nov 20, 2020
0402c6a
Auto merge of #6354 - Daniel-B-Smith:refcell_ref_await, r=flip1995
bors Nov 20, 2020
9b910e1
a typo
Nov 22, 2020
e30bb76
update
Nov 22, 2020
4284ec3
Auto merge of #6364 - o752d:master, r=flip1995
bors Nov 22, 2020
831aa96
Auto merge of #6363 - o752d:patch-2, r=flip1995
bors Nov 22, 2020
034244f
Small grammar, punctuation, and code style improvements to docs
carols10cents Nov 21, 2020
445466e
Apply suggestions from code review to change "that" to "which"
carols10cents Nov 22, 2020
3e7c6de
Auto merge of #6361 - integer32llc:doc-style, r=carols10cents
bors Nov 22, 2020
dfac9be
Merge commit '3e7c6dec244539970b593824334876f8b6ed0b18' into clippyup
flip1995 Nov 23, 2020
99b9459
Fix ICE in utils::implements_trait
flip1995 Nov 23, 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
Prev Previous commit
Next Next commit
Merge commit 'b20d4c155d2fe3a8391f86dcf9a8c49e17188703' into clippyup
  • Loading branch information
flip1995 committed Nov 5, 2020
commit 34244190d45d80bf66a0eec0d04f0254efd4c754
6 changes: 3 additions & 3 deletions .github/driver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ unset CARGO_MANIFEST_DIR
# FIXME: How to match the clippy invocation in compile-test.rs?
./target/debug/clippy-driver -Dwarnings -Aunused -Zui-testing --emit metadata --crate-type bin tests/ui/double_neg.rs 2>double_neg.stderr && exit 1
sed -e "s,tests/ui,\$DIR," -e "/= help/d" double_neg.stderr >normalized.stderr
diff normalized.stderr tests/ui/double_neg.stderr
diff -u normalized.stderr tests/ui/double_neg.stderr

# make sure "clippy-driver --rustc --arg" and "rustc --arg" behave the same
SYSROOT=$(rustc --print sysroot)
diff <(LD_LIBRARY_PATH=${SYSROOT}/lib ./target/debug/clippy-driver --rustc --version --verbose) <(rustc --version --verbose)
diff -u <(LD_LIBRARY_PATH=${SYSROOT}/lib ./target/debug/clippy-driver --rustc --version --verbose) <(rustc --version --verbose)

echo "fn main() {}" >target/driver_test.rs
# we can't run 2 rustcs on the same file at the same time
CLIPPY=$(LD_LIBRARY_PATH=${SYSROOT}/lib ./target/debug/clippy-driver ./target/driver_test.rs --rustc)
RUSTC=$(rustc ./target/driver_test.rs)
diff <($CLIPPY) <($RUSTC)
diff -u <($CLIPPY) <($RUSTC)

# TODO: CLIPPY_CONF_DIR / CARGO_MANIFEST_DIR
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Current beta, release 2020-11-19
* [`map_err_ignore`] [#5998](https://github.com/rust-lang/rust-clippy/pull/5998)
* [`rc_buffer`] [#6044](https://github.com/rust-lang/rust-clippy/pull/6044)
* [`to_string_in_display`] [#5831](https://github.com/rust-lang/rust-clippy/pull/5831)
* [`single_char_push_str`] [#5881](https://github.com/rust-lang/rust-clippy/pull/5881)
* `single_char_push_str` [#5881](https://github.com/rust-lang/rust-clippy/pull/5881)

### Moves and Deprecations

Expand Down Expand Up @@ -1665,6 +1665,7 @@ Released 2018-09-13
[`cognitive_complexity`]: https://rust-lang.github.io/rust-clippy/master/index.html#cognitive_complexity
[`collapsible_if`]: https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
[`comparison_chain`]: https://rust-lang.github.io/rust-clippy/master/index.html#comparison_chain
[`comparison_to_empty`]: https://rust-lang.github.io/rust-clippy/master/index.html#comparison_to_empty
[`copy_iterator`]: https://rust-lang.github.io/rust-clippy/master/index.html#copy_iterator
[`create_dir`]: https://rust-lang.github.io/rust-clippy/master/index.html#create_dir
[`crosspointer_transmute`]: https://rust-lang.github.io/rust-clippy/master/index.html#crosspointer_transmute
Expand Down Expand Up @@ -1713,6 +1714,7 @@ Released 2018-09-13
[`extend_from_slice`]: https://rust-lang.github.io/rust-clippy/master/index.html#extend_from_slice
[`extra_unused_lifetimes`]: https://rust-lang.github.io/rust-clippy/master/index.html#extra_unused_lifetimes
[`fallible_impl_from`]: https://rust-lang.github.io/rust-clippy/master/index.html#fallible_impl_from
[`field_reassign_with_default`]: https://rust-lang.github.io/rust-clippy/master/index.html#field_reassign_with_default
[`filetype_is_file`]: https://rust-lang.github.io/rust-clippy/master/index.html#filetype_is_file
[`filter_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#filter_map
[`filter_map_next`]: https://rust-lang.github.io/rust-clippy/master/index.html#filter_map_next
Expand All @@ -1731,6 +1733,7 @@ Released 2018-09-13
[`for_loops_over_fallibles`]: https://rust-lang.github.io/rust-clippy/master/index.html#for_loops_over_fallibles
[`forget_copy`]: https://rust-lang.github.io/rust-clippy/master/index.html#forget_copy
[`forget_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#forget_ref
[`from_iter_instead_of_collect`]: https://rust-lang.github.io/rust-clippy/master/index.html#from_iter_instead_of_collect
[`future_not_send`]: https://rust-lang.github.io/rust-clippy/master/index.html#future_not_send
[`get_last_with_len`]: https://rust-lang.github.io/rust-clippy/master/index.html#get_last_with_len
[`get_unwrap`]: https://rust-lang.github.io/rust-clippy/master/index.html#get_unwrap
Expand Down Expand Up @@ -1795,13 +1798,15 @@ Released 2018-09-13
[`manual_async_fn`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_async_fn
[`manual_memcpy`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_memcpy
[`manual_non_exhaustive`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_non_exhaustive
[`manual_ok_or`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_ok_or
[`manual_range_contains`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_range_contains
[`manual_saturating_arithmetic`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_saturating_arithmetic
[`manual_strip`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_strip
[`manual_swap`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_swap
[`manual_unwrap_or`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_unwrap_or
[`many_single_char_names`]: https://rust-lang.github.io/rust-clippy/master/index.html#many_single_char_names
[`map_clone`]: https://rust-lang.github.io/rust-clippy/master/index.html#map_clone
[`map_collect_result_unit`]: https://rust-lang.github.io/rust-clippy/master/index.html#map_collect_result_unit
[`map_entry`]: https://rust-lang.github.io/rust-clippy/master/index.html#map_entry
[`map_err_ignore`]: https://rust-lang.github.io/rust-clippy/master/index.html#map_err_ignore
[`map_flatten`]: https://rust-lang.github.io/rust-clippy/master/index.html#map_flatten
Expand Down Expand Up @@ -1917,6 +1922,7 @@ Released 2018-09-13
[`redundant_pub_crate`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_pub_crate
[`redundant_static_lifetimes`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_static_lifetimes
[`ref_in_deref`]: https://rust-lang.github.io/rust-clippy/master/index.html#ref_in_deref
[`ref_option_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#ref_option_ref
[`regex_macro`]: https://rust-lang.github.io/rust-clippy/master/index.html#regex_macro
[`repeat_once`]: https://rust-lang.github.io/rust-clippy/master/index.html#repeat_once
[`replace_consts`]: https://rust-lang.github.io/rust-clippy/master/index.html#replace_consts
Expand All @@ -1937,8 +1943,8 @@ Released 2018-09-13
[`should_assert_eq`]: https://rust-lang.github.io/rust-clippy/master/index.html#should_assert_eq
[`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_add_str`]: https://rust-lang.github.io/rust-clippy/master/index.html#single_char_add_str
[`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_element_loop`]: https://rust-lang.github.io/rust-clippy/master/index.html#single_element_loop
[`single_match`]: https://rust-lang.github.io/rust-clippy/master/index.html#single_match
Expand Down
7 changes: 4 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ To figure out how this syntax structure is encoded in the AST, it is recommended
Usually the lint will end up to be a nested series of matches and ifs, [like so][deep-nesting].
But we can make it nest-less by using [if_chain] macro, [like this][nest-less].

[`E-medium`] issues are generally pretty easy too, though it's recommended you work on an E-easy issue first.
They are mostly classified as [`E-medium`], since they might be somewhat involved code wise,
but not difficult per-se.
[`E-medium`] issues are generally pretty easy too, though it's recommended you work on an [`good first issue`]
first. Sometimes they are only somewhat involved code wise, but not difficult per-se.
Note that [`E-medium`] issues may require some knowledge of Clippy internals or some
debugging to find the actual problem behind the issue.

[`T-middle`] issues can be more involved and require verifying types. The [`ty`] module contains a
lot of methods that are useful, though one of the most useful would be `expr_ty` (gives the type of
Expand Down
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,18 +167,21 @@ You can add options to your code to `allow`/`warn`/`deny` Clippy lints:

* `allow`/`warn`/`deny` can be limited to a single function or module using `#[allow(...)]`, etc.

Note: `deny` produces errors instead of warnings.
Note: `allow` means to suppress the lint for your code. With `warn` the lint
will only emit a warning, while with `deny` the lint will emit an error, when
triggering for your code. An error causes clippy to exit with an error code, so
is useful in scripts like CI/CD.

If you do not want to include your lint levels in your code, you can globally enable/disable lints
by passing extra flags to Clippy during the run:
If you do not want to include your lint levels in your code, you can globally
enable/disable lints by passing extra flags to Clippy during the run:

To disable `lint_name`, run
To allow `lint_name`, run

```terminal
cargo clippy -- -A clippy::lint_name
```

And to enable `lint_name`, run
And to warn on `lint_name`, run

```terminal
cargo clippy -- -W clippy::lint_name
Expand All @@ -190,7 +193,7 @@ can run Clippy with warnings for all lints enabled:
cargo clippy -- -W clippy::pedantic
```

If you care only about a single lint, you can allow all others and then explicitly reenable
If you care only about a single lint, you can allow all others and then explicitly warn on
the lint(s) you are interested in:
```terminal
cargo clippy -- -A clippy::all -W clippy::useless_format -W clippy::...
Expand Down
11 changes: 10 additions & 1 deletion clippy_dev/src/ra_setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::path::PathBuf;
// code. See https://github.com/rust-analyzer/rust-analyzer/issues/3517 and https://github.com/rust-lang/rust-clippy/issues/5514 for details

pub fn run(rustc_path: Option<&str>) {
// we can unwrap here because the arg is required here
// we can unwrap here because the arg is required by clap
let rustc_path = PathBuf::from(rustc_path.unwrap());
assert!(rustc_path.is_dir(), "path is not a directory");
let rustc_source_basedir = rustc_path.join("compiler");
Expand Down Expand Up @@ -49,6 +49,15 @@ fn inject_deps_into_manifest(
cargo_toml: &str,
lib_rs: &str,
) -> std::io::Result<()> {
// do not inject deps if we have aleady done so
if cargo_toml.contains("[target.'cfg(NOT_A_PLATFORM)'.dependencies]") {
eprintln!(
"cargo dev ra-setup: warning: deps already found inside {}, doing nothing.",
manifest_path
);
return Ok(());
}

let extern_crates = lib_rs
.lines()
// get the deps
Expand Down
25 changes: 22 additions & 3 deletions clippy_lints/src/arithmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,28 @@ impl<'tcx> LateLintPass<'tcx> for Arithmetic {

let (l_ty, r_ty) = (cx.typeck_results().expr_ty(l), cx.typeck_results().expr_ty(r));
if l_ty.peel_refs().is_integral() && r_ty.peel_refs().is_integral() {
span_lint(cx, INTEGER_ARITHMETIC, expr.span, "integer arithmetic detected");
self.expr_span = Some(expr.span);
} else if l_ty.peel_refs().is_floating_point() && r_ty.peel_refs().is_floating_point() {
match op.node {
hir::BinOpKind::Div | hir::BinOpKind::Rem => match &r.kind {
hir::ExprKind::Lit(_lit) => (),
hir::ExprKind::Unary(hir::UnOp::UnNeg, expr) => {
if let hir::ExprKind::Lit(lit) = &expr.kind {
if let rustc_ast::ast::LitKind::Int(1, _) = lit.node {
span_lint(cx, INTEGER_ARITHMETIC, expr.span, "integer arithmetic detected");
self.expr_span = Some(expr.span);
}
}
},
_ => {
span_lint(cx, INTEGER_ARITHMETIC, expr.span, "integer arithmetic detected");
self.expr_span = Some(expr.span);
},
},
_ => {
span_lint(cx, INTEGER_ARITHMETIC, expr.span, "integer arithmetic detected");
self.expr_span = Some(expr.span);
},
}
} else if r_ty.peel_refs().is_floating_point() && r_ty.peel_refs().is_floating_point() {
span_lint(cx, FLOAT_ARITHMETIC, expr.span, "floating-point arithmetic detected");
self.expr_span = Some(expr.span);
}
Expand Down
22 changes: 11 additions & 11 deletions clippy_lints/src/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use rustc_middle::lint::in_external_macro;
use rustc_middle::ty;
use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_span::source_map::Span;
use rustc_span::sym;
use rustc_span::symbol::{Symbol, SymbolStr};
use semver::Version;

Expand Down Expand Up @@ -286,14 +287,14 @@ impl<'tcx> LateLintPass<'tcx> for Attributes {
},
_ => {},
}
if items.is_empty() || !attr.has_name(sym!(deprecated)) {
if items.is_empty() || !attr.has_name(sym::deprecated) {
return;
}
for item in items {
if_chain! {
if let NestedMetaItem::MetaItem(mi) = &item;
if let MetaItemKind::NameValue(lit) = &mi.kind;
if mi.has_name(sym!(since));
if mi.has_name(sym::since);
then {
check_semver(cx, item.span(), lit);
}
Expand All @@ -309,7 +310,7 @@ impl<'tcx> LateLintPass<'tcx> for Attributes {
}
match item.kind {
ItemKind::ExternCrate(..) | ItemKind::Use(..) => {
let skip_unused_imports = item.attrs.iter().any(|attr| attr.has_name(sym!(macro_use)));
let skip_unused_imports = item.attrs.iter().any(|attr| attr.has_name(sym::macro_use));

for attr in item.attrs {
if in_external_macro(cx.sess(), attr.span) {
Expand All @@ -326,7 +327,7 @@ impl<'tcx> LateLintPass<'tcx> for Attributes {
match item.kind {
ItemKind::Use(..) => {
if is_word(lint, sym!(unused_imports))
|| is_word(lint, sym!(deprecated))
|| is_word(lint, sym::deprecated)
|| is_word(lint, sym!(unreachable_pub))
|| is_word(lint, sym!(unused))
|| extract_clippy_lint(lint)
Expand Down Expand Up @@ -411,8 +412,7 @@ fn check_clippy_lint_names(cx: &LateContext<'_>, ident: &str, items: &[NestedMet
let lint_store = cx.lints();
for lint in items {
if let Some(lint_name) = extract_clippy_lint(lint) {
if let CheckLintNameResult::Tool(Err((None, _))) =
lint_store.check_lint_name(&lint_name, Some(sym!(clippy)))
if let CheckLintNameResult::Tool(Err((None, _))) = lint_store.check_lint_name(&lint_name, Some(sym::clippy))
{
span_lint_and_then(
cx,
Expand Down Expand Up @@ -529,10 +529,10 @@ fn check_attrs(cx: &LateContext<'_>, span: Span, name: Symbol, attrs: &[Attribut

for attr in attrs {
if let Some(values) = attr.meta_item_list() {
if values.len() != 1 || !attr.has_name(sym!(inline)) {
if values.len() != 1 || !attr.has_name(sym::inline) {
continue;
}
if is_word(&values[0], sym!(always)) {
if is_word(&values[0], sym::always) {
span_lint(
cx,
INLINE_ALWAYS,
Expand Down Expand Up @@ -623,12 +623,12 @@ fn check_empty_line_after_outer_attr(cx: &EarlyContext<'_>, item: &rustc_ast::It
fn check_deprecated_cfg_attr(cx: &EarlyContext<'_>, attr: &Attribute) {
if_chain! {
// check cfg_attr
if attr.has_name(sym!(cfg_attr));
if attr.has_name(sym::cfg_attr);
if let Some(items) = attr.meta_item_list();
if items.len() == 2;
// check for `rustfmt`
if let Some(feature_item) = items[0].meta_item();
if feature_item.has_name(sym!(rustfmt));
if feature_item.has_name(sym::rustfmt);
// check for `rustfmt_skip` and `rustfmt::skip`
if let Some(skip_item) = &items[1].meta_item();
if skip_item.has_name(sym!(rustfmt_skip)) ||
Expand Down Expand Up @@ -690,7 +690,7 @@ fn check_mismatched_target_os(cx: &EarlyContext<'_>, attr: &Attribute) {
}

if_chain! {
if attr.has_name(sym!(cfg));
if attr.has_name(sym::cfg);
if let Some(list) = attr.meta_item_list();
let mismatched = find_mismatched_target_os(&list);
if !mismatched.is_empty();
Expand Down
5 changes: 3 additions & 2 deletions clippy_lints/src/booleans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::hir::map::Map;
use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_span::source_map::Span;
use rustc_span::sym;

declare_clippy_lint! {
/// **What it does:** Checks for boolean expressions that can be written more
Expand Down Expand Up @@ -253,8 +254,8 @@ fn simplify_not(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option<String> {
},
ExprKind::MethodCall(path, _, args, _) if args.len() == 1 => {
let type_of_receiver = cx.typeck_results().expr_ty(&args[0]);
if !is_type_diagnostic_item(cx, type_of_receiver, sym!(option_type))
&& !is_type_diagnostic_item(cx, type_of_receiver, sym!(result_type))
if !is_type_diagnostic_item(cx, type_of_receiver, sym::option_type)
&& !is_type_diagnostic_item(cx, type_of_receiver, sym::result_type)
{
return None;
}
Expand Down
3 changes: 2 additions & 1 deletion clippy_lints/src/bytecount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use rustc_hir::{BinOpKind, BorrowKind, Expr, ExprKind, UnOp};
use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::ty;
use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_span::sym;
use rustc_span::Symbol;

declare_clippy_lint! {
Expand Down Expand Up @@ -68,7 +69,7 @@ impl<'tcx> LateLintPass<'tcx> for ByteCount {
let haystack = if let ExprKind::MethodCall(ref path, _, ref args, _) =
filter_args[0].kind {
let p = path.ident.name;
if (p == sym!(iter) || p == sym!(iter_mut)) && args.len() == 1 {
if (p == sym::iter || p == sym!(iter_mut)) && args.len() == 1 {
&args[0]
} else {
&filter_args[0]
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/cognitive_complexity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use rustc_lint::{LateContext, LateLintPass, LintContext};
use rustc_middle::hir::map::Map;
use rustc_session::{declare_tool_lint, impl_lint_pass};
use rustc_span::source_map::Span;
use rustc_span::BytePos;
use rustc_span::{sym, BytePos};

use crate::utils::{is_type_diagnostic_item, snippet_opt, span_lint_and_help, LimitStack};

Expand Down Expand Up @@ -61,7 +61,7 @@ impl CognitiveComplexity {
helper.visit_expr(expr);
let CCHelper { cc, returns } = helper;
let ret_ty = cx.typeck_results().node_type(expr.hir_id);
let ret_adjust = if is_type_diagnostic_item(cx, ret_ty, sym!(result_type)) {
let ret_adjust = if is_type_diagnostic_item(cx, ret_ty, sym::result_type) {
returns
} else {
#[allow(clippy::integer_division)]
Expand Down Expand Up @@ -123,7 +123,7 @@ impl<'tcx> LateLintPass<'tcx> for CognitiveComplexity {
hir_id: HirId,
) {
let def_id = cx.tcx.hir().local_def_id(hir_id);
if !cx.tcx.has_attr(def_id.to_def_id(), sym!(test)) {
if !cx.tcx.has_attr(def_id.to_def_id(), sym::test) {
self.check(cx, kind, decl, body, span);
}
}
Expand Down
Loading