]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoFix clippy error
Hirochika Matsumoto [Fri, 28 Aug 2020 10:35:04 +0000 (19:35 +0900)]
Fix clippy error

3 years agoAdd STD_FS_CREATE_DIR into paths
Hirochika Matsumoto [Fri, 28 Aug 2020 09:53:15 +0000 (18:53 +0900)]
Add STD_FS_CREATE_DIR into paths

3 years agoAdd a new lint to prevent `create_dir` from being used
Hirochika Matsumoto [Fri, 28 Aug 2020 09:40:22 +0000 (18:40 +0900)]
Add a new lint to prevent `create_dir` from being used

3 years agoAuto merge of #5971 - giraffate:fix_fp_in_to_string_in_display, r=ebroto
bors [Thu, 27 Aug 2020 23:26:52 +0000 (23:26 +0000)]
Auto merge of #5971 - giraffate:fix_fp_in_to_string_in_display, r=ebroto

Fix FP in `to_string_in_display`

Don't emit a lint when `.to_string()` on anything that is not `self`

Fix #5967

changelog: Fix FP in `to_string_in_display` when calling `.to_string()` on anything that is not `self`

3 years agoFix FP in `to_string_in_display`
Takayuki Nakata [Thu, 27 Aug 2020 14:37:47 +0000 (23:37 +0900)]
Fix FP in `to_string_in_display`

Don't emit a lint when `.to_string()` on anything that is not `self`

3 years agoAuto merge of #5957 - xvschneider:AddUnwrapInsideResultLint, r=yaahc
bors [Wed, 26 Aug 2020 23:38:34 +0000 (23:38 +0000)]
Auto merge of #5957 - xvschneider:AddUnwrapInsideResultLint, r=yaahc

Adding new lint to prevent usage of 'unwrap' inside functions that re…

### Change
Adding a new lint that will emit a warning when using "unwrap" or "expect" inside a function that returns result.
### Motivation
These functions promote recoverable errors to non-recoverable errors which may be undesirable in code bases which wish to avoid panics.
### Test plan
Running:
`TESTNAME=unwrap_in_result cargo uitest
`---

changelog: none

3 years agoAdd new lint to prevent usage of unwrap in fns that return result
Jane Lusby [Wed, 26 Aug 2020 23:31:49 +0000 (16:31 -0700)]
Add new lint to prevent usage of unwrap in fns that return result

3 years agoAuto merge of #5968 - rail-rain:fix_use_snippet_with_applicability, r=flip1995
bors [Wed, 26 Aug 2020 22:52:47 +0000 (22:52 +0000)]
Auto merge of #5968 - rail-rain:fix_use_snippet_with_applicability, r=flip1995

Fix the wrong use of `snippet_with_applicability`

For the context, please see https://github.com/rust-lang/rust-clippy/issues/5822#issuecomment-680749728 and https://github.com/rust-lang/rust-clippy/issues/5822#issuecomment-680783381.

---

changelog: none

3 years agoFix the wrong use of `snippet_with_applicability`
rail [Wed, 26 Aug 2020 22:23:21 +0000 (10:23 +1200)]
Fix the wrong use of `snippet_with_applicability`

This includes a workaround of the issue #5822,
the cause of this little mistake.

3 years agoAuto merge of #5966 - 1c3t3a:1c3t3a-dev-5819-fix, r=Manishearth
bors [Wed, 26 Aug 2020 18:15:42 +0000 (18:15 +0000)]
Auto merge of #5966 - 1c3t3a:1c3t3a-dev-5819-fix, r=Manishearth

Corrects the float_equality_without_abs lint

