xiongmao86
4f14826e09
Lint on opt.as_ref().map(|x| &**x).
2020-04-06 22:53:59 +08:00
Nick Torres
5d54fbb791
result_map_or_into_option: fix syntax error in example
2020-04-04 17:20:23 -07:00
Nick Torres
325d0b69d2
result_map_or_into: fix dogfood_clippy error => {h,l}int
2020-04-04 15:02:38 -07:00
Nick Torres
2533f56a0e
result_map_or_into_option: fix cargo dev fmt --check
errors
2020-04-04 14:33:43 -07:00
Nick Torres
acc3bc1ba2
result_map_or_into_option: move arg checks into tuple assignment
2020-04-04 14:24:22 -07:00
Nick Torres
d0738bd673
result_map_or_into_option: destructure lint tuple or return early
2020-04-04 14:16:23 -07:00
Nick Torres
3a29aedf8d
result_map_or_into_option: add good and bad examples
2020-04-04 14:16:18 -07:00
Nick Torres
91759a7582
result_map_or_into_option: explicitly note absence of known problems
2020-04-04 14:16:11 -07:00
David Tolnay
560c8c9c70
Downgrade new_ret_no_self to pedantic
2020-04-04 12:58:18 -07:00
Nick Torres
91d8a804d3
result_map_or_into_option: add lint to catch manually adpating Result -> Option
...
Result<T, E> has an `ok()` method that adapts a Result<T,E> into an Option<T>.
It's possible to get around this adapter by writing Result<T,E>.map_or(None, Some).
This lint is implemented as a new variant of the existing
[`option_map_none` lint](https://github.com/rust-lang/rust-clippy/pull/2128 )
2020-04-04 03:17:13 -07:00
David Tolnay
e26ae7a0ff
Downgrade inefficient_to_string to pedantic
2020-04-02 20:00:12 -07:00
Matthias Krüger
aff57e0f43
rustup https://github.com/rust-lang/rust/pull/70536
2020-03-30 11:17:58 +02:00
Philipp Hansch
cec1e8f74e
Remove dependency on matches
crate
...
The std equivalent works exactly the same.
2020-03-25 07:50:08 +01:00
Matthias Krüger
a97f60b8e3
rustup https://github.com/rust-lang/rust/pull/69738
2020-03-16 18:38:30 +01:00
bors
24f6d643fe
Auto merge of #5322 - phansch:or_patterns, r=matthiaskrgr
...
Make use of `or_patterns` feature
changelog: none
2020-03-16 12:41:04 +00:00
Matthias Krüger
ba0884bee3
rustup https://github.com/rust-lang/rust/pull/68944
2020-03-16 11:36:17 +01:00
Philipp Hansch
548c417ec4
Make use of or_patterns
feature
2020-03-16 07:25:09 +01:00
Yuki Okushi
3e3776666e
Rustup to rust-lang/rust#69674
2020-03-13 04:56:55 +09:00
Yuki Okushi
3d44ad2e32
Use try_eval_usize
over eval_usize
2020-03-03 21:40:24 +09:00
Yuki Okushi
4253aa7137
Rustup to rust-lang/rust#69592
2020-03-01 12:23:33 +09:00
flip1995
8472ecda0f
Fix fallout
2020-02-21 11:14:18 +01:00
Yuki Okushi
f56e8b7eb4
Rename FunctionRetTy
to FnRetTy
2020-02-17 19:07:08 +09:00
Matthew Jasper
787398aa53
Avoid using regions from TypeckTables
...
These regions will all be `ReErased` soon.
2020-02-15 16:24:49 +00:00
Lily Chung
385fd7cd0a
change in the right place, run update_lints
2020-02-12 17:03:49 -08:00
Areredify
66ad544175
improve 'iter_nth_zero' documentation
2020-02-03 15:44:55 +03:00
Ludwig Stecher
1f600f3f9a
Un-ignore most code blocks to render correctly on website, correct mistakes
2020-01-30 23:44:37 +01:00
Ludwig Stecher
58da5ba6db
Fix code formatting for more lints
2020-01-30 22:12:00 +01:00
Ludwig Stecher
f0dc98160b
Fix syntax highlighting of code fence
...
The documentation for RESULT_EXPECT_USED includes this code:
let res: Result<usize, ()> = Ok(1);
res?;
# Ok::<(), ()>(())
Because the code fence didn't start with `rust`, the code wasn't highlighted and the line starting with `#` was displayed on the website. This is now fixed.
2020-01-30 21:55:30 +01:00
xiongmao86
ac9f019fbf
Reformat code.
2020-01-30 00:23:47 +08:00
Yuki Okushi
f5e86d6894
Rename span_note_and_lint
to span_lint_and_note
2020-01-27 11:26:42 +09:00
Yuki Okushi
f60f12f71f
Rename span_help_and_lint
to span_lint_and_help
2020-01-27 11:17:58 +09:00
Yuki Okushi
4b133f2867
Apply review comments
2020-01-26 07:01:16 +09:00
Yuki Okushi
2dc73c45d5
Clean up methods/mod.rs
2020-01-24 17:04:37 +09:00
Areredify
796958c7e2
add option_as_ref_deref
lint
2020-01-23 16:12:16 +03:00
bors
eca0d8e5d0
Auto merge of #5067 - JohnTitor:lint-skip-while-next, r=flip1995
...
Add `skip_while_next` lint
Fixes #4036
changelog: Add `skip_while_next` lint
2020-01-20 17:28:38 +00:00
Yuki Okushi
bec5b69e45
Apply review comment
2020-01-20 21:07:31 +09:00
Yuki Okushi
f8034e0bc6
Improve suspicious_map
documentation
2020-01-20 15:05:40 +09:00
Yuki Okushi
95c369fa91
Add skip_while_next
lint
2020-01-20 10:56:02 +09:00
Yuki Okushi
e72f0e61c6
Rustup to rust-lang/rust#68204
2020-01-18 14:39:18 +09: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
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
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
39947992b5
Rustup to rust-lang/rust#67806
2020-01-11 21:50:00 +09:00
Yuki Okushi
e58cfac458
Rustup to rust-lang/rust#67979
2020-01-09 16:43:51 +09:00
Yuki Okushi
5ac08b0cc9
Normalize lint messages
2020-01-07 18:26:55 +09:00
Yuki Okushi
2f2eaf8b7e
Rustup to rust-lang/rust#67886
2020-01-07 01:46:33 +09: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
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
Yuki Okushi
1102b87e3a
Remove use of try!
from documentation
2020-01-04 13:47:01 +09:00
Yuki Okushi
9086b17e14
Rustup to rust-lang/rust#67707
2019-12-31 09:17:56 +09: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
Yuki Okushi
a4c201e6b4
Rustup to rust-lang/rust#66942
2019-12-30 13:02:10 +09:00
Micha Ober
c5046fdce5
Add real suggestion to option_map_unwrap_or
2019-12-28 23:24:45 +01:00
Yuki Okushi
e2636729ec
Rustup to rust-lang/rust#66936
2019-12-27 16:13:53 +09:00
flip1995
9632e27487
Add <'_> where necessary
2019-12-22 15:42:41 +01:00
Lzu Tao
d1ca5f1d7c
rustup "Merge ast::Mutability
and mir::Mutability
"
2019-12-21 18:38:45 +00: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
Lily Chung
6e8c2bf8e6
Fix documentation example for unnecessary_filter_map.
2019-12-19 15:48:17 -08: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
Matthias Krüger
98e433d70d
Rustup to rust-lang/rust#66878
2019-12-04 01:34:01 +01: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
Lzu Tao
d0e0ffa99f
make use of Result::map_or
2019-11-28 10:52:20 +07:00
Manish Goregaokar
341e266508
Add BorrowKind::Ref
2019-11-27 14:39:28 -08: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
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
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
Andre Bogus
c21b198576
New lint: zst_offset
2019-11-15 22:39:27 +01:00
Guanqun Lu
f2d8197110
doc: fix the comment above the lint function
2019-11-16 01:55:06 +08:00
Manish Goregaokar
e9a3e54910
MutImmutable -> Immutable, MutMutable -> Mutable, CaptureClause -> CaptureBy
2019-11-11 10:58:39 -08:00
flip1995
08fd397c2c
Deprecate into_iter_on_array
lint
...
This lint was uplifted/reimplemented by rustc.
Rustup to rust-lang/rust#66017
2019-11-07 14:04:29 +01:00
Lzu Tao
51632530d7
rustup rust-lang/rust#65776
2019-11-06 17:46:45 +07:00
Lzu Tao
4c7387e965
rustup https://github.com/rust-lang/rust/pull/65535
2019-10-19 12:27:21 +07:00
Heinz N. Gies
7f454d8d06
Split out tests
2019-10-18 07:40:48 +02:00
Heinz N. Gies
a7ad78f3eb
Add expect
...
Co-Authored-By: Philipp Krones <hello@philkrones.com>
2019-10-18 07:37:58 +02:00
Michael Zhang
2106a23966
Update help text in inefficient_to_string
...
Co-Authored-By: Manish Goregaokar <manishsmail@gmail.com>
2019-10-17 19:13:32 -04:00
HMPerson1
76b44f34b9
Add inefficient_to_string
lint
2019-10-16 15:54:20 -04:00
Andre Bogus
cc622608db
new lints around #[must_use]
fns
...
`must_use_unit` lints unit-returning functions with a `#[must_use]`
attribute, suggesting to remove it.
`double_must_use` lints functions with a plain `#[must_use]`
attribute, but which return a type which is already `#[must_use]`,
so the attribute has no benefit.
`must_use_candidate` is a pedantic lint that lints functions and
methods that return some non-unit type that is not already
`#[must_use]` and suggests to add the annotation.
2019-10-14 12:09:04 +02:00
bors
b690cdb1e7
Auto merge of #4611 - rust-lang:doc-visibility, r=flip1995
...
account for doc visibility
This fixes #4608 .
Also I noticed that the lint failed to look at trait and impl items. There's a small bit of fallout in the code, too, but not enough to warrant its own commit.
changelog: check docs of trait items and impl items, also make `missing_safety_doc` account for visibility
2019-10-08 07:11:26 +00:00
flip1995
3aa531c194
Run util/dev fmt
2019-10-05 12:42:09 +02:00
flip1995
3b23092b69
Get rid of rvalue_promotable_map method call
2019-10-05 12:38:38 +02:00
Andre Bogus
e3f143ff0a
account for doc visibility
2019-10-02 21:15:28 +02:00
flip1995
4bbd10a585
Rustup to rust-lang/rust#64813
2019-09-27 17:21:20 +02:00
Lzu Tao
a7b7e19f49
Rustup https://github.com/rust-lang/rust/pull/64513
2019-09-26 16:03:36 +07:00
Matthias Krüger
b72982759c
run rustfmt
2019-09-11 08:26:57 +02:00
bors
4ee8bc84cd
Auto merge of #4527 - rust-lang:more-vec-diag-items, r=oli-obk
...
Changed more `Vec` paths to diagnostic_items
In #4519 , I missed a few instances of path matching for `Vec`, so here they are.
r? @oli-obk
changelog: none
2019-09-09 16:56:51 +00:00
bors
c733376a5f
Auto merge of #4522 - mikerite:fix-4514, r=phansch
...
Fix `or_fun_call` bad suggestion
Closes #4514
changelog: Fix `or_fun_call` bad suggestion
2019-09-09 15:38:59 +00:00
Andre Bogus
507c03a859
Changed more Vec paths to diagnostic_items
2019-09-09 17:22:41 +02:00
Andre Bogus
e3c4ffd4aa
Use diagnostic item for
2019-09-09 05:43:39 +02:00
Michael Wright
9bdfd0683f
Fix or_fun_call
bad suggestion
...
Closes #4514
2019-09-08 11:03:45 +02:00
Jeremy Stucki
3fc1ec1ffd
Refactor option handling
2019-09-04 16:19:59 +02:00
bors
ffe57fad85
Auto merge of #4498 - sinkuu:checked_arithmetic_unwrap, r=flip1995
...
Add manual_saturating_arithmetic lint
changelog: add `manual_saturating_arithmetic` lint
Fixes #1557 . This lint detects manual saturating arithmetics like `x.checked_add(10u32).unwrap_or(u32::max_value())` and suggests replacing with `x.saturating_add(10u32)`.
2019-09-04 12:14:41 +00:00
Shotaro Yamada
c6fb9c8a2a
Hide variables in doc-test
2019-09-04 21:10:08 +09:00
Shotaro Yamada
45fde0f86f
Fix doctest and renaming src
2019-09-04 21:06:28 +09:00
Shotaro Yamada
4960f79476
Add manual_saturating_arithmetic lint
2019-09-04 18:38:25 +09:00
bors
8239b7616f
Auto merge of #4454 - BO41:search_is_some, r=flip1995
...
Dereference one less on search_is_some and make it auto-fixable
Fixes #4453
changelog: none
2019-09-04 07:53:44 +00:00
BO41
64cd9e4d60
Try to fix .fixed
2019-09-03 18:56:23 +02:00
Andre Bogus
b01f2d1126
lint against MaybeUninit::uninit().assume_init()
2019-09-03 17:37:38 +02:00
flip1995
3c11406c1f
Rustup to rust-lang/rust#60966
2019-08-30 10:11:27 +02:00
flip1995
dac81d867b
Use the spans returned by utils::method_calls
2019-08-29 17:34:03 +02:00
BO41
945d4cf69f
Dereference one less on search_is_some and make it auto-fixable
2019-08-29 17:34:02 +02:00
Yuki Okushi
2c282252a9
Replace Arg
with Param
2019-08-28 18:33:25 +09:00
bors
f760088820
Auto merge of #4430 - lzutao:defid_trait_alias, r=flip1995
...
Account for trait alias when looking for defid
I hit the crash on the `expect` call when running clippy on rustc libcore.
Hopefully this will fix it.
changelog: none
2019-08-26 12:46:00 +00:00
bors
ba6681300e
Auto merge of #4436 - BO41:written_as, r=phansch
...
Add some "could be written as" examples
fixes #4405
changelog: none
2019-08-26 11:11:57 +00:00
Lzu Tao
dac2509bac
Account for trait alias when looking for defid
2019-08-25 20:36:11 +07:00
BO41
31a6ab47e1
Fix lint doc
2019-08-24 13:57:25 +02:00
Jeremy Stucki
2da8288433
Refactor some minor things
2019-08-23 22:52:04 +02:00
Jeremy Stucki
907aebcf8b
Use more if-chains
2019-08-23 22:51:44 +02:00
Jeremy Stucki
4130dfba2e
Refactor 'lint_or_fun_call'
2019-08-23 22:31:22 +02:00
Jeremy Stucki
419c87fb35
Refactor 'check_unwrap_or_default'
2019-08-23 14:36:00 +02:00
Jeremy Stucki
1436fea271
Refactor 'check_impl_item'
2019-08-23 14:20:55 +02:00
BO41
eebb7cd839
Add examples to some complexity lints
2019-08-22 15:41:07 +02:00
BO41
43a2ba34e6
Add examples to some correctness lints
2019-08-22 15:41:07 +02:00
Michael Wright
59893bcab0
Fix temporary_cstring_as_ptr
false negative
...
Fixes #4375 .
Changes the check to test when `.unwrap().as_ptr()` is called on any
`Result<CString, _>` as suggested by @flip1995
(https://github.com/rust-lang/rust-clippy/issues/4375#issuecomment-520724123 ).
2019-08-21 07:35:04 +02:00
KRAAI, MATTHEW [VISUS]
204b2f3658
Remove in_macro_or_desugar
2019-08-19 09:30:32 -07:00
bors
5c71c1b838
Auto merge of #4411 - mikerite:fix-4384, r=flip1995
...
Fix `clone_on_copy` false positives
Closes #4384
changelog: Fix `clone_on_copy` false positives
2019-08-19 08:04:12 +00:00
Michael Wright
68a1af540c
Fix clone_on_copy
false positives
...
Closes #4384
2019-08-19 08:19:54 +02:00
Lzu Tao
7065239da5
Add option_and_then_some lint
2019-08-19 03:54:40 +00:00
Jeremy Stucki
9c39c02b75
Change lint type to 'complexity'
2019-08-18 16:49:11 +02:00
Jeremy Stucki
f4f31a4ff4
Implement lint 'suspicious_map'
2019-08-15 22:58:32 +02:00
Jeremy Stucki
fdf82eb1a8
Remove unused import
2019-08-14 20:24:05 +02:00
Jeremy Stucki
08f658bc72
Use different span
2019-08-14 19:35:06 +02:00
bors
63d2d066f9
Auto merge of #4369 - mikerite:fix-4293, r=flip1995
...
Fix `wrong_self_convention` issue
Resolves #4293
changelog: Fix `wrong_self_convention` issue
2019-08-14 10:59:36 +00:00
Jeremy Stucki
2bfcf89f82
Merge branch 'origin/master' into flat-map
2019-08-14 07:36:37 +02:00
Jeremy Stucki
d578c43c51
Use correct span
2019-08-13 21:50:42 +02:00
Jeremy Stucki
d51136d594
Use 'span_lint_and_sugg'
2019-08-12 21:42:57 +02:00
Jeremy Stucki
3a65e4e75a
Minor refactoring
2019-08-12 21:29:33 +02:00
Jeremy Stucki
09e9568c26
Change lint type from 'pedantic' → 'complexity'
2019-08-12 10:53:23 +02:00
Jeremy Stucki
df9063013e
Update rustdoc
2019-08-11 22:18:58 +02:00
Jeremy Stucki
5fd7d44f36
Refactor if_chain
...
Co-authored-by: Philipp Krones <hello@philkrones.com>
2019-08-11 21:02:01 +02:00
Jeremy Stucki
b651f19eb8
Rename 'flat_map' → 'flat_map_identity'
2019-08-11 20:34:25 +02:00
Jeremy Stucki
f0ce04f814
Handle calls with 'std::convert::identity'
2019-08-11 19:51:43 +02:00
Jeremy Stucki
05d9f884e1
Merge branch 'origin/master' into flat-map
2019-08-11 19:22:40 +02:00
Michael Wright
77278ccda9
Fix wrong_self_convention
issue
...
Resolves #4293
2019-08-10 06:01:15 +02:00
Michael Wright
170d4861c6
Simplify wrong_self_convention
code
...
Use actual types instead of hir types.
2019-08-10 06:00:27 +02:00
Michael Wright
ebd24985bf
Rename implitem to impl_item
...
`impl_item` is proper snake case and used everywhere else.
2019-08-10 05:58:52 +02:00
Lukas Markeffsky
d7b9a845aa
new_ret_no_self: walk associated types in impl Trait return types
2019-08-09 17:44:05 +02:00
bors
c55d38ed7a
Auto merge of #4362 - lzutao:expect-on-cstring_as_ptr, r=flip1995
...
Fix lint_cstring_as_ptr for expect
Closes #4312
changelog: none
2019-08-09 09:22:02 +00:00