Commit graph

1402 commits

Author SHA1 Message Date
bors
44d6439bfd Auto merge of #6025 - thomcc:compare_exchange_atomics, r=flip1995
Extend invalid_atomic_ordering for compare_exchange{,_weak} and fetch_update

changelog: The invalid_atomic_ordering lint can now detect misuse of `compare_exchange`, `compare_exchange_weak`, and `fetch_update`.

---

I was surprised not to find an issue or existing support here, since these are the functions which are always hardest to get the ordering right on for me (as the allowed orderings for `fail` depend on the `success` parameter).

I believe this lint now covers all atomic methods which care about their ordering now, but I could be wrong.

Hopefully I didn't forget to do anything for the PR!
2020-09-16 18:33:38 +00:00
Michael Wright
8b04c2d6e8 Merge branch 'master' into lint-5734 2020-09-15 21:21:35 +02:00
bors
f82e84c894 Auto merge of #5998 - deg4uss3r:master, r=yaahc
Add map_err_ignore lint

In a large code base a lot of times errors are ignored by using something like:

```rust
foo.map_err(|_| Some::Enum)?;
```

This drops the original error in favor of a enum that will not have the original error's context. This lint helps catch throwing away the original error in favor of an enum without its context.

---

*Please keep the line below*
changelog: Added map_err_ignore lint
2020-09-14 19:56:47 +00:00
Michael Wright
d1f0f04a48 New lint: manual-strip
Add a new lint, `manual-strip`, that suggests using the `str::strip_prefix`
and `str::strip_suffix` methods introduced in Rust 1.45 when the same
functionality is performed 'manually'.

Closes #5734
2020-09-14 06:11:35 +02:00
Takayuki Nakata
9ff7e5d984 Downgrade verbose_bit_mask to pedantic 2020-09-13 23:23:45 +09:00
bors
0ab75c37b6 Auto merge of #5977 - xvschneider:AddLintPanicInResult, r=matthiaskrgr
Add lint panic in result

### Change
Adding a new "restriction" lint that will emit a warning when using "panic", "unimplemented" or "unreachable" in a function of type option/result.

### Motivation
Some codebases must avoid crashes at all costs, and hence functions of type option/result must return an error instead of crashing.

### Test plan
Running:
TESTNAME=panic_in_result cargo uitest ---

changelog: none
2020-09-10 16:22:20 +00:00
bors
5034d47f72 Auto merge of #5980 - matsujika:create-dir, r=flip1995
Add a lint to prevent `create_dir` from being used

This closes #5950
changelog: none
2020-09-10 14:34:22 +00:00
Thom Chiovoloni
61671a2268 Detect fetch_update misuse in invalid_atomic_ordering too 2020-09-09 14:15:54 -07:00
Vali Schneider
3550568a54 removing if chain and renaming lint 2020-09-09 14:02:34 -07:00
Ricky
d719b48543 Move map_err_ignore from style to pedantic 2020-09-08 19:37:14 -04:00
Ricky
337729137b Ran cargo dev update_lints 2020-09-01 17:05:40 -04:00
Kyle Huey
4972989b61 Add a lint for an async block/closure that yields a type that is itself awaitable.
This catches bugs of the form

