Yuki Okushi
ff0a22d99f
Allow unused_self
lint at the function level
2020-01-18 21:05:42 +09:00
Andre Bogus
ff5fb19bbd
Downgrade range_plus_one to pedantic
2020-01-18 09:40:36 +01:00
Yuki Okushi
e72f0e61c6
Rustup to rust-lang/rust#68204
2020-01-18 14:39:18 +09:00
Brad Sherman
32337a9b58
Add lint for default lint description
...
- Lint for any new lints that have the default lint description
from the automation
2020-01-15 21:23:08 -06:00
bors
be09bb47db
Auto merge of #5034 - ThibsG:MatchWildErrArmImprove5024, r=flip1995
...
Match wild err arm improvements
This lint should trigger on other identifiers which have `_` prefix (such as `_e`) and only if they are unused in the panic block.
_Note_: the `is_unused` function is greatly inspired from `pat_is_wild` function in [loops lints](43ac9416d9/clippy_lints/src/loops.rs (L1689)
).
I've been considering doing some refactoring, maybe in utils. Maybe this PR or a new one. What do you think ?
fixes #5024
changelog: none
2020-01-15 21:17:21 +00:00
Andre Bogus
2797b64f7e
Omit doc safety/errors header checking for main
2020-01-14 18:20:56 +01:00
bors
c24a42289b
Auto merge of #4543 - xiongmao86:issue4503, r=flip1995
...
Fix issue4503
Fixes #4503 .
changelog: Add a lint checking user are using FileType.is_file() method and suggest using !FileType.is_dir().
- [x] Followed [lint naming conventions][lint_naming]
- [x] Added passing UI tests (including committed `.stderr` file)
- [x] `cargo test` passes locally
- [x] Executed `./util/dev update_lints`
- [x] Added lint documentation
- [x] Run `./util/dev fmt`
2020-01-13 22:09:39 +00:00
Yuki Okushi
73e525019d
Fix the ordering on nonminimal_bool
2020-01-14 07:08:45 +09:00
ThibsG
44fb8b5e88
Extract visitor to utils
2020-01-13 16:50:11 +01:00
ThibsG
d3c76b5b2a
Change note message
2020-01-13 16:25:35 +01:00
ThibsG
95cc500e9d
Fix formatting
2020-01-13 16:25:35 +01:00
ThibsG
e5c9073f9c
Better binding name on Err for note
2020-01-13 16:25:35 +01:00
ThibsG
f79c47f28d
Match underscore-prefixed variable also
2020-01-13 16:25:35 +01:00
Yuki Okushi
ce1c6b285d
Rustup to rust-lang/rust#68045
2020-01-13 21:55:57 +09:00
xiongmao86
2b477f361e
Update lints again.
2020-01-12 19:54:17 +08:00
xiongmao86
77c48ca341
Fix grammar error.
2020-01-12 19:54:17 +08:00
Rui
1018b78f41
Update clippy_lints/src/methods/mod.rs
...
Co-Authored-By: Philipp Krones <hello@philkrones.com>
2020-01-12 19:54:17 +08:00
xiongmao86
8d3cc6b8a9
Change lint message.
2020-01-12 19:54:17 +08:00
xiongmao86
2909bc372f
./util/dev update_lints.
2020-01-12 19:54:17 +08:00
Rui
a73822d3b9
Fix documents and messages.
...
Update clippy_lints/src/methods/mod.rs
2020-01-12 19:54:17 +08:00
xiongmao86
8d333a3cbb
Extend spans to include !.
2020-01-12 19:54:17 +08:00
xiongmao86
3c59eaf91c
Add lint logic.
2020-01-12 19:54:17 +08:00
xiongmao86
96334d0d7c
Declare lint.
2020-01-12 19:54:17 +08:00
Yuki Okushi
2f4b105863
Remove references
2020-01-12 05:20:18 +09:00
Yuki Okushi
8a3a0ea2ea
Rustup to rust-lang/rust#67000
2020-01-12 03:41:54 +09:00
Yuki Okushi
3bdf404076
Apply review comments
2020-01-11 23:21:09 +09:00
Yuki Okushi
39947992b5
Rustup to rust-lang/rust#67806
2020-01-11 21:50:00 +09:00
Yuki Okushi
10cf141ebb
Apply review comments
2020-01-11 19:39:43 +09:00
Yuki Okushi
8daa2784c7
Rustup to rust-lang/rust#68101
2020-01-11 09:06:09 +09:00
Yuki Okushi
1d7d4e9217
Rustup to rust-lang/rust#67258
2020-01-11 09:05:51 +09:00
Krishna Sai Veera Reddy
e2e40f2570
Detect usage of invalid atomic ordering in memory fences
...
Detect usage of `core::sync::atomic::{fence, compiler_fence}`
with `Ordering::Relaxed` and suggest valid alternatives.
2020-01-09 09:49:15 -08:00
Shotaro Yamada
b3971fdd5d
Lint vectored IO in unused_io_amount lint
2020-01-09 23:46:55 +09:00
bors
ac795a6f3a
Auto merge of #4960 - ThibsG:patterns_with_wildcard_#4640, r=flip1995
...
New lint: pats_with_wild_match_arm
Wildcard use with other pattern in same match arm.
The wildcard covers other(s) pattern(s) as it will match anyway.
changelog: add new lint when multiple patterns (including wildcard) are used in a match arm.
Fixes #4640 .
2020-01-09 13:51:00 +00:00
Yuki Okushi
e58cfac458
Rustup to rust-lang/rust#67979
2020-01-09 16:43:51 +09:00
Yuki Okushi
c24251b5fd
Rustup to rust-lang/rust#67781
2020-01-09 09:22:16 +09:00
bors
0da0ae3aa6
Auto merge of #5022 - flip1995:useless_attr, r=phansch
...
Fix useless_attribute suggestion
Fixes #5021
changelog: Fix [`useless_attribute`] suggestion, which tripped rustfix
2020-01-08 20:28:19 +00:00
flip1995
9ea17d42a7
Fix useless attribute suggestion
2020-01-08 17:47:01 +01:00
bors
52b9e704c6
Auto merge of #5017 - sinkuu:mir_no_opt_fallout, r=flip1995
...
Fix redundant_clone lint not working with PathBuf and OsString
https://github.com/rust-lang/rust-clippy/pull/4825 diabled MIR optimization in clippy, including `rustc_mir::transform::InstCombine` which reduces `&(*x)` to `x`. This PR tries to unwrap `&*` when looking into `mir::Rvalue`s.
Fixes #5014 .
---
changelog: fixed `redundant_clone` lint not working with `PathBuf` and `OsString`
2020-01-08 12:09:45 +00:00
bors
c789caa454
Auto merge of #5015 - krishna-veerareddy:change-float-to-int-transmute-category, r=flip1995
...
Move `transmute_float_to_int` lint to `complexity`
`transmute_float_to_int` lint was accidentally added to nursery so moving it to the complexity group.
changelog: Move `transmute_float_to_int` out of nursery
2020-01-08 08:42:46 +00:00
Yuki Okushi
787106c380
Normalize lint messages in cast_precision_loss
2020-01-08 16:36:02 +09:00
Yuki Okushi
fa33681d5c
Rustup to rust-lang/rust#67970
2020-01-08 15:42:54 +09:00
Shotaro Yamada
99eec3f54f
Fix redundant_clone
2020-01-08 14:18:00 +09:00
Krishna Sai Veera Reddy
b793cf09f2
Move transmute_float_to_int
lint to complexity
...
`transmute_float_to_int` lint was accidentally added to nursery
so moving it to the complexity group.
2020-01-07 15:53:19 -08:00
ThibsG
0fa0df9efb
Span help without suggestion
2020-01-07 19:10:59 +01:00
ThibsG
8ae8b08e32
Change lint name to WILDCARD_IN_OR_PATTERNS
2020-01-07 18:48:16 +01:00
ThibsG
58deaad42d
Handle case for non-exhaustive enums
2020-01-07 18:48:16 +01:00
ThibsG
d60c6f9398
Move to complexity and adapt test
...
- test wildcard_enum_match_arm has been impacted by this new lint
2020-01-07 18:48:16 +01:00
ThibsG
649af71f9e
Change group and use only func call
2020-01-07 18:48:16 +01:00
ThibsG
8ec32175fa
Remove useless parameters in func call
2020-01-07 18:48:16 +01:00
ThibsG
96c4198832
New lint: pats_with_wild_match_arm
...
- Wildcard use with other pattern in same match arm
2020-01-07 18:48:16 +01:00
Yuki Okushi
f7a93f029c
Apply suggestion from code review
2020-01-07 18:38:12 +09:00
Yuki Okushi
5ac08b0cc9
Normalize lint messages
2020-01-07 18:26:55 +09:00
bors
cdd134764a
Auto merge of #5010 - lzutao:recurse-remove_blocks, r=phansch
...
Make utils::remove_blocks non-recursive
changelog: none
2020-01-07 07:46:00 +00:00
Lzu Tao
3801d216e2
Make utils::remove_blocks non-recursive
2020-01-07 10:50:35 +07:00
Krishna Sai Veera Reddy
fe21ef4e8b
Prevent doc-tests from running and fix lint description
2020-01-06 17:33:28 -08:00
Krishna Sai Veera Reddy
9e6a6069a7
Add lint to detect usage of invalid atomic ordering
...
Detect usage of invalid atomic ordering modes such as
`Ordering::{Release, AcqRel}` in atomic loads and
`Ordering::{Acquire, AcqRel}` in atomic stores.
2020-01-06 16:39:31 -08:00
Yuki Okushi
2213989a01
Do not trigger let_and_return
lint on macros
2020-01-07 05:26:20 +09:00
Yuki Okushi
2f2eaf8b7e
Rustup to rust-lang/rust#67886
2020-01-07 01:46:33 +09:00
bors
732825dcff
Auto merge of #4996 - JohnTitor:rustup, r=matthiaskrgr
...
Rustup to rust-lang/rust#67803 and rust-lang/rust#67137
changelog: none
2020-01-05 08:41:37 +00:00
Yuki Okushi
17cfc77bd6
Rustup to rust-lang/rust#67137
2020-01-05 15:50:06 +09:00
Yuki Okushi
07f061563d
Rustup to rust-lang/rust#67803
2020-01-05 15:50:06 +09:00
Andre Bogus
539cd25262
External macro check for missing_*_doc
2020-01-04 20:19:14 +01:00
Brad Sherman
ab5ff0352e
Add lint for iter.nth(0)
...
- Encourage iter.next() rather than iter.nth(0), which is less readable
2020-01-04 11:20:11 -06:00
Brad Sherman
8ef53bf196
Fix existing iter-nth-zero violations
2020-01-04 09:00:54 -06:00
Philipp Hansch
c5178e82b4
Rustup to https://github.com/rust-lang/rust/pull/67853
...
Specifically caused by https://github.com/rust-lang/rust/pull/67786
2020-01-04 11:30:03 +01:00
bors
fa9b85d4df
Auto merge of #4881 - krishna-veerareddy:issue-4871-use-mem-take, r=flip1995
...
Use `mem::take` instead of `mem::replace` when applicable
`std::mem::take` can be used to replace a value of type `T` with `T::default()` instead of `std::mem::replace`.
Fixes issue #4871
changelog: Added lint for [`mem_replace_with_default`]
2020-01-04 08:09:43 +00:00
Yuki Okushi
1102b87e3a
Remove use of try!
from documentation
2020-01-04 13:47:01 +09:00
Andre Bogus
47972cdf12
No #[no_mangle] must_use_candidate functions
2020-01-03 17:21:36 +01:00
bors
2e8c3c3e9e
Auto merge of #4975 - JohnTitor:fix-4968, r=phansch
...
Fix ICE on `unsound_collection_transmute`
Fixes #4968
Check if `Ty`s are normalizable. It might show hidden false negative, I'm not sure.
Also, the regression tests are placed on two dirs, so move them to `/crashes`. I think it will be easier to find the right place.
changelog: Fix ICE on `unsound_collection_transmute`
2020-01-03 08:48:05 +00:00
bors
304edf39c3
Auto merge of #4978 - mikerite:fix-4958, r=phansch
...
Fix bad `explicit_into_iter_loop` suggestion
Fixes #4958
changelog: Fix bad `explicit_into_iter_loop` suggestion
2020-01-03 05:59:19 +00:00
Yuki Okushi
bf67fcf5a9
Move is_normalizable
into utils
2020-01-02 11:48:06 +09:00
Michael Wright
ea829bd8c6
Fix bad explicit_into_iter_loop
suggestion
...
Fixes #4958
2020-01-01 07:09:09 +02:00
Krishna Veera Reddy
84a60c3186
Prevent replace_consts
lint within match patterns
...
Currently `replace_consts` lint applies within match patterns but
the suggestion is incorrect as function calls are disallowed in
them. To fix this we prevent the lint from firing within patterns.
2019-12-31 10:33:15 -08:00
Krishna Veera Reddy
42e4595d3a
Indicate anonymous lifetimes for types
2019-12-31 09:22:35 -08:00
Krishna Veera Reddy
c09e79e226
Lint within internal macros without a suggestion
2019-12-31 09:22:35 -08:00
Krishna Veera Reddy
aa66f760c3
Destructure mem:replace
arguments
2019-12-31 09:22:35 -08:00
Krishna Veera Reddy
78b4dfc57c
Move mem_replace_with_default
out of nursery
2019-12-31 09:22:34 -08:00
Krishna Veera Reddy
26812f733d
Prevent mem_replace_with_default
lint within macros
...
Also added test cases for internal and external macros.
2019-12-31 09:22:34 -08:00
Krishna Veera Reddy
8db319f957
Use mem::take
instead of mem::replace
when applicable
...
`std::mem::take` can be used to replace a value of type `T`
with `T::default()` instead of `std::mem::replace`.
2019-12-31 09:22:34 -08:00
Yuki Okushi
f922812541
Fix ICE due to normalization failure
2019-12-31 20:55:11 +09:00
Yuki Okushi
bf08998b5c
Use is_empty()
2019-12-31 16:50:43 +09:00
Yuki Okushi
9086b17e14
Rustup to rust-lang/rust#67707
2019-12-31 09:17:56 +09:00
bors
3036b0e6d5
Auto merge of #4970 - krishna-veerareddy:fix-replace-consts-documentation, r=flip1995
...
Fix `replace_consts` lint documentation
`replace_consts` lint no longer lints for the usage of
`ATOMIC_{SIZE}_INIT` and `ONCE_INIT` so removing any
occurences of them in the documentation.
changelog: Update `replace_consts` lint documentation
2019-12-30 17:28:57 +00:00
bors
cecaca3382
Auto merge of #4634 - m-ober:feature/2320-map-or, r=llogiq
...
Add real suggestion to option_map_unwrap_or
changelog: Add real suggestion to `option_map_unwrap_or`
Fixes #2320
2019-12-30 15:50:06 +00:00
Krishna Veera Reddy
f533b98121
Fix replace_consts
lint documentation
...
`replace_consts` lint no longer lints for the usage of
`ATOMIC_{SIZE}_INIT` and `ONCE_INIT` so removing any
occurences of them in the documentation.
2019-12-30 05:55:22 -08:00
Yuki Okushi
a4c201e6b4
Rustup to rust-lang/rust#66942
2019-12-30 13:02:10 +09:00
Yuki Okushi
cf76eb48de
Rustup to rust-lang/rust#67151
2019-12-29 12:39:46 +09:00
Micha Ober
c5046fdce5
Add real suggestion to option_map_unwrap_or
2019-12-28 23:24:45 +01:00
bors
6bf87d5bbf
Auto merge of #4964 - JohnTitor:fix-potential-ice, r=flip1995
...
Possibly fix an ICE on test
Fix a potential ICE on test with debug assertion, caused on rust-lang/rust#67661 .
r? @oli-obk
changelog: none
2019-12-28 18:41:38 +00:00
mgr-inz-rafal
a208906afb
Fixes for elided lifetimes
2019-12-28 17:14:19 +01:00
mgr-inz-rafal
f191e916bd
Add new lint (modulo_arithmetic)
2019-12-28 16:46:08 +01:00
Yuki Okushi
bca125935c
code review
2019-12-28 22:45:41 +09:00
Yuki Okushi
fbdb13cfb0
Possibly fix an ICE on test
2019-12-28 22:30:44 +09:00
Yuki Okushi
5962fffcfe
Suggest similar lint name on unknown_clippy_lints
2019-12-27 22:07:55 +09:00
Yuki Okushi
e2636729ec
Rustup to rust-lang/rust#66936
2019-12-27 16:13:53 +09:00
bors
b0c4744d57
Auto merge of #4956 - JohnTitor:decimal-lit-suffix, r=llogiq
...
Do not drop suffixes on `decimal_literal_representation`
Fixes #4763
changelog: Do not drop type suffixes on `decimal_literal_representation`
2019-12-25 19:39:13 +00:00
Yuki Okushi
b68e65b4da
Do not drop suffixes on decimal_literal_representation
2019-12-26 01:22:36 +09:00
Yuki Okushi
ad936389e1
Correct documentation for len_zero
2019-12-25 21:06:55 +09:00
bors
a68ef55dbf
Auto merge of #4947 - rust-lang:doc-main-extern-crate, r=flip1995
...
Avoid needless_doctest_main on 'extern crate'
This fixes #4927 .
r? @flip1995
changelog: none
2019-12-24 15:03:54 +00:00
bors
1837cbce6c
Auto merge of #4885 - rust-lang:mut-key-types, r=flip1995
...
new lint: mutable_key_type
This fixes #732 - well, partly, it doesn't adress `Hash` impls, but the use of mutable types as map keys or set members
changelog: add `mutable_key_type` lint
r? @flip1995
2019-12-24 13:32:45 +00:00
Andre Bogus
40435acf3d
new lint: mutable_key_type
2019-12-24 13:46:19 +01:00
Andre Bogus
129d0cd0f4
Avoid needless_doctest_main on 'extern crate'
2019-12-24 13:42:37 +01:00
Lzu Tao
652666b288
rustup "Add span information to ExprKind::Assign
"
2019-12-24 11:25:24 +07:00
Lzu Tao
f5b896451a
do minor cleanups
...
* ToString and AsRef are in prelude, no need to import them
2019-12-24 03:06:52 +07:00
bors
37b7970a7c
Auto merge of #4934 - illicitonion:exhaustive_match, r=flip1995
...
Update wildcard enum match lint for non_exhaustive enums
changelog: wildcard_enum_match_arm gives better suggestions for non_exhaustive enums
2019-12-23 17:00:38 +00:00
bors
b38b026a98
Auto merge of #4823 - Areredify:must_use_res, r=flip1995
...
Add `let_underscore_must_use` lint
changelog: closes #4812 , added a new `let_underscore_must_use` lint, moved `is_must_use_ty` to utils, added `is_must_use_fn` util function
2019-12-23 06:16:37 +00:00
bors
40881e7713
Auto merge of #4941 - lzutao:utils-mod, r=phansch
...
a few small cleanups
changelog: none
2019-12-23 06:00:54 +00:00
Yuki Okushi
d5316163b6
Rustup to rust-lang/rust#66877
2019-12-23 09:07:46 +09:00
Lzu Tao
185e608ae2
a few small cleanups
2019-12-23 05:28:23 +07:00
Mikhail Babenko
a310cb2d0b
implemented let_underscore
lint
...
actually add files
update lints
change to pedantic
2019-12-22 22:10:25 +03:00
Mikhail Babenko
8b4a3b74e9
move is_must_use_ty to utils
2019-12-22 22:06:48 +03:00
flip1995
f6a5b608ef
Rustup to rust-lang/rust#66931
2019-12-22 15:56:34 +01:00
flip1995
9632e27487
Add <'_> where necessary
2019-12-22 15:42:41 +01:00
Daniel Wagner-Hall
4f4444c429
Remove trailling .s
2019-12-22 11:51:39 +00:00
bors
8723eb6035
Auto merge of #4937 - mikerite:fix-4824, r=phansch
...
Fix `map_clone` false positive
Don't lint when the item type is not a reference. `copied` only applies to references.
changelog: Fix `map_clone` false positive
2019-12-22 09:55:50 +00:00
bors
19dbb22032
Auto merge of #4930 - flip1995:unused_label, r=phansch
...
Deprecate unused_label lint
This lint was uplifted/turned into warn-by-default in rustc
Fixes #4925
changelog: Deprecate [`unused_label`] lint
2019-12-22 09:39:32 +00:00
Michael Wright
b15b977d76
Fix map_clone
false positive
...
Don't lint when the item type is not a reference. `copied` only applies
to references.
2019-12-22 11:26:51 +02:00
Daniel Wagner-Hall
c21b4ad7d4
Update wildcard enum match lint for non_exhaustive enums
2019-12-22 02:13:39 +00:00
Krishna Veera Reddy
91a491e68e
Reduce cognitive complexity lint span
...
Currently the cognitive complexity lint spans the entire function
body making it really difficult to read and refactor the code in
editors. To fix this we reduce the lint span to the function name.
2019-12-21 18:07:53 -08:00
Lzu Tao
d1ca5f1d7c
rustup "Merge ast::Mutability
and mir::Mutability
"
2019-12-21 18:38:45 +00:00
flip1995
710c749bb1
Deprecate unused_label lint
...
This lint was uplifted/turned into warn-by-default in rustc
2019-12-21 16:20:30 +01:00
Matthias Krüger
e5a5b0a077
rustup https://github.com/rust-lang/rust/pull/67455
2019-12-20 21:19:46 +01:00
bors
b4ad56e5c4
Auto merge of #4920 - lily-commure:fix-unnecessary-filter-map-docs, r=phansch
...
Fix documentation example for unnecessary_filter_map.
Fixes #4919 .
changelog: none
2019-12-20 07:27:24 +00:00
bors
a86463c99f
Auto merge of #4913 - mikerite:step-by-zero-20191218, r=phansch
...
Move `iterator_step_by_zero` and correct the documentation
Move `iterator_step_by_zero` and correct the documentation.
changelog: Corrected `iterator_step_by_zero` documentation
2019-12-20 07:10:11 +00:00
Emma
5a6b00ce50
Fix 'redudant' spelling in redundant_clone docs
...
The word 'redundant' is spelled incorrectly in the **What it does** section of the redundant_clone documentation.
2019-12-20 01:07:42 +01:00
Lily Chung
6e8c2bf8e6
Fix documentation example for unnecessary_filter_map.
2019-12-19 15:48:17 -08:00
bors
584f95fc54
Auto merge of #4915 - mikerite:fix-4912-2, r=phansch
...
Fix `expect_fun_call` false negative on references
Closes #4912
changelog: Fix `expect_fun_call` false negative on references
2019-12-19 09:44:14 +00:00
Michael Wright
1559f8bf34
Fix expect_fun_call
false negative on references
...
Closes #4912
2019-12-19 06:57:56 +02:00
mikerite
710e06dd29
Fix iterator_step_by_zero
description in declaration
...
Co-Authored-By: Phil Hansch <dev@phansch.net>
2019-12-19 06:51:26 +02:00
Michael Wright
38d0b2199a
Correct iterator_step_by_zero
documentation
2019-12-18 18:59:59 +02:00
Michael Wright
e097fca4df
Update iterator_step_by_zero
...
Move `iterator_step_by_zero` into `methods` since it applies to all
iterators and not just ranges. Simplify the code while doing so.
2019-12-18 18:59:43 +02:00
Krishna Veera Reddy
460d5a3b5a
Prevent cmp_nan
when inside constants
...
`std::{f32,f64}::is_nan` isn't a const fn so prevent `cmp_nan`
lint from running within constant comparisons.
2019-12-17 19:18:42 -08:00
Krishna Veera Reddy
eb0408ea65
Detect comparisons with NAN constants
...
Currently `cmp_nan` lint doesn't detect comparisons with NaN's
if the operands are consts variables so to fix this we evaluate
the const variables first before testing for NaN.
2019-12-17 18:51:30 -08:00
Krishna Veera Reddy
728a2418cb
Fix clippy build failure
...
Clippy build fails because the feature `result_map_or` has been
stabilized in v1.41.0 but we still have an explicit feature
attribute for it.
2019-12-16 22:29:05 -08:00
bors
d82debbd01
Auto merge of #4883 - krishna-veerareddy:issue-4818-cast-sign-loss-false-positive, r=flip1995
...
Fix false positive with cast_sign_loss lint
`cast_sign_loss` lint incorrectly suggests that the result of `checked_abs`, `rem_euclid` and `checked_rem_euclid` cannot be casted to an unsigned integer without loss.
Fixes #4818 #4764 #4743
changelog: Fix false positives in `cast_sign_loss` lint
2019-12-12 00:34:59 +00:00
bors
221bf650f6
Auto merge of #4886 - rust-lang:must-use-pub-only, r=phansch
...
Lint only exported must_use_candidates
As promised on #4779 , here's the check for publicly visible items for `must_use_candidate`
changelog: none
2019-12-11 12:01:10 +00:00
Krishna Veera Reddy
c77fc06d52
Add lint to detect transmutes from float to integer
...
Add lint that detects transmutation from a float to an integer
and suggests usage of `{f32, f64}.to_bits()` instead.
2019-12-07 16:33:49 -08:00
Andre Bogus
a60177cc1e
Lint only exported must_use_candidates
2019-12-06 20:10:14 +01:00
RobbieClarken
f5d0a452ba
Add lint for pub fns returning a Result
without documenting errors
...
The Rust Book recommends that functions that return a `Result` type have
a doc comment with an `# Errors` section describing the kind of errors
that can be returned
(https://doc.rust-lang.org/book/ch14-02-publishing-to-crates-io.html#commonly-used-sections ).
This change adds a lint to enforce this. The lint is allow by default;
it can be enabled with `#![warn(clippy::missing_errors_doc)]`.
Closes #4854 .
2019-12-06 17:19:05 +10:30
Krishna Veera Reddy
7002a9ee83
Fix false positive with cast_sign_loss lint
...
`cast_sign_loss` lint incorrectly suggests that the result of
`checked_abs`, `rem_euclid` and `checked_rem_euclid` cannot
be casted to an unsigned integer without loss.
2019-12-05 15:47:15 -08:00
daxpedda
946961d19e
Change to only detect in external macros.
2019-12-05 11:06:13 +01:00
daxpedda
d11b958faf
Fix false positive in string_add
.
2019-12-04 21:51:02 +01:00
Matthias Krüger
98e433d70d
Rustup to rust-lang/rust#66878
2019-12-04 01:34:01 +01:00
bors
c66cca44c8
Auto merge of #4877 - flip1995:manual_swap_4853, r=llogiq
...
Fix FP in manual_swap lint with slice-like types
Fixes #4853
changelog: Fix FP in [`manual_swap`] lint with slice-like types and make it auto applicable
2019-12-03 18:36:19 +00:00
flip1995
c56f72da35
Make OP_REF lint suggestion MaybeIncorrect
...
cc #2597
2019-12-03 18:37:07 +01:00
Christopher Durham
718558064d
Fire clippy::op_ref on PartialOrd but !Ord types
2019-12-03 18:37:07 +01:00
flip1995
f6a75f17f6
Rustup to rust-lang/rust#66935
2019-12-03 18:37:06 +01:00
flip1995
aa2381d9d0
Fix rustdoc examples
2019-12-03 16:29:05 +01:00
flip1995
1e3b24de43
Make manual_swap autofixable
2019-12-03 13:42:05 +01:00
flip1995
bd39a608a8
Formatting
2019-12-03 13:25:41 +01:00
flip1995
d1d5f790f5
Fix FP in manual_swap lint with slice-like types
2019-12-03 13:25:41 +01:00
flip1995
286b39d2e5
Rustup to rust-lang/rust#64736
2019-12-02 20:39:40 +01:00
Philipp Hansch
474e9a131d
Use assert_crate_local for a more explicit error
...
`assert_crate_local` does the same as the previous `if let` but with a
more explicit error message if it's not a `ClearCrossCrate::Set`.
2019-12-02 12:09:38 +01:00
Philipp Hansch
6669c2c6ce
Rustup to https://github.com/rust-lang/rust/pull/66789
2019-12-02 09:51:35 +01:00
bors
45196cee02
Auto merge of #4690 - lzutao:fix-test-on-non-amd64, r=flip1995
...
generate stderr file on 32bit pointer system
changelog: none
2019-12-01 18:39:21 +00:00
Lzu Tao
5488672d1f
account for external macro in MISSING_INLINE_IN_PUBLIC_ITEMS lint
2019-12-01 19:38:01 +07:00
Lzu Tao
142b289a51
chore: fix and split some ui tests on 32bit system
2019-12-01 19:07:02 +07:00
Andre Bogus
ef7587d957
Less needless_doctest_main false positives
...
This checks if a) the `fn main() {}` function is empty or if the doctest contains a `static`. In both cases don't lint.
2019-11-29 21:47:26 +01:00
Philipp Hansch
c1ccba005f
fmt
2019-11-29 20:47:50 +01:00
Philipp Hansch
ad6d8a4700
Make triggering this lint less likely 📎
2019-11-29 20:47:50 +01:00
Philipp Hansch
676f14baa0
Add custom ICE message that points to Clippy repo
...
This utilizes https://github.com/rust-lang/rust/pull/60584 by setting
our own `panic_hook` and pointing to our own issue tracker instead of
the rustc issue tracker.
This also adds a new internal lint to test the ICE message.
**Potential downsides**
* This essentially copies rustc's `report_ice` function as
`report_clippy_ice`. I think that's how it's meant to be implemented, but
maybe @jonas-schievink could have a look as well =)
The downside of more-or-less copying this function is that we have to
maintain it as well now.
The original function can be found [here][original].
* `driver` now depends directly on `rustc` and `rustc_errors`
Closes #2734
[original]: 59367b074f/src/librustc_driver/lib.rs (L1185)
2019-11-29 20:47:47 +01:00
bors
04036877ef
Auto merge of #4863 - phansch:use_self, r=flip1995
...
Move use_self to nursery
Closes #4859
We have a lot of false positives in this lint, so I think it makes sense
to move this to the nursery until they are resolved.
changelog: Move `use_self` lint to nursery, due to many false positives
2019-11-29 18:17:41 +00:00
flip1995
fd7eca2baf
Run update_lints
2019-11-29 14:50:19 +01:00
flip1995
604e6ba0e2
Add projections check to EUV for escape analysis
2019-11-29 12:57:10 +01:00
flip1995
b2523afae4
Use infer_ctxt
2019-11-29 11:12:19 +01:00
Philipp Hansch
70a2a29453
Move use_self to nursery
...
Closes #4859
We have a lot of false positives in this lint, so I think it makes sense
to move this to the nursery until they are resolved.
changelog: Move `use_self` lint to nursery, due to many false positives
2019-11-29 07:51:49 +01:00
Manish Goregaokar
45842e5131
Fix categorizations
2019-11-28 07:33:12 -08:00
Manish Goregaokar
c1c5c3522d
Fix arguments on ExprUseVisitor::new
2019-11-28 07:20:37 -08:00
Manish Goregaokar
dc9d839410
euv moved from middle to typeck
2019-11-28 07:17:56 -08:00
Manish Goregaokar
85bb66480c
cmt_ -> Place
2019-11-28 07:09:02 -08:00
bors
b5a6714155
Auto merge of #4849 - flip1995:deny_warnings, r=phansch
...
Deny warnings in CI
Removes the `debugging` feature, that wasn't used anymore and adds/enables the `deny-warnings` feature for every sub-crate of Clippy.
changelog: none
2019-11-28 10:27:46 +00:00
bors
dbdd75ab52
Auto merge of #4855 - phansch:rollup-x7yail7, r=phansch
...
Rollup of 3 pull requests
Successful merges:
- #4832 (Add some positive examples to lint docs)
- #4842 ([comparison_chain] #4827 Check `core::cmp::Ord` is implemented)
- #4847 (fixing a typo)
Failed merges:
changelog: none
r? @ghost
2019-11-28 09:30:16 +00:00
Phil Hansch
a05f3cb9a1
Rollup merge of #4847 - rust-lang:offest, r=phansch
...
fixing a typo
changelog: none
2019-11-28 10:19:06 +01:00
Phil Hansch
1165176840
Rollup merge of #4842 - timbodeit:comparison-chain-false-positive-4827, r=flip1995
...
[comparison_chain] #4827 Check `core::cmp::Ord` is implemented
Only emit `comparison_chain` lint, if `cmp` is actually available on the type being compared. Don't emit lint in cases where only `PartialOrd` is implemented.
I haven't yet fully understood [Adjustments](https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/adjustment/struct.Adjustment.html ). I would appreciate, if someone could double check whether my usage of [expr_ty](https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/struct.TypeckTables.html#method.expr_ty ) in `clippy_lints/src/comparison_chain.rs:91` is correct or if there are cases where using [expr_ty_adjusted](https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/struct.TypeckTables.html#method.expr_ty_adjusted ) would lead to a different result when used with `utils::implements_trait`.
---
fixes #4827
changelog: [comparison_chain] Check `core::cmp::Ord` is implemented
2019-11-28 10:19:05 +01:00
Phil Hansch
6686892cbf
Rollup merge of #4832 - dario23:i4829, r=phansch
...
Add some positive examples to lint docs
fixes #4829
changelog: Add some positive examples to lint docs
2019-11-28 10:19:04 +01:00
bors
f3288eb48d
Auto merge of #4851 - daxpedda:float-arithmetic, r=flip1995
...
Remove negative float literal checks.
Fixes #4850 .
changelog: Remove negative float literal checks.
2019-11-28 09:11:45 +00:00
bors
d377486561
Auto merge of #4821 - Areredify:as_conversions, r=flip1995
...
Add `as_conversions` lint
changelog: closes #4771 , adding a new pedantic allow-by-default lint that lints against any usage of `as`.
2019-11-28 08:53:36 +00:00
bors
d6accfcc82
Auto merge of #4808 - euclio:string-lit-as-bytes, r=phansch
...
trigger string_lit_as_bytes when literal has escapes
---
changelog: fix string_lit_as_bytes false negative
Depends on rust-lang/rust#66349.
Fixes #4796 .
2019-11-28 07:26:04 +00:00
Lzu Tao
d0e0ffa99f
make use of Result::map_or
2019-11-28 10:52:20 +07:00
Manish Goregaokar
40c91ec758
config.usize_ty -> config.ptr_width
...
From http://github.com/rust-lang/rust/pull/66719
2019-11-27 15:09:48 -08:00
Manish Goregaokar
e381143a6b
More borrowkind fixes
2019-11-27 15:09:48 -08:00
Manish Goregaokar
3430bc1bc5
Re-add wildcards for BorrowKind in some places
2019-11-27 15:09:48 -08:00
Manish Goregaokar
341e266508
Add BorrowKind::Ref
2019-11-27 14:39:28 -08:00
Andy Russell
d33ad45d7d
trigger string_lit_as_bytes when literal has escapes
2019-11-26 17:07:17 -05:00
Ian Kronquist
aef2662896
Update literal_representation.rs
2019-11-25 16:30:46 -08:00
Ian Kronquist
b13f4e4faf
Update literal_representation.rs
2019-11-25 16:28:46 -08:00
daxpedda
e46bedca3c
Remove negative float literal checks.
2019-11-25 19:23:28 +01:00
flip1995
1d3ec29880
Remove unused debugging feature
2019-11-25 17:23:07 +01:00
Mikhail Babenko
9ec8888b91
implemented as_conversions
lint
...
actuall add files
add better example and change pedantic to restriction
2019-11-25 18:12:52 +03:00
flip1995
6eeac46b91
Run rustfmt
2019-11-25 15:20:10 +01:00
Andre Bogus
47ef5394de
fixing a typo
2019-11-25 14:06:34 +01:00
flip1995
d2d62de841
Rustup to rust-lang/rust#64856
2019-11-25 13:56:24 +01:00
flip1995
d43c424145
Rustup to rust-lang/rust#66671
2019-11-25 13:18:38 +01:00
Tim Bodeit
fff9a8ea9c
[comparison_chain] #4827 Check core::cmp::Ord
is implemented
...
Only emit lint, if `cmp` is actually available on the type being
compared. Don't emit lint in cases where only `PartialOrd` is
implemented.
2019-11-24 10:00:06 +01:00
bors
cc35165f52
Auto merge of #4840 - flip1995:rollup-jqk3a3i, r=flip1995
...
Rollup of 5 pull requests
Successful merges:
- #4730 (Fix check_infinite_loop (while_immutable_condition) by checking for break or return inside loop body)
- #4766 (Fix false positive in derive_hash_xor_eq)
- #4811 (Literal Representation Restructure)
- #4820 (doc: fix the comment above the lint function)
- #4830 (use more efficient code to generate repeated string)
Failed merges:
r? @ghost
changelog: none
2019-11-23 17:40:57 +00:00
Philipp Krones
b4524004e0
Rollup merge of #4830 - lzutao:str-repeat, r=flip1995
...
use more efficient code to generate repeated string
see https://rust.godbolt.org/z/z9vrFP for comparison
changelog: none
2019-11-23 18:16:03 +01:00
Philipp Krones
ae69bc4980
Rollup merge of #4820 - guanqun:comment-fix, r=flip1995
...
doc: fix the comment above the lint function
it's a simple comment fix.
---
changelog: none
2019-11-23 18:16:01 +01:00
Philipp Krones
623d8c4640
Rollup merge of #4811 - mikerite:lit_repr_20191113, r=flip1995
...
Literal Representation Restructure
This pull request restructures the literal_representation module to be easier to understand and maintain. I split the changes into a lot of commits to make reviewing easier.
changelog: none
2019-11-23 18:16:00 +01:00
Philipp Krones
93d84d7dda
Rollup merge of #4766 - phansch:fix_fp_in_derive_hash_xor_eq, r=flip1995
...
Fix false positive in derive_hash_xor_eq
This fixes a false positive in derive_hash_xor_eq where the lint was
triggering on user-defined traits called `Hash`.
changelog: Fix false positive in `derive_hash_xor_eq`
Fixes #4658
2019-11-23 18:15:59 +01:00
Philipp Krones
016857db65
Rollup merge of #4730 - yerke:fix-check_infinite_loop, r=flip1995
...
Fix check_infinite_loop (while_immutable_condition) by checking for break or return inside loop body
changelog: Fix check_infinite_loop (while_immutable_condition) by checking for break or return inside loop body
fixes #4648
2019-11-23 18:15:58 +01:00