rail
c53192c347
Add a note to as_conversions
...
… to clalify its purpose.
2021-01-19 12:58:48 +13:00
Cameron Steffen
2454408318
Remove qpath_res util function
2021-01-18 14:54:58 -06:00
LeSeulArtichaut
dce2262dae
Use ty::{IntTy,UintTy,FloatTy} in rustdoc and clippy
2021-01-18 21:10:36 +01:00
Ashley Mannix
9009f8f031
Rollup merge of #81038 - flip1995:clippyup, r=Manishearth
...
Update Clippy
Biweekly Clippy update
r? ``@Manishearth``
2021-01-18 21:53:22 +10:00
kai.giebeler
fb943fbe86
Merge remote-tracking branch 'upstream/master' into doc-markdown
2021-01-17 22:25:56 +01:00
bors
e477105405
Auto merge of #80679 - jackh726:predicate-kind-take2, r=lcnr
...
Remove PredicateKind and instead only use Binder<PredicateAtom>
Originally brought up in https://github.com/rust-lang/rust/pull/76814#discussion_r546858171
r? `@lcnr`
2021-01-17 20:49:11 +00:00
ThibsG
70704db36f
Do not lint when range is completely included into another one
2021-01-17 21:07:01 +01:00
pro-grammer1
fb2a06dcce
Remove numeric literals from print_literal and write_literal tests
2021-01-17 18:55:59 +00:00
pro-grammer1
ab155b14a2
Negate results of matches!
2021-01-17 18:21:58 +00:00
pro-grammer1
2af642da28
Replace another instance of match with matches
2021-01-17 18:01:01 +00:00
bors
91292f1eef
Auto merge of #6585 - Daniel-B-Smith:false-positive-issue, r=flip1995
...
Explicitly document false positives
Adds documentation for known false positives for the `await_holding*` lints.
Issues:
https://github.com/rust-lang/rust-clippy/issues/6353
https://github.com/rust-lang/rust-clippy/issues/6446
changelog: document FPs for the ``await_holding_*`` lints
2021-01-17 17:14:13 +00:00
bors
990e2b35b2
Auto merge of #6528 - Jarcho:redundant_slicing, r=flip1995
...
New lint: redundant_slicing
changelog: Added lint: `redundant_slicing`
fixes #6519
This will trigger on any type which implements `Index<RangeFull>` that returns the input type. This would be a false positive if the implementation does something other than return itself, but I'm not sure why you would ever want to do that.
2021-01-17 16:26:28 +00:00
bors
e0d331fbf4
Auto merge of #6582 - rail-rain:ice_6539, r=flip1995
...
Fix the ICE 6539
Fixes #6539
It happened because `zero_sized_map_values` used `layout_of` with types from type aliases, which is essentially the same as the ICE 4968.
---
changelog: Fix an ICE in `zero_sized_map_values`
2021-01-17 15:38:50 +00:00
bors
40ce9f83b6
Auto merge of #6549 - ThibsG:FixClosureNeedlessReturn, r=phansch
...
Fix FP with empty return for `needless_return` lint
This fixes a false positive in `needless_return` lint, when triggered in a closure using `return` statement without value.
Fixes : #6501
changelog: none
2021-01-17 10:29:10 +00:00
pro-grammer1
0d542b7310
Run tests/ui/update-all-references.sh and refactor match into matches!
2021-01-17 08:48:37 +00:00
Jack Huey
e73b8dcbca
Review changes
2021-01-16 18:56:37 -05:00
Jack Huey
82569601f2
Cleanup
2021-01-16 18:50:34 -05:00
Jack Huey
7c3b6a63ad
Use pred not binder
2021-01-16 18:40:47 -05:00
Jack Huey
f06eeaf982
Cleanup
2021-01-16 18:40:47 -05:00
Jack Huey
3436e21df5
Remove PredicateKind
2021-01-16 18:40:47 -05:00
Jack Huey
38e293cf5d
Remove PredicateKind::Atom
2021-01-16 18:40:47 -05:00
flip1995
7449dc96c0
Deprecate unknown_clippy_lints
...
This is now handled by unknown_lints
2021-01-16 19:44:46 +01:00
Jason Newcomb
9146a77032
Update clippy_lints/src/redundant_slicing.rs
...
Co-authored-by: Philipp Krones <hello@philkrones.com>
2021-01-15 16:41:24 -05:00
Jason Newcomb
bf028b3f4a
fix copy-paste error
2021-01-15 16:41:22 -05:00
Jason Newcomb
27c0d6c14b
don't lint external macro expansions
2021-01-15 16:41:20 -05:00
Jason Newcomb
2a41d40807
fix new lint error
2021-01-15 16:41:17 -05:00
Jason Newcomb
837bc99065
Initial implementation of redundant_slicing lint
2021-01-15 16:41:13 -05:00
bors
3577cf79de
Auto merge of #6500 - Javier-varez:case_sensitive_file_extensions, r=llogiq
...
Case sensitive file extensions
Closes #6425
Looks for ends_with methods calls with case sensitive extension comparisons.
changelog: Add new lint that warns about case-sensitive file extension comparisons.
2021-01-15 19:49:39 +00:00
ThibsG
83f1abff48
Fix FP with empty return for needless_return
lint
2021-01-15 18:57:56 +01:00
bors
2d1e129851
Auto merge of #6574 - Jarcho:single_match_eq, r=Manishearth
...
single_match: suggest `if` over `if let` when possible
fixes : #173
changelog: single_match: suggest `if` over `if let` when possible
2021-01-15 16:25:03 +00:00
bors
9ea66e946e
Auto merge of #6555 - stanislav-tkach:patch-1, r=flip1995
...
Remove duplication in the manual_ok_or lint example
changelog: none
2021-01-15 10:27:47 +00:00
flip1995
488153ff2f
Merge commit '953f024793dab92745fee9cd2c4dee6a60451771' into clippyup
2021-01-15 10:56:44 +01:00
flip1995
f18cf82ca8
Don't trigger needless_return lint in macros
2021-01-15 10:41:29 +01:00
flip1995
9bd037d0b5
Merge remote-tracking branch 'upstream/master' into rustup
2021-01-15 10:39:53 +01:00
Jason Newcomb
36ff2f739c
Rename function
2021-01-14 22:02:04 -05:00
Jason Newcomb
85edd65bf6
Address review comments
...
Add: attempt to remove address of expressions from the scrutinee expression before adding references to the pattern
2021-01-14 14:26:26 -05:00
bors
7b3af4145b
Auto merge of #79328 - c410-f3r:hir-if, r=matthewjasper
...
Reintroduce hir::ExprKind::If
Basically copied and paste #59288/https://github.com/rust-lang/rust-clippy/pull/4080 with some modifications.
The vast majority of tests were fixed and now there are only a few remaining. Since I am still unable to figure out the missing pieces, any help with the following list is welcome.
- [ ] **Unnecessary `typeck` exception**: [Cheated on this one to make CI green.](https://github.com/rust-lang/rust/pull/79328/files#diff-3faee9ba23fc54a12b7c43364ba81f8c5660045c7e1d7989a02a0cee1c5b2051 )
- [x] **Incorrect span**: [Span should reference `then` and `else` separately.](https://github.com/rust-lang/rust/pull/79328/files#diff-cf2c46e82222ee4b1037a68fff8a1af3c4f1de7a6b3fd798aacbf3c0475abe3d )
- [x] **New note regarding `assert!`**: [Modified but not "wrong". Maybe can be a good thing?](https://github.com/rust-lang/rust/pull/79328/files#diff-9e0d7c89ed0224e2b62060c957177c27db43c30dfe3c2974cb6b5091cda9cfb5 )
- [x] **Inverted report location**: [Modified but not "wrong". Locations were inverted.](https://github.com/rust-lang/rust/pull/79328/files#diff-f637ce7c1f68d523a165aa9651765df05e36c4d7d279194b1a6b28b48a323691 )
- [x] **`src/test/ui/point-to-type-err-cause-on-impl-trait-return.rs` has weird errors**: [Not sure why this is happening.](https://github.com/rust-lang/rust/pull/79328/files#diff-c823c09660f5b112f95e97e8ff71f1797b6c7f37dbb3d16f8e98bbaea8072e95 )
- [x] **Missing diagnostic**: [???](https://github.com/rust-lang/rust/pull/79328/files#diff-6b8ab09360d725ba4513933827f9796b42ff9522b0690f80b76de067143af2fc )
2021-01-14 14:41:58 +00:00
Daniel Smith
02f99bea87
Explicitly document false positives
2021-01-13 16:08:15 -05:00
bors
dcd8c8e739
Auto merge of #77524 - Patryk27:fixes/66228, r=estebank
...
Rework diagnostics for wrong number of generic args (fixes #66228 and #71924 )
This PR reworks the `wrong number of {} arguments` message, so that it provides more details and contextual hints.
2021-01-13 20:35:58 +00:00
Joshua Nelson
dfb41f4797
Separate out a hir::Impl
struct
...
This makes it possible to pass the `Impl` directly to functions, instead
of having to pass each of the many fields one at a time. It also
simplifies matches in many cases.
2021-01-12 20:32:33 -05:00
Takayuki Nakata
ea028497ed
Make a reference a link in doc
2021-01-13 09:21:26 +09:00
rail
feee45c872
Fix the ICE 6539
...
It happened because `zero_sized_map_values` used `layout_of` with types
from type aliases, which is essentially the same as the ICE 4968.
2021-01-13 12:07:33 +13:00
Cameron Steffen
f2d493504c
Similar names ignore underscore prefixed names
2021-01-12 14:21:28 -06:00
bors
7f4599a848
Auto merge of #6557 - rail-rain:extending_cast_ptr_alignment, r=phansch
...
Catch `pointer::cast` too in `cast_ptr_alignment`
Fixes #4708
Although there were some discussion in the issue, this PR implements the original feature. I think `cast_ptr_alignment` should exist as it is, separated from `ptr_as_ptr`.
---
changelog: Extend `cast_ptr_alignment` lint for the `pointer::cast` method
2021-01-11 22:03:46 +00:00
rail
53f87310cd
Simplify cast_ptr_alignment
pointer::casr
case
2021-01-12 10:06:41 +13:00
Jason Newcomb
8d7417d807
Add: single_match will suggest using if .. == .. instead of if let when applicable
2021-01-10 23:32:23 -05:00
Patryk Wychowaniec
2c6dc8801f
Rework diagnostics for wrong number of generic args
2021-01-10 13:07:40 +01:00
Vadim Petrochenkov
9e45a23ab9
ast: Remove some indirection layers from values in key-value attributes
2021-01-09 21:50:39 +03:00
bors
583715f583
Auto merge of #6565 - giraffate:small_fixes_of_doc_in_needless_question_mark, r=phansch
...
Small fixes of doc in `needless_question_mark`
changelog: none
2021-01-09 15:28:10 +00:00
bors
ee0598e254
Auto merge of #6571 - ThibsG:BoxedLocalTrait, r=phansch
...
Fix FP for `boxed_local` lint in default trait fn impl
Fix FP on default trait function implementation on `boxed_local` lint.
Maybe I checked too much when looking if `self` is carrying `Self` in its bound type.
I can't find a good test case for this, so it could be too much conservative.
Let me know if you think only detecting `self` parameter is enough.
Fixes : #4804
changelog: none
2021-01-09 13:42:28 +00:00
ThibsG
8a6fea4fb8
Fix FP for boxed_local
lint in default trait fn impl
2021-01-09 12:26:24 +01:00
Cameron Steffen
7871ebaab9
Fix symbol string comparison dogfood
2021-01-08 14:50:00 -06:00
Cameron Steffen
cc26919b4d
Add unnecessary symbol string lint
2021-01-08 14:49:59 -06:00
Cameron Steffen
76ccfb4ae2
Fix unnecessary keyword intern dogfood
2021-01-08 14:32:32 -06:00
Cameron Steffen
121c65f0cf
Add keywords to interning defined symbol lint
2021-01-08 12:13:06 -06:00
Cameron Steffen
24c700b5d7
Use DefId in interning defined symbol lint
2021-01-08 12:13:06 -06:00
Cameron Steffen
8490862cc3
Fix path_to_res for enum inherent items
2021-01-08 11:56:52 -06:00
bors
2950c8e1cb
Auto merge of #6566 - giraffate:reduce_the_span_in_from_over_into, r=Manishearth
...
Reduce the span in `from_over_into` to impl header
A follow up of https://github.com/rust-lang/rust-clippy/pull/6476#discussion_r546271382
> That item might be quite large. We may want to reduce the span to the `impl` header.
changelog: none
2021-01-08 01:49:26 +00:00
rail
ee9b47dae6
Move is_hir_ty_cfg_dependant
to util
,
...
add stuff on pointer::cast` to the document for `cast_ptr_alignment`
and fix line numbers in the test.
2021-01-08 14:15:12 +13:00
Takayuki Nakata
0e14a75506
Reduce the span in from_over_into
to impl header
2021-01-08 09:16:11 +09:00
Takayuki Nakata
aa9adbf244
Small fixes of doc in needless_question_mark
2021-01-08 08:45:15 +09:00
Caio
7d42172899
Reintroduce hir::ExprKind::If
2021-01-07 18:54:12 -03:00
Stanislav Tkach
2b3c0ade6d
Fix typo: irrevelent
-> irrelevant
2021-01-07 13:59:55 +02:00
rail
f50ded0592
Catch pointer::cast
too in cast_ptr_alignment
2021-01-07 16:56:19 +13:00
Stanislav Tkach
15d5ac6b2f
Remove duplication in the manual_ok_or lint example
2021-01-06 13:26:35 +02:00
jekto_vatimeliju
8a45ffa11d
Fix typo: which which can be
-> which can be
2021-01-06 20:02:50 +09:00
bors
efccfe80e4
Auto merge of #6553 - phansch:field-reassign-with-default-macros, r=flip1995
...
Fix derive and macro related false positives in `field_reassign_with_default`
Closes #6545
changelog: Fix derive and macro related false positives in [`field_reassign_with_default`]
2021-01-06 08:22:47 +00:00
Philipp Hansch
92f2bbbe06
Fix macro issues with field_reassign_with_default
2021-01-05 20:31:13 +01:00
Philipp Hansch
a8825e9af0
Use existing 'is_automatically_derived' helper
2021-01-05 16:31:08 +01:00
Philipp Hansch
ea885d90ad
Tiny Symbol cleanup
...
* Renames `sym.rs` to `sym_helper.rs` so that the `sym as rustc_sym` is no longer needed.
* Removes one needless `symbol` from a path
2021-01-05 16:03:39 +01:00
Javier Alvarez
e56973a854
Remove default lint description
...
This was left as default and caused a CI failure for the
case_sensitive_file_extension_comparison lint.
2021-01-05 14:22:26 +01:00
Javier Alvarez
61f3d9d46b
Add case_sensitive_file_extensions lint
...
Closes #6425
Looks for ends_with methods calls with case sensitive extensions.
2021-01-05 14:22:26 +01:00
bors
a6b72d378f
Auto merge of #6542 - rail-rain:ptr_as_ptr, r=flip1995
...
Add a new lint `ptr_as_ptr`
This PR adds a new lint `ptr_as_ptr` which checks for `as` casts between raw pointers without changing its mutability and suggest replacing it with `pointer::cast`. Closes #5890 .
Open question: should this lint be `pedantic` or `style`? I set it `pedantic` for now because the original post suggests using it, but I think the lint also fits well to `style`.
---
changelog: New lint `ptr_as_ptr`
2021-01-05 09:54:34 +00:00
bors
311186b9bb
Auto merge of #6513 - nahuakang:fix/empty_enum_lint_never_type, r=flip1995
...
Fix: Empty enum never type suggested only if the feature is enabled
This PR addresses [Issue 6422](https://github.com/rust-lang/rust-clippy/issues/6422 ). Instead of always recommending `never type` for empty enums, Clippy would only recommend [the lint](https://rust-lang.github.io/rust-clippy/master/index.html#empty_enum ) if [LatePass.TyCtxt](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html ) has `features().never_type` enabled.
- \[ ] Followed [lint naming conventions][lint_naming]
- \[x] Added passing UI tests (including committed `.stderr` file)
- \[x] `cargo test` passes locally
- \[x] Executed `cargo dev update_lints`
- \[x] Added lint documentation
- \[x] Run `cargo dev fmt`
---
*Please write a short comment explaining your change (or "none" for internal only changes)*
changelog: Only trigger [`empty_enum`] lint if `never_type` feature is enabled.
2021-01-05 09:37:19 +00:00
rail
dfa5d7e818
Fix the MSRV and add the tests for MSRV
2021-01-05 10:21:55 +13:00
rail
4b478a5731
Add a new lint ptr_as_ptr
,
...
which checks for `as` casts between raw pointers
without changing its mutability
and suggest replacing it with `pointer::cast`.
2021-01-05 10:19:03 +13:00
bors
976850b69b
Auto merge of #6538 - Jarcho:vec_init_then_push, r=llogiq
...
New lint: vec_init_then_push
fixes : #1483
This will trigger on `new`, `default`, and `with_capacity` when the given capacity is less than or equal to the number of push calls. Is there anything else this should trigger on?
changelog: Added lint: `vec_init_then_push`
2021-01-04 20:42:18 +00:00
nahuakang
a8d47b4b78
Run cargo dev fmt
2021-01-04 18:41:42 +01:00
nahuakang
bc97f5d215
Address flip1995's review comments
2021-01-04 18:34:05 +01:00
bors
ae9ae9713c
Auto merge of #6507 - bengsparks:lint/issue6410, r=flip1995
...
Needless Question Mark Lint
Fixes #6410 , i.e the needless question mark lint
changelog: [`needless_question_mark`] New lint
2021-01-04 14:17:24 +00:00
Benjamin Sparks
ba87acb440
Implemented needless question mark lint
2021-01-04 14:51:48 +01:00
Matthias Krüger
6dcec6ae86
collapsible_if: split collapsible_else_if into its own lint so we can enable/disable it particularly
...
This splits up clippy::collapsible_if into collapsible_if for
if x {
if y { }
}
=>
if x && y { }
and collapsible_else_if for
if x {
} else {
if y { }
}
=>
if x {
} else if y {
}
so that we can lint for only the latter but not the first if we desire.
changelog: collapsible_if: split up linting for if x {} else { if y {} } into collapsible_else_if lint
2021-01-04 13:34:14 +01:00
Matthias Krüger
39f39d5405
match_like_matches_macro: strip refs in suggestion
...
fixes #6503
changelog: match_like_matches_macro: strip refs in suggestion (#6503 )
2021-01-03 20:28:46 +01:00
Jason Newcomb
7b5f54954a
Fix docs: use type inference
2021-01-03 14:04:05 -05:00
bors
592f7eb7eb
Auto merge of #6531 - matthiaskrgr:6522, r=ebroto
...
field_reassign_with_default: don't expand macros in suggestion
fixes #6522
changelog: field_reassign_with_default: don't expand macros in lint suggestion (#6522 )
2021-01-02 23:38:23 +00:00
Jason Newcomb
d37ee6ffa0
Fix lint errors
2021-01-02 14:31:21 -05:00
Jason Newcomb
1853f8b228
Add lint
2021-01-02 11:08:56 -05:00
flip1995
ba4bf4f9c5
Merge commit '1fcc74cc9e03bc91eaa80ecf92976b0b14b3aeb6' into clippyup
2021-01-02 16:29:43 +01:00
flip1995
e4fbc5f423
Bump Clippy version to 0.1.51
2021-01-02 16:26:10 +01:00
flip1995
d93692efa2
Merge remote-tracking branch 'upstream/master' into rustup
2021-01-02 16:03:26 +01:00
Matthias Krüger
5d48b91b40
field_reassign_with_default: don't expand macros in suggestion
...
fixes #6522
changelog: field_reassign_with_default: don't expand macros in lint suggestion (#6522 )
2021-01-01 17:01:09 +01:00
Mara Bos
e5a1f22f48
Initial support for Rust 2021.
...
Clippy treated Rust 2021 as Rust 2015, because 2018 was checked with
`==` instead of `>=`. This fixes that, such that 2018-specific things
are also enabled for 2021.
2021-01-01 16:21:31 +01:00
Julian Knodt
48dec842f2
first pass at default values for const generics
...
- Adds optional default values to const generic parameters in the AST
and HIR
- Parses these optional default values
- Adds a `const_generics_defaults` feature gate
2021-01-01 10:55:10 +01:00
Matthias Krüger
59397d6abb
make clippy version number correspond to rustc version number.
...
clippy 0.1.50 corresponds to rustc 1.50.x
This bumps the clippy version number from 0.0.212 to 0.1.50
Fixes #6499
2020-12-31 16:29:26 +01:00
Joshua Nelson
5479bbaf72
Rename kw::Invalid -> kw::Empty
...
See https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Is.20there.20a.20symbol.20for.20the.20empty.20string.3F/near/220054471
for context.
2020-12-30 09:50:02 -05:00
nahuakang
275988cb73
Add additional lint doc to known problems section
2020-12-28 20:45:56 +01:00
nahuakang
469281c0dd
Check if never type feature is enabled by TyCtxt before suggesting empty enum lint
2020-12-28 18:59:35 +01:00
Aleksei Latyshev
203715aa4e
don't ignore expression after first not matched method call in PtrCloneVisitor
2020-12-28 01:09:04 +03:00
bors
61a3ee7935
Auto merge of #6506 - alex-700:add-path-buf-to-ptr-arg-lint, r=Manishearth
...
Lint "&PathBuf instead of &Path" in PTR_ARG
fixes #6502
changelog: lint "`&PathBuf` instead of `&Path`" in `PTR_ARG`
2020-12-27 17:59:52 +00:00
bors
3661848997
Auto merge of #6375 - camsteffen:reassign-default-private, r=flip1995
...
Reassign default private
changelog: fix field_reassign_with_default false positive
* Fix #6344
* Fix assumption that `field: Default::default()` is the same as `..Default::default()`
* Cleanup some redundant logic
2020-12-27 16:20:47 +00:00