tokio::spawn(async move {
    let f = some_async_thing();
    f // Oh no I forgot to await f so that work will never complete.
});
2020-08-29 15:33:54 -07:00
Hirochika Matsumoto
5574182b4d Add a new lint to prevent create_dir from being used 2020-08-28 18:45:28 +09:00
Vali Schneider
b006522393 added lint for todo and removed option 2020-08-27 16:55:23 -07:00
Vali Schneider
b2d8ca9a76 ran cargo dev update lints 2020-08-27 16:30:49 -07:00
Vali Schneider
459969f88f added restriction lint that prohibits the usage of unimplemented, unreachable or panic in a function of type result or option 2020-08-27 16:18:05 -07:00
Jane Lusby
91024f1fde Add new lint to prevent usage of unwrap in fns that return result 2020-08-26 16:31:49 -07:00
Bastian
680c68153b Added a lint which corrects expressions like (a - b) < f32::EPSILON 2020-08-24 16:31:51 +02:00
Takayuki Nakata
902b28275e Improve lint message in to_string_in_display 2020-08-19 22:31:34 +09:00
Tomasz Miąsko
4f4abf4e06 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;
}
```
2020-08-16 23:31:36 +02:00
Dániel Buga
fc1e07e0c1 Rename lint to use plural form 2020-08-16 22:16:39 +02:00
Dániel Buga
d7220dbd91 Run cargo dev update_lints 2020-08-16 20:27:54 +02:00
Dániel Buga
a3ea65c2d9 Implement new lint 2020-08-16 20:27:22 +02:00
bors
dff7e74b27 Auto merge of #5903 - jrqc:needless_return, r=ebroto,flip1995
Needless return

Fixes #5858
changelog: fix false positive [`needless_return`]
2020-08-16 17:08:45 +00:00
bors
c8e05fc1c6 Auto merge of #5881 - wiomoc:feature/single-char-push_str, r=ebroto,flip1995
Lint `push_str` with a single-character string literal

Fixes #5875
changelog:  `* [single_char_push_str]`
2020-08-16 16:41:57 +00:00
jrqc
96efaee552 cargo dev update_lints 2020-08-16 00:24:27 +03:00
jrqc
6d18fe730e Make needless_return a late lint pass 2020-08-16 00:24:27 +03:00
Christoph Walcher
ae56e988a2
Merge lint with single_char_pattern 2020-08-15 01:40:55 +02:00
Christoph Walcher
72d2c2eab4
Lint push_str with a single-character string literal
Fixes #5875
2020-08-15 01:40:55 +02:00
chansuke
8e549978e5 Don't use to_string in impl Display 2020-08-14 21:38:11 +09:00
Matthias Krüger
be3e695b60 if_not_else: make lint adhere to lint message convention 2020-08-11 16:43:53 +02:00
bors
09bd400243 Auto merge of #5891 - flip1995:rustup, r=flip1995
Rustup

r? @ghost

Sync back rust-lang/rust#75098

changelog: none
2020-08-11 12:32:10 +00:00
Matthias Krüger
f59ec1945f run cargo dev update-lints 2020-08-10 23:57:08 +02:00
Philipp Krones
8ee57eed79
Rollup merge of #5869 - wiomoc:feature/implicit-self, r=ebroto,flip1995
New lint against `Self` as an arbitrary self type

Fixes #5861

changelog: * [`needless_arbitrary_self_type`] [#5869](https://github.com/rust-lang/rust-clippy/pull/5869)
2020-08-10 14:56:26 +02:00
Philipp Krones
9da5b6d1d0
Rollup merge of #5825 - giraffate:same_item_push, r=Manishearth
Add the new lint `same_item_push`

changelog: Add the new lint `same_item_push`

Fixed #4078. As I said in https://github.com/rust-lang/rust-clippy/issues/4078#issuecomment-658184195, I referrerd to https://github.com/rust-lang/rust-clippy/pull/4647.
2020-08-10 14:56:25 +02:00
Christoph Walcher
d635b76eaf
adopt comments from review 2020-08-07 18:08:51 +02:00
Christoph Walcher
e0a4988fcc
Lint against Self as an arbitrary self type
Fixes #5861
2020-08-07 18:08:51 +02:00
Ryan1729
0d2a378547 run clippy_dev update_lints 2020-08-06 06:11:23 -06:00
Ryan1729
5e84b8c2fb run cargo dev new_lint then move transmutes_expressible_as_ptr_casts into transmute module 2020-08-06 04:24:24 -06:00
bors
2d4c3379d3 Auto merge of #5809 - JarredAllen:stable_sort_primitive, r=Manishearth
Stable sort primitive

changelog: Implements #5762
2020-08-05 20:41:21 +00:00
Takayuki Nakata
1543e117cc cargo dev update_lints 2020-08-05 22:51:38 +09:00
Takayuki Nakata
1e8ada3cab Add lint same_item_push 2020-08-05 22:51:38 +09:00
Philipp Krones
84455b211f
Rollup merge of #5852 - wiomoc:feature/lint-duplicate-trait, r=Manishearth
Add lint for duplicate methods of trait bounds

rel: #5777

changelog: Add [`trait_duplication_in_bounds`] lint
2020-08-04 12:06:41 +02:00
JarredAllen
25abd7ae76 Create stable_sort_primitive lint 2020-08-03 11:17:43 -07:00
Christoph Walcher
2b7fde6a4b
typo fix 2020-07-29 16:10:15 +02:00
Christoph Walcher
94c50bc8c9
Lint duplicate methods of trait bounds
Fixes #5777
2020-07-28 16:42:26 +02:00
Ryan1729
94b10a6e5a run cargo dev update_lints 2020-07-27 00:31:09 -06:00
Ryan1729
fc20ee63a1 move derive_ord_xor_partial_ord into derive mod so we can reuse derive_hash_xor_partial_eq code later 2020-07-26 20:54:04 -06:00
Ryan1729
5a644964fc run cargo dev new_lint
specifically:
cargo dev new_lint --name derive_ord_xor_partial_ord --category correctness --pass late
2020-07-26 20:40:57 -06:00
flip1995
d164ab65f7 Merge commit 'da5a6fb1b65ec6581a67e942a3850f6bc15a552c' into clippyup 2020-07-26 21:07:07 +02:00