Commit graph

3028 commits

Author SHA1 Message Date
Marc Dominik Migge
9fe9d94abd Don't lint unit args if expression kind is path 2021-02-24 13:31:04 +01:00
Marc Dominik Migge
eb476c6c70 Split up tests for unit arg expressions 2021-01-18 20:18:56 +01:00
Marc Dominik Migge
0c347d3d06 Fix false positive for unit_arg lint 2021-01-17 14:42:36 +01: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
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
46aa654c2d Fix test due to recent Rustup merge 2021-01-15 18:58:48 +01: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
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
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
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
Jason Newcomb
8d7417d807
Add: single_match will suggest using if .. == .. instead of if let when applicable 2021-01-10 23:32:23 -05: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
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
Caio
7d42172899 Reintroduce hir::ExprKind::If 2021-01-07 18:54:12 -03:00
rail
f50ded0592 Catch pointer::cast too in cast_ptr_alignment 2021-01-07 16:56:19 +13:00
Philipp Hansch
92f2bbbe06
Fix macro issues with field_reassign_with_default 2021-01-05 20:31:13 +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
bors
a02806e00d Auto merge of #6518 - ThibsG:CopyException, r=ebroto
Ensure `Copy` exception in trait definition for `wrong_self_conventio…

Add a test case to ensure `Copy` exception is preserved also in trait definition, when passing `self` by value.

Follow up of #6316

changelog: none
2021-01-02 23:51:49 +00: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
9427e0356b
Fix clone_on_copy test 2021-01-02 14:15:11 -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
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
ThibsG
af480a67be Ensure Copy exception in trait definition for wrong_self_convention lint 2020-12-30 12:02:26 +01:00
Aaron Hill
6fd18f95ca Remove unnecessary semicolon from Clippy test 2020-12-29 17:16:04 -05:00
nahuakang
83a458acf1 Enable never type in empty enum ui test; run cargo dev bless 2020-12-28 20:18:27 +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
Aleksei Latyshev
dfaea9c967
lint &PathBuf instead of &Path in PTR_ARG
- extract get_only_generic_arg_snippet to improve readability
2020-12-25 15:06:34 +03:00
Takayuki Nakata
e1743ef525 Fix a style of texts in map_err_ignore 2020-12-25 08:59:34 +09:00
Cameron Steffen
c6450c70dd Fix field_reassign_with_default for private fields 2020-12-22 11:09:46 -06:00
Cameron Steffen
8bdf34e10c Fix default initialized fields in suggestion
The default value for a field type does not necessarily match the
default value for that field in the struct Default.
2020-12-22 10:51:56 -06:00
bors
25e9acb253 Auto merge of #6476 - 1c3t3a:1c3t3a-from-over-into, r=llogiq
Added from_over_into lint

Closes #6456
Added a lint that searches for implementations of `Into<..>` and suggests to implement `From<..>` instead, as it comes with a default implementation of `Into`. Category: style.

changelog: added `from_over_into` lint
2020-12-22 12:06:08 +00:00
Bastian Kersting
53f4d437f4
Update from_over_into.stderr 2020-12-21 17:15:05 +01:00