Fixes an issue in the `float_equality_without_abs` lint. The lint suggestion was configured in a way that it lints the whole error and not just the subtraction part. In the current configuration the lint would suggest to change the expression in a wrong way, e.g.
```rust
let _ = (a - b) < f32::EPSILON; // before
let _ = (a - b).abs(); // after
```
This was dicovered by @flip1995. (See discussion of PR #5952).

Also the suggestion is now formatted via `utils::sugg`.
changelog: none

3 years agoChanged the location of the suggestion as well as the way the suggestion is assembled
Bastian [Wed, 26 Aug 2020 14:39:30 +0000 (16:39 +0200)]
Changed the location of the suggestion as well as the way the suggestion is assembled

3 years agoAuto merge of #5946 - mikerite:fix-5729, r=flip1995
bors [Wed, 26 Aug 2020 12:01:32 +0000 (12:01 +0000)]
Auto merge of #5946 - mikerite:fix-5729, r=flip1995

Fix `let_and_return` bad suggestion

Add a cast to the suggestion when the return expression has adjustments.
These adjustments are lost when the suggestion is applied.

This is similar to the problem in issue #4437.

Closes #5729

changelog: Fix `let_and_return` bad suggestion

3 years agoAuto merge of #5949 - rail-rain:fix_fp_borrow_interior_mutable_const, r=oli-obk
bors [Wed, 26 Aug 2020 11:06:37 +0000 (11:06 +0000)]
Auto merge of #5949 - rail-rain:fix_fp_borrow_interior_mutable_const, r=oli-obk

Fix fp in `borrow_interior_mutable_const`

fixes #5796

changelog: fix false positive in `borrow_interior_mutable_const` when referencing a field behind a pointer.

3 years agoAuto merge of #5964 - matsujika:matsujika-patch-1, r=ebroto
bors [Wed, 26 Aug 2020 07:53:07 +0000 (07:53 +0000)]
Auto merge of #5964 - matsujika:matsujika-patch-1, r=ebroto

Fix typo

changelog: none

3 years agoFix typo
Hirochika Matsumoto [Wed, 26 Aug 2020 07:03:35 +0000 (16:03 +0900)]
Fix typo

3 years agoAuto merge of #5951 - ThibsG:FixMacroCloneOnRefPtr2076, r=ebroto
bors [Tue, 25 Aug 2020 21:48:19 +0000 (21:48 +0000)]
Auto merge of #5951 - ThibsG:FixMacroCloneOnRefPtr2076, r=ebroto

Fix incorrect suggestion when `clone_on_ref_ptr` is triggered in macros

In the lint `clone_on_ref_ptr`, if the `span` is in a macro, don't expand it for suggestion.

Fixes: #2076
changelog: none

r? @ebroto

3 years agoUpdate clippy_lints/src/methods/mod.rs
Thibaud [Tue, 25 Aug 2020 20:20:35 +0000 (22:20 +0200)]
Update clippy_lints/src/methods/mod.rs

Co-authored-by: Eduardo Broto <ebroto@tutanota.com>
3 years agoAuto merge of #5961 - scottmcm:master, r=Manishearth
bors [Tue, 25 Aug 2020 19:30:05 +0000 (19:30 +0000)]
Auto merge of #5961 - scottmcm:master, r=Manishearth

Re-enable len_zero for ranges now that `is_empty` is stable on them

Fixes #5956

Completed stabilization PR: https://github.com/rust-lang/rust/pull/75132

changelog: len_zero: re-enable linting ranges now that range_is_empty is stable

3 years agoRe-enable len_zero for ranges now that `is_empty` is stable on them
Scott McMurray [Tue, 25 Aug 2020 19:05:02 +0000 (12:05 -0700)]
Re-enable len_zero for ranges now that `is_empty` is stable on them

3 years agoAuto merge of #5958 - mikerite:fix-fmt-20200825, r=flip1995
bors [Tue, 25 Aug 2020 17:15:51 +0000 (17:15 +0000)]
Auto merge of #5958 - mikerite:fix-fmt-20200825, r=flip1995

Various fmt test improvements

Various fmt test improvements.

changelog: none

3 years agoAuto merge of #5952 - 1c3t3a:1c3t3a-dev-5819, r=Manishearth
bors [Tue, 25 Aug 2020 16:54:48 +0000 (16:54 +0000)]
Auto merge of #5952 - 1c3t3a:1c3t3a-dev-5819, r=Manishearth

Added a lint which corrects expressions like (a - b) < f32::EPSILON, according to #5819

Fixes #5819
changelog: none

3 years agoAuto merge of #5947 - ebroto:rustup_doc_improvements, r=flip1995
bors [Tue, 25 Aug 2020 16:33:17 +0000 (16:33 +0000)]
Auto merge of #5947 - ebroto:rustup_doc_improvements, r=flip1995

Improve documentation related to the sync process

[Rendered](https://github.com/ebroto/rust-clippy/blob/rustup_doc_improvements/CONTRIBUTING.md)

r? @flip1995

changelog: none

3 years agoAuto merge of #5960 - flip1995:rustup, r=flip1995
bors [Tue, 25 Aug 2020 16:11:17 +0000 (16:11 +0000)]
Auto merge of #5960 - flip1995:rustup, r=flip1995

Rustup

r? @ghost

changelog: none

3 years agoFix typo
Philipp Krones [Tue, 25 Aug 2020 16:01:08 +0000 (18:01 +0200)]
Fix typo

3 years agoAdded F32::EPSILON and F64::EPSILON to paths.rs
Bastian [Tue, 25 Aug 2020 11:41:39 +0000 (13:41 +0200)]
Added F32::EPSILON and F64::EPSILON to paths.rs

3 years agoFix intermittent build error
Michael Wright [Tue, 25 Aug 2020 03:53:28 +0000 (05:53 +0200)]
Fix intermittent build error

The fmt test will cause clippy dev to be compiled and run. The clippy dev
dependencies are currently stored at `target/debug/deps` when this happens.
This location sometimes causes conflicts with ui tests which result in the
build error "thread 'compile_test' panicked at 'Found multiple rlibs for crate
`regex` ...".

This commit forces the clippy_dev dependencies to be stored under
`clippy_dev/target/` which seems to resolve this problem.

3 years agoSimplify fmt test by using the clippy dev alias
Michael Wright [Tue, 25 Aug 2020 03:53:28 +0000 (05:53 +0200)]
Simplify fmt test by using the clippy dev alias

3 years agoFix incorrect comment
Michael Wright [Tue, 25 Aug 2020 03:53:28 +0000 (05:53 +0200)]
Fix incorrect comment

3 years agoAuto merge of #5920 - giraffate:fix_fp_for_redundant_closure_call, r=mikerite
bors [Tue, 25 Aug 2020 03:29:59 +0000 (03:29 +0000)]
Auto merge of #5920 - giraffate:fix_fp_for_redundant_closure_call, r=mikerite

Fix FP for `redundant_closure_call`

Fix #5916

changelog: Fix FP for `redundant_closure_call` when called in function body

3 years agoUnbreak the clippy test
Scott McMurray [Mon, 24 Aug 2020 21:28:01 +0000 (14:28 -0700)]
Unbreak the clippy test

3 years agoAuto merge of #5935 - matthiaskrgr:unstable_sort_ty_name, r=flip1995
bors [Mon, 24 Aug 2020 18:08:39 +0000 (18:08 +0000)]
Auto merge of #5935 - matthiaskrgr:unstable_sort_ty_name, r=flip1995

stable_sort_primitive: print the type that is being sorted in the lint message

changelog: stable_sort_primitive: print the type that is being sorted in the lint message

3 years agostable_sort_primitive: print the type that is being sorted in the lint message
Matthias Krüger [Fri, 21 Aug 2020 00:03:57 +0000 (02:03 +0200)]
stable_sort_primitive: print the type that is being sorted in the lint message

3 years agoAdded a lint which corrects expressions like (a - b) < f32::EPSILON
Bastian [Mon, 24 Aug 2020 14:31:51 +0000 (16:31 +0200)]
Added a lint which corrects expressions like (a - b) < f32::EPSILON

3 years agoFix incorrect suggestion when `clone_on_ref_ptr` is triggered in macros
ThibsG [Mon, 24 Aug 2020 12:01:27 +0000 (14:01 +0200)]
Fix incorrect suggestion when `clone_on_ref_ptr` is triggered in macros

3 years agotypo
rail-rain [Mon, 24 Aug 2020 07:08:38 +0000 (19:08 +1200)]
typo

Co-authored-by: Thibaud <ThibsG@users.noreply.github.com>
3 years agoAvoid period in lint message according to convention
Takayuki Nakata [Mon, 24 Aug 2020 01:11:53 +0000 (10:11 +0900)]
Avoid period in lint message according to convention

3 years agoFix FP for `redundant_closure_call`
Takayuki Nakata [Tue, 18 Aug 2020 14:00:21 +0000 (23:00 +0900)]
Fix FP for `redundant_closure_call`

Visit the nested things like function body when checking closure call.

3 years agoApply suggestions from PR review
Eduardo Broto [Sun, 23 Aug 2020 20:20:55 +0000 (22:20 +0200)]
Apply suggestions from PR review

3 years agoAuto merge of #5948 - ebroto:5944_repeat_ice, r=Manishearth
bors [Sun, 23 Aug 2020 14:13:58 +0000 (14:13 +0000)]
Auto merge of #5948 - ebroto:5944_repeat_ice, r=Manishearth

Fix ICE in `repeat_once`

changelog: Fix ICE in [`repeat_once`]

Fixes #5944

3 years agoAuto merge of #5930 - ebroto:dev_newlint_fix_lt, r=matthiaskrgr
bors [Sun, 23 Aug 2020 10:59:53 +0000 (10:59 +0000)]
Auto merge of #5930 - ebroto:dev_newlint_fix_lt, r=matthiaskrgr

Fix cargo dev new_lint for late lint passes

Since https://github.com/rust-lang/rust-clippy/commit/30c046ede47ea45a772d2656b0365a4807263bca, `LateLintPass` has only one lifetime parameter.

I'm not sure how to easily test this, I think adding this kind of tests would be probably part of #5394

changelog: none

3 years agoFix fp in `borrow_interior_mutable_const`
rail [Sun, 23 Aug 2020 10:16:24 +0000 (22:16 +1200)]
Fix fp in `borrow_interior_mutable_const`

Fix false positive when referencing a field behind a pointer.

3 years agoFix ICE in `repeat_once` lint
Eduardo Broto [Sun, 23 Aug 2020 10:05:34 +0000 (12:05 +0200)]
Fix ICE in `repeat_once` lint

3 years agoImprove documentation related to the sync process
Eduardo Broto [Sun, 23 Aug 2020 09:29:06 +0000 (11:29 +0200)]
Improve documentation related to the sync process

3 years agoFix cargo dev new_lint for late lint passes
Eduardo Broto [Thu, 20 Aug 2020 21:47:04 +0000 (23:47 +0200)]
Fix cargo dev new_lint for late lint passes

3 years agoFix `let_and_return` bad suggestion
Michael Wright [Sun, 23 Aug 2020 05:50:59 +0000 (07:50 +0200)]
Fix `let_and_return` bad suggestion

Add a cast to the suggestion when the return expression has adjustments.
These adjustments are lost when the suggestion is applied.

This is similar to the problem in issue #4437.

Closes #5729

3 years agoAuto merge of #5941 - ThibsG:InlineInCopyPassByRef, r=yaahc
bors [Sat, 22 Aug 2020 18:30:39 +0000 (18:30 +0000)]
Auto merge of #5941 - ThibsG:InlineInCopyPassByRef, r=yaahc

Don't lint if it has always inline attribute

Don't trigger the lint `trivially_copy_pass_by_ref` if it has `#[inline(always)]` attribute.

Note: I am not particularly familiar with `inline` impacts, so I implemented this the way that if only `#[inline]` attribute is here (without `always`), the lint will still trigger. Also, it will still trigger if it has `#[inline(never)]`.
Just tell me if it sounds too much conservative.

Fixes: #5876
changelog: none

3 years agoAuto merge of #5929 - stchris:issues/5917, r=ebroto
bors [Sat, 22 Aug 2020 12:50:22 +0000 (12:50 +0000)]
Auto merge of #5929 - stchris:issues/5917, r=ebroto

Widen understanding of prelude import

Prelude imports are exempt from wildcard import warnings. Until now only
imports of the form

```
use ...::prelude::*;
```

were considered. This change makes it so that the segment `prelude` can
show up anywhere, for instance:

```
use ...::prelude::v1::*;
```

Fixes #5917

changelog: Allow `prelude` to appear in any segment of the import path in [`wildcard_imports`]

3 years agoUse more elegant way to check for prelude string
Christian Stefanescu [Fri, 21 Aug 2020 12:03:42 +0000 (14:03 +0200)]
Use more elegant way to check for prelude string

3 years agoRun sh tests/ui/update-all-references.sh
Christian Stefanescu [Thu, 20 Aug 2020 20:54:46 +0000 (22:54 +0200)]
Run sh tests/ui/update-all-references.sh

3 years agoWiden understanding of prelude import
Christian Stefanescu [Thu, 20 Aug 2020 20:49:39 +0000 (22:49 +0200)]
Widen understanding of prelude import

Prelude imports are exempt from wildcard import warnings. Until now only
imports of the form

```
use ...::prelude::*;
```

were considered. This change makes it so that the segment `prelude` can
show up anywhere, for instance:

```
use ...::prelude::v1::*;
```

Fixes #5917

3 years agoDon't lint if it has always inline attribute
ThibsG [Sat, 22 Aug 2020 08:35:18 +0000 (10:35 +0200)]
Don't lint if it has always inline attribute

3 years agoAuto merge of #5934 - ThibsG:WrongSelfTestCase4037, r=ebroto
bors [Sat, 22 Aug 2020 06:19:42 +0000 (06:19 +0000)]
Auto merge of #5934 - ThibsG:WrongSelfTestCase4037, r=ebroto

Add async test case for FP in `wrong_self_convention` lint

Closes: #4037
changelog: none

r? @ebroto

3 years agoAdd async test case for `wrong_self_convention` lint
ThibsG [Fri, 21 Aug 2020 06:18:05 +0000 (08:18 +0200)]
Add async test case for `wrong_self_convention` lint

3 years agoAuto merge of #5926 - giraffate:improve_lint_message_in_to_string_in_display, r=yaahc
bors [Sat, 22 Aug 2020 04:51:38 +0000 (04:51 +0000)]
Auto merge of #5926 - giraffate:improve_lint_message_in_to_string_in_display, r=yaahc

Improve lint message in `to_string_in_display`

This is a follow-up of https://github.com/rust-lang/rust-clippy/pull/5831.

changelog: none

3 years agoAuto merge of #5933 - mikerite:fix-5927, r=matthiaskrgr
bors [Fri, 21 Aug 2020 23:43:20 +0000 (23:43 +0000)]
Auto merge of #5933 - mikerite:fix-5927, r=matthiaskrgr

Fix false negative in `option_as_ref_deref`

Closes #5927

changelog: Fix false negative in `option_as_ref_deref`

3 years agoAuto merge of #5938 - ebroto:sync-from-rust, r=ebroto
bors [Fri, 21 Aug 2020 23:10:59 +0000 (23:10 +0000)]
Auto merge of #5938 - ebroto:sync-from-rust, r=ebroto

Rustup

r? @ghost

changelog: none

3 years agorun cargo dev fmt
Eduardo Broto [Fri, 21 Aug 2020 22:59:42 +0000 (00:59 +0200)]
run cargo dev fmt

3 years agoMerge remote-tracking branch 'upstream/master' into sync-from-rust
Eduardo Broto [Fri, 21 Aug 2020 22:53:03 +0000 (00:53 +0200)]
Merge remote-tracking branch 'upstream/master' into sync-from-rust

3 years agoFix false negative in `option_as_ref_deref`
Michael Wright [Fri, 21 Aug 2020 05:23:04 +0000 (07:23 +0200)]
Fix false negative in `option_as_ref_deref`

3 years agoAuto merge of #5928 - mikerite:fix-5924, r=ebroto
bors [Thu, 20 Aug 2020 22:09:27 +0000 (22:09 +0000)]
Auto merge of #5928 - mikerite:fix-5924, r=ebroto

Fix false positive in `PRECEDENCE` lint

Extend the lint to handle chains of methods combined with unary negation.

Closes #5924

changelog: Fix false negative in `PRECEDENCE` lint

3 years agoAuto merge of #5919 - ebroto:5747_from_bits_in_const, r=matthiaskrgr
bors [Thu, 20 Aug 2020 10:04:46 +0000 (10:04 +0000)]
Auto merge of #5919 - ebroto:5747_from_bits_in_const, r=matthiaskrgr

transmute: avoid suggesting from/to bits in const

changelog: Avoid suggesting from/to bits in const contexts in [`transmute_int_to_float`]

Fixes #5747

3 years agoCapture tokens for Pat used in macro_rules! argument
Aaron Hill [Mon, 27 Jul 2020 22:02:29 +0000 (18:02 -0400)]
Capture tokens for Pat used in macro_rules! argument

This extends PR #73293 to handle patterns (Pat). Unlike expressions,
patterns do not support custom attributes, so we only need to capture
tokens during macro_rules! argument parsing.

3 years agoFix false positive in `PRECEDENCE` lint
Michael Wright [Thu, 20 Aug 2020 04:34:48 +0000 (06:34 +0200)]
Fix false positive in `PRECEDENCE` lint

Extend the lint to handle chains of methods combined with unary negation.

Closes #5924

3 years agoImprove lint message in `to_string_in_display`
Takayuki Nakata [Wed, 19 Aug 2020 13:31:34 +0000 (22:31 +0900)]
Improve lint message in `to_string_in_display`

3 years agono from/to bits in const: add tests cases for f64
Eduardo Broto [Tue, 18 Aug 2020 20:19:30 +0000 (22:19 +0200)]
no from/to bits in const: add tests cases for f64

3 years agotransmute: avoid suggesting from/to bits in const
Eduardo Broto [Mon, 17 Aug 2020 23:00:11 +0000 (01:00 +0200)]
transmute: avoid suggesting from/to bits in const

3 years agoAuto merge of #5922 - flip1995:rustup, r=flip1995
bors [Tue, 18 Aug 2020 17:58:40 +0000 (17:58 +0000)]
Auto merge of #5922 - flip1995:rustup, r=flip1995

Rustup

r? @ghost

changelog: none

3 years agoMerge remote-tracking branch 'upstream/master' into rustup
flip1995 [Tue, 18 Aug 2020 17:10:52 +0000 (19:10 +0200)]
Merge remote-tracking branch 'upstream/master' into rustup

3 years agoAuto merge of #75120 - JulianKnodt:rm_reps, r=oli-obk
bors [Mon, 17 Aug 2020 23:16:08 +0000 (23:16 +0000)]
Auto merge of #75120 - JulianKnodt:rm_reps, r=oli-obk

rust_ast::ast => rustc_ast

Rework of #71199 which is a rework #70621

Still working on this but just made the PR to track progress

r? @Dylan-DPC

3 years agorust_ast::ast => rustc_ast
Ujjwal Sharma [Mon, 27 Apr 2020 17:56:11 +0000 (23:26 +0530)]
rust_ast::ast => rustc_ast

3 years agoAuto merge of #5908 - giraffate:fix_fp_for_same_item_push, r=flip1995
bors [Mon, 17 Aug 2020 16:49:03 +0000 (16:49 +0000)]
Auto merge of #5908 - giraffate:fix_fp_for_same_item_push, r=flip1995

Fix FP for `same_item_push`

Fixes https://github.com/rust-lang/rust-clippy/issues/5902

changelog: Fix FP for `same_item_push` where the pushed variable is mutated.

3 years agoclippy: support `QPath::LangItem`
David Wood [Tue, 4 Aug 2020 13:24:13 +0000 (14:24 +0100)]
clippy: support `QPath::LangItem`

This commit updates clippy with the introduction of `QPath::LangItem` so
that it still compiles.

Signed-off-by: David Wood <david@davidtw.co>
3 years agoAuto merge of #5915 - matthiaskrgr:deps_, r=Manishearth
bors [Mon, 17 Aug 2020 12:23:44 +0000 (12:23 +0000)]
Auto merge of #5915 - matthiaskrgr:deps_, r=Manishearth

deps: bump cargo_metadata and semver

cargo_metadata 0.9.1 -> 0.11.1
semver 0.9.0 -> 0.10.0

changelog: none

3 years agodeps: bump cargo_metadata and semver
Matthias Krüger [Mon, 17 Aug 2020 10:19:32 +0000 (12:19 +0200)]
deps: bump cargo_metadata and semver

cargo_metadata 0.9.1 -> 0.11.1
semver 0.9.0 -> 0.10.0

3 years agoImprove code style
Takayuki Nakata [Sun, 16 Aug 2020 23:36:02 +0000 (08:36 +0900)]
Improve code style

3 years agoAuto merge of #5894 - tmiasko:self-assignment, r=Manishearth
bors [Sun, 16 Aug 2020 21:56:37 +0000 (21:56 +0000)]
Auto merge of #5894 - tmiasko:self-assignment, r=Manishearth

Warn about explicit self-assignment

Warn about assignments where left-hand side place expression is the same
as right-hand side value expression. For example, warn about assignment in:

```rust
pub struct Event {
    id: usize,
    x: i32,
    y: i32,
}

pub fn copy_position(a: &mut Event, b: &Event) {
    a.x = b.x;
    a.y = a.y;
}
```

changelog: New lint `self_assignment`, checks for explicit self-assignments.

3 years agoWarn about explicit self-assignment
Tomasz Miąsko [Sun, 16 Aug 2020 00:00:00 +0000 (00:00 +0000)]
Warn about explicit self-assignment

Warn about assignments where left-hand side place expression is the same
as right-hand side value expression. For example, warn about assignment in:

```rust
pub struct Event {
    id: usize,
    x: i32,
    y: i32,
}

pub fn copy_position(a: &mut Event, b: &Event) {
    a.x = b.x;
    a.y = a.y;
}
```

3 years agoExpresions with Assign / AssignOp have side effects
Tomasz Miąsko [Sun, 16 Aug 2020 00:00:00 +0000 (00:00 +0000)]
Expresions with Assign / AssignOp have side effects

3 years agoRename SpanlessEq::ignore_fn to deny_side_effects
Tomasz Miąsko [Sun, 16 Aug 2020 00:00:00 +0000 (00:00 +0000)]
Rename SpanlessEq::ignore_fn to deny_side_effects

No functional changes intended.

3 years agoIntroduce function for comparing expression values
Tomasz Miąsko [Sun, 16 Aug 2020 00:00:00 +0000 (00:00 +0000)]
Introduce function for comparing expression values

Introduce `eq_expr_value(cx, a, b)` as a shortcut for
`SpanlessEq::new(cx).ignore_fn().eq_expr(cx, a, b)`.

No functional changes intended.

3 years agoAuto merge of #5720 - bugadani:new-lint, r=flip1995,yaahc
bors [Sun, 16 Aug 2020 20:27:43 +0000 (20:27 +0000)]
Auto merge of #5720 - bugadani:new-lint, r=flip1995,yaahc

Add unnecessary lazy evaluation lint

changelog: Add [`unnecessary_lazy_evaluations`] lint that checks for usages of `unwrap_or_else` and similar functions that can be simplified.

Closes #5715

3 years agoRename lint to use plural form
Dániel Buga [Sun, 16 Aug 2020 20:16:39 +0000 (22:16 +0200)]
Rename lint to use plural form

3 years agoFix missed rename
Dániel Buga [Sun, 16 Aug 2020 19:33:29 +0000 (21:33 +0200)]
Fix missed rename

3 years agoAuto merge of #5913 - HactarCE:patch-1, r=flip1995
bors [Sun, 16 Aug 2020 19:27:27 +0000 (19:27 +0000)]
Auto merge of #5913 - HactarCE:patch-1, r=flip1995

Fix typo in description of unnecessary_mut_passed

changelog: Correct "immutable reference" to "mutable reference" in description of `unnecessary_mut_passed`

3 years agoFix dogfooding test errors
Dániel Buga [Sun, 16 Aug 2020 19:04:02 +0000 (21:04 +0200)]
Fix dogfooding test errors

3 years agorun cargo dev fmt
Dániel Buga [Sun, 16 Aug 2020 18:51:16 +0000 (20:51 +0200)]
run cargo dev fmt

3 years agoCleanup, explain return value
Dániel Buga [Sun, 16 Aug 2020 18:50:30 +0000 (20:50 +0200)]
Cleanup, explain return value

3 years agoMoved to submodule, don't trigger if map_unwrap_or does
Dániel Buga [Sun, 16 Aug 2020 18:47:50 +0000 (20:47 +0200)]
Moved to submodule, don't trigger if map_unwrap_or does

3 years agoFix typo in description of unnecessary_mut_passed
Hactar [Sun, 16 Aug 2020 18:43:34 +0000 (14:43 -0400)]
Fix typo in description of unnecessary_mut_passed

3 years agoApply suggested change
Dániel Buga [Sun, 26 Jul 2020 19:08:07 +0000 (21:08 +0200)]
Apply suggested change

Co-authored-by: Philipp Krones <hello@philkrones.com>
3 years agoApply suggested change
Dániel Buga [Sun, 26 Jul 2020 18:52:00 +0000 (20:52 +0200)]
Apply suggested change

Co-authored-by: Philipp Krones <hello@philkrones.com>
3 years agoRemoved the extra lifetime parameter
Dániel Buga [Sun, 26 Jul 2020 18:18:12 +0000 (20:18 +0200)]
Removed the extra lifetime parameter

3 years agoCatch function calls in argument lists, add tests that tuples don't get linted
Dániel Buga [Mon, 15 Jun 2020 18:01:18 +0000 (20:01 +0200)]
Catch function calls in argument lists, add tests that tuples don't get linted

3 years agoRun cargo dev update_lints
Dániel Buga [Mon, 15 Jun 2020 13:22:22 +0000 (15:22 +0200)]
Run cargo dev update_lints

3 years agoAlso simplify if the closure body is an index expression
Dániel Buga [Mon, 15 Jun 2020 13:26:02 +0000 (15:26 +0200)]
Also simplify if the closure body is an index expression

3 years agoAdd note to `or_fun_call`, list checked methods
Dániel Buga [Mon, 15 Jun 2020 12:55:23 +0000 (14:55 +0200)]
Add note to `or_fun_call`, list checked methods

3 years agoRename the changelog footnote as well
Dániel Buga [Mon, 15 Jun 2020 09:48:14 +0000 (11:48 +0200)]
Rename the changelog footnote as well

3 years agoImplement new lint
Dániel Buga [Mon, 15 Jun 2020 09:21:56 +0000 (11:21 +0200)]
Implement new lint

3 years agoAuto merge of #5725 - montrivo:should-impl-trait, r=flip1995
bors [Sun, 16 Aug 2020 17:51:18 +0000 (17:51 +0000)]
Auto merge of #5725 - montrivo:should-impl-trait, r=flip1995

should_impl_trait - ignore methods with lifetime params

Fixes: #5617
changelog: don't lint should_implement_trait when an `Iterator::next` case has explicit parameters

3 years agoAuto merge of #5907 - wiomoc:feature/useless-vec-max-size, r=flip1995
bors [Sun, 16 Aug 2020 17:30:12 +0000 (17:30 +0000)]
Auto merge of #5907 - wiomoc:feature/useless-vec-max-size, r=flip1995

appreciative too_large_for_stack in useless `vec!`

Fixes: #5847
changelog: Add `too_large_for_stack ` configuration option for `USELESS_VEC`