Commit graph

735 commits

Author SHA1 Message Date
Patrick José Pereira
bc27d1492d Add string_from_utf8_as_bytes linter
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
2020-11-04 21:17:46 -03:00
bors
5b52474ae6 Auto merge of #5911 - hegza:issue-568, r=ebroto
Add lint for 'field_reassign_with_default` #568

changelog: Add lint for field_reassign_with_default that checks if mutable object + field modification is used to edit a binding initialized with Default::default() instead of struct constructor.

Fixes #568

Notes:
- Checks for reassignment of one or more fields of a binding initialized with Default::default().
- Implemented using EarlyLintPass, might be future proofed better with LateLintPass.
- Does not trigger if Default::default() is used via another type implementing Default.
- This is a re-open of [PR#4761](https://github.com/rust-lang/rust-clippy/pull/4761), but I couldn't figure out how to re-open that one so here's a new one with the requested changes :S
2020-11-04 22:21:44 +00:00
bors
225ce5ff58 Auto merge of #6233 - montrivo:manual_ok_or, r=flip1995
add manual_ok_or lint

Implements partially #5923

changelog: add lint manual_ok_or
2020-11-03 16:42:59 +00:00
bors
2fe87a89c9 Auto merge of #6165 - dvermd:ref_option_ref, r=flip1995
Add lint 'ref_option_ref' #1377

This lint checks for usage of `&Option<&T>` which can be simplified as `Option<&T>` as suggested in #1377.

This WIP PR is here to get feedback on the lint as there's more cases to be handled:
* statics/consts,
* associated types,
* type alias,
* function/method parameter/return,
* ADT definitions (struct/tuple struct fields, enum variants)

changelog: Add 'ref_option_ref' lint
2020-11-03 16:21:51 +00:00
bors
a2bf404d34 Auto merge of #6101 - pitiK3U:from_iter_instead_of_collect, r=flip1995
Add lint: from_iter_instead_of_collect

Fixes #5679

This implements lint for `::from_iter()` from #5679 not the general issue (`std::ops::Add::add`, etc.).
This lint checks if expression is function call with `from_iter` name and if it's implementation of the `std::iter::FromIterator` trait.

changelog: Introduce  from_iter_instead_of_collect lint
2020-11-03 15:59:16 +00:00
Piti the little Light
9d6eedf5f2
Run cargo dev update_lints 2020-11-03 16:42:30 +01:00
Henri Lunnikivi
7b203f3da6 Implement field_reassign_with_default
- Implement `field_reassign_with_default` as a `LateLintPass`
- Avoid triggering `default_trait_access` on a span already linted by
`field_reassigned_with_default`
- Merge `default_trait_access` and `field_reassign_with_default` into
`Default`
- Co-authored-by: Eduardo Broto <ebroto@tutanota.com>
- Fixes #568
2020-10-31 15:49:58 +02:00
Eduardo Broto
f8ac1f99ef Address suggestions in PR review 2020-10-30 23:47:22 +01:00
Eduardo Broto
d958269fe5 Rename single_char_push_str to single_char_add_str 2020-10-30 23:29:44 +01:00
bors
c57d8ae515 Auto merge of #6227 - HMPerson1:collect_map, r=phansch
Add lint for replacing `.map().collect()` with `.try_for_each()`

Fixes #6208

changelog: Add `map_collect_result_unit`
2020-10-29 15:34:15 +00:00
bors
e1a2845558 Auto merge of #6226 - Urcra:master, r=flip1995
Add lint for comparing to empty slices instead of using .is_empty()

Hey first time making a clippy lint

I added the implementation of the lint the `len_zero` since it shared a lot of the code, I would otherwise have to rewrite. Just tell me if the lint should use it's own file instead

changelog: Add lint for comparing to empty slices

Fixes #6217
2020-10-29 15:12:24 +00:00
Eduardo Broto
50419118b4 Merge commit '645ef505da378b6f810b1567806d1bcc2856395f' into clippyup 2020-10-28 23:36:07 +01:00
Tim Nielens
111b9023da add manual_ok_or lint 2020-10-27 01:57:04 +01:00
dvermd
213dbf7aac clippy_lint: Add 'ref_option_ref' 2020-10-26 22:34:40 +01:00
HMPerson1
f0cf3bdca1
Add lint for replacing .map().collect() with .try_for_each() 2020-10-25 21:20:57 -04:00
Urcra
de5a6d3420 Initial implementation of comparison_to_empty 2020-10-26 00:31:25 +01:00
cgm616
312bbff696
Integrate suggestions from code review 2020-10-25 11:31:24 -04:00
Florian Hartwig
db8380c4a0 Add lint for unusually-grouped hex/binary literals 2020-10-25 09:18:38 -04:00
bors
90cb25d3f6 Auto merge of #6177 - rust-lang:manual-range-contains, r=flip1995
New lint: manual-range-contains

This fixes #1110, at least for the contains-suggesting part.

- \[x] 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`
---

changelog: new lint: manual-range-contains
2020-10-25 10:35:46 +00:00
bors
399732bf79 Auto merge of #6103 - FrancisMurillo:mut_mutex_lock, r=flip1995
Add lint for `&mut Mutex::lock`

Fixes #1765

changelog: Add lint [`mut_mutex_lock`] for `&mut Mutex::lock` and suggests using `&mut Mutex::get_mut` instead.
2020-10-25 10:16:23 +00:00
bors
6b01c39e64 Auto merge of #6181 - cgm616:undropped-manually-drops, r=flip1995
Add new lint for undropped ManuallyDrop values

Adds a new lint for the following code:

```rust
struct S;

impl Drop for S {
    fn drop(&mut self) {
        println!("drip drop");
    }
}

fn main() {
    // This will not drop the `S`!!!
    drop(std::mem::ManuallyDrop::new(S));
    unsafe {
        // This will.
        std::mem::ManuallyDrop::drop(&mut std::mem::ManuallyDrop::new(S));
    }
}
```

The inner value of a `ManuallyDrop` will not be dropped unless the proper, unsafe drop function is called on it. This lint makes sure that a user does not accidently use the wrong function and forget to drop a `ManuallyDrop` value.

Fixes #5581.

---

*Please keep the line below*
changelog: none
2020-10-25 09:37:09 +00:00
Francis Murillo
f82f9c2c55 Add lint for &mut Mutex::lock 2020-10-25 17:18:52 +08:00
bors
e0e617adaa Auto merge of #6109 - patrickelectric:single_element_for_check, r=flip1995
Add linter for a single element for loop

changelog: Fixes #1540, check for vectors that contain a single element in a for loop
2020-10-25 09:15:55 +00:00
bors
a675778cfb Auto merge of #6029 - Daniel-B-Smith:refcell_ref_await, r=flip1995
Add lint for holding RefCell Ref across an await

Fixes #6008

This introduces the lint await_holding_refcell_ref. For async functions, we iterate
over all types in generator_interior_types and look for `core::cell::Ref` or `core::cell::RefMut`. If we find one then we emit a lint.

Heavily cribs from: https://github.com/rust-lang/rust-clippy/pull/5439

changelog: introduce the await_holding_refcell_ref lint
2020-10-25 08:54:27 +00:00
Cauê Baasch de Souza
e8731a926c Add large_types_passed_by_value lint
Refactor trivially_copy_pass_by_ref and the new lint into pass_by_ref_or_value module

Update stderr of conf_unknown_key test

Rename lint to large_types_passed_by_value

Increase `pass_by_value_size_limit` default value to 256

Improve rules for `large_types_passed_by_value`

Improve tests for `large_types_passed_by_value`

Improve documentation for `large_types_passed_by_value`

Make minor corrections to pass_by_ref_or_value.rs suggested by clippy itself

Fix `large_types_passed_by_value` example and improve docs

pass_by_ref_or_value: Tweak check for mut annotation in params

large_types_passed_by_value: add tests for pub trait, trait impl and inline attributes
2020-10-24 14:46:56 -03:00
Eduardo Broto
cdb555f4fc Merge commit 'bf1c6f9871f430e284b17aa44059e0d0395e28a6' into clippyup 2020-10-23 22:16:59 +02:00
Andre Bogus
c693de350a New lint: manual-range-contains 2020-10-22 08:45:21 +02:00
cgm616
4a4f998c39 Add new lint for undropped ManuallyDrop values 2020-10-21 21:21:11 -04:00
Daniel Smith
070a751d4c update_lints 2020-10-21 11:04:26 -04:00
Patrick José Pereira
ec23db9496 Add linter for a single element for loop
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
2020-10-19 09:53:35 -03:00
Tim Nielens
6d4eeeabcd manual-unwrap-or / pr remarks 2020-10-14 22:16:48 +02:00
Tim Nielens
07b2da884c add lint less_concise_than_option_unwrap_or 2020-10-14 22:16:48 +02:00
Andre Bogus
6021c23159 New lint: result-unit-err 2020-10-11 22:04:59 +02:00
bors
947516f018 Auto merge of #6130 - Ambroisie:lint-ptr-eq, r=Manishearth
New lint: Recommend using `ptr::eq` when possible

This is based almost entirely on the code available in the previous PR #4596. I merely updated the code to make it compile.

Fixes #3661.

- [ ] I'm not sure about the lint name, but it was the one used in the original PR.
- [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`

---

changelog: none
2020-10-09 16:46:09 +00:00
flip1995
fbf2430f02 Merge commit '2f6439ae6a6803d030cceb3ee14c9150e91b328b' into clippyup 2020-10-09 12:45:29 +02:00
Bruno BELANYI
aa7c42f756 fixup! New lint: Recommend using ptr::eq when possible
Add missing modified files.
2020-10-07 11:54:09 +02:00
Eduardo Broto
13781ae2f8 Remove "thanks" section 2020-10-06 00:09:45 +02:00
Eduardo Broto
c5f17002e5 Add changelog for 1.48 beta 2020-10-05 17:03:24 +02:00
Dániel Buga
998bd3b6b4 Rename lint to invisible_characters 2020-10-03 00:03:33 +02:00
Jethro Beekman
0690f9c5d5 Add lint for inline assembly syntax style preference 2020-09-30 09:43:46 +02:00
Frank
1479c18396 add disallowed_method lint 2020-09-25 11:09:04 -05:00
flip1995
d1f9cad102 Merge commit 'e636b88aa180e8cab9e28802aac90adbc984234d' into clippyup 2020-09-24 14:49:22 +02:00
bors
e636b88aa1 Auto merge of #6044 - rschoon:rc-buffer, r=yaahc
Add `rc_buffer` lint for checking Rc<String> and friends

Fixes #2623

This is a bit different from the original PR attempting to implement this type of lint.   Rather than linting against converting into the unwanted types, this PR lints against declaring the unwanted type in a struct or function definition.

I'm reasonably happy with what I have here, although I used the fully qualified type names for the Path and OsString suggestions, and I'm not sure if I should have just used the short versions instead, even if they might not have been declared via use.

Also, I don't know if "buffer type" is the best way to put it or not.  Alternatively I could call it a "growable type" or "growable buffer type", but I was thinking of PathBuf when I started making the lint.

changelog: Add `rc_buffer` lint
2020-09-23 18:35:08 +00:00
Michael Wright
8b04c2d6e8 Merge branch 'master' into lint-5734 2020-09-15 21:21:35 +02:00
Robin Schoonover
1b5317f68b Add rc_buffer lint for Rc<String> and other buffer types 2020-09-14 17:08:14 -06: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
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
flip1995
a12828a80a Merge commit '5034d47f721ff4c3a3ff2aca9ef2ef3e1d067f9f' into clippyup 2020-09-10 17:47:07 +02: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
Vali Schneider
f90b1fc063 cargo dev update-lints 2020-09-09 14:06:11 -07:00
Vali Schneider
3550568a54 removing if chain and renaming lint 2020-09-09 14:02:34 -07: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
flip1995
282c59820b Merge commit '3d0b0e66afdfaa519d8855b338b35b4605775945' into clippyup 2020-08-28 18:43:25 +02: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
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
Eduardo Broto
baf62e7a38 Update changelog to beta 1.47 2020-08-27 14:48:07 +02: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
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
923d61222c Rename the changelog footnote as well 2020-08-16 20:27:22 +02:00
Dániel Buga
a3ea65c2d9 Implement new lint 2020-08-16 20:27:22 +02: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
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
flip1995
027780ca2c Merge commit '09bd400243ed6f7059fedc0c1623aae3792521d6' into clippyup 2020-08-11 17:50:45 +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
robojumper
82c816ee02
Fix CHANGELOG's commit range links
Two most recent links linked to the wrong range

changelog: none
2020-08-10 17:45:04 +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
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
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
94c50bc8c9
Lint duplicate methods of trait bounds
Fixes #5777
2020-07-28 16:42:26 +02: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
flip1995
aba0d244d4
Typo: Change Log -> Changelog 2020-07-16 15:40:13 +02:00
flip1995
cf383cf48a
Update changelog to beta-1.46 2020-07-16 15:36:53 +02:00
Matthias Krüger
126790999a new lint: Returning unit from closures expecting Ord
This lint catches cases where the last statement of a closure expecting
an instance of Ord has a trailing semi-colon. It compiles since the
closure ends up return () which also implements Ord but causes
unexpected results in cases such as sort_by_key.

Fixes #5080

reprise: rebase, update and address all concerns
2020-07-14 15:54:04 +02:00
flip1995
6f25adbd5a Merge commit '2ca58e7dda4a9eb142599638c59dc04d15961175' into clippyup 2020-07-14 14:59:59 +02:00
bors
12df6384b9 Auto merge of #5773 - giraffate:repeat_once, r=flip1995
Add a lint for `.repeat(1)`

changelog: New lint `repeat_once`

fix #3028.
2020-07-14 09:13:58 +00:00
Takayuki Nakata
5307cb5614 Add a lint for .repeat(1)
fix #3028.
2020-07-07 23:13:39 +09:00
robojumper
2e8a1be444 new lint: match_like_matches_macro 2020-07-06 18:25:20 +02:00
JarredAllen
ccb999851a Fix compile error from library change 2020-07-03 16:50:45 -07:00
JarredAllen
93f0f5d37b Last few tweaks 2020-07-03 16:50:45 -07:00
JarredAllen
bf48a2d50d Lint for if let Some(x) = ... instead of Option::map_or 2020-07-03 16:47:38 -07:00
Robert Sedlacek
c3c402783f Added restriction lint: pattern-type-mismatch 2020-07-03 18:12:29 +02:00
Eduardo Broto
814349f941 Lint enabling the whole restriction group 2020-06-30 21:56:19 +02:00
Teddy_Wang
40ee620e51 Added a lint for .map(|x| x) 2020-06-13 10:08:12 -04:00
Lzu Tao
8db24840f7 Merge commit 'ff0993c5e9162ddaea78e83d0f0161e68bd4ea73' into clippy 2020-06-09 14:36:01 +00:00
Mazdak Farrokhzad
7b6dc7b33d
add unnested_or_patterns lint 2020-06-07 21:09:47 +02:00
bors
6fc9939893 Auto merge of #5671 - ebroto:changelog_144_145, r=flip1995
Update changelog for stable:1.44 beta:1.45

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

changelog: none
2020-06-05 12:52:23 +00:00
Eduardo Broto
dcd4806782 Apply suggestions from PR review 2020-06-02 20:45:57 +02:00
bors
f760d77bdb Auto merge of #5597 - esamudera:slice_iter_next, r=flip1995
New lint: iter_next_slice

Hello, this is a work-in-progress PR for issue: https://github.com/rust-lang/rust-clippy/issues/5572

I have implemented lint to replace `iter().next()` for `slice[index..]` and `array` with `get(index)` and `get(0)` respectively. However since I made a lot of changes, I would like to request some feedback before continuing so that I could fix mistakes.

Thank you!

---

changelog: implement `iter_next_slice` lint and test, and modify `needless_continues`, `for_loop_over_options_result` UI tests since they have `iter().next()`
2020-06-02 11:42:22 +00:00
Eduardo Broto
a44fa387ef Update documentation on changelog updates 2020-06-01 20:30:20 +02:00
Eduardo Broto
6955420ace Update changelog for stable:1.44 beta:1.45 2020-06-01 09:19:54 +02:00
JarredAllen
b89880a30c Ran update_lints 2020-05-31 15:19:31 -07:00
Ericko Samudera
32fde0b511 New lint: iter_next_slice 2020-06-01 03:08:51 +07:00
JarredAllen
7e843515d9 Created lint 2020-05-31 11:55:45 -07:00
Tim Nielens
5faab874f9 new lint: vec_resize_to_zero 2020-05-30 17:52:10 +02:00
flip1995
a0e9f9bd0d Merge commit '7ea7cd165ad6705603852771bf82cc2fd6560db5' into clippyup2 2020-05-28 15:45:24 +02:00
bors
cafa94662c Auto merge of #5582 - vtmargaryan:match_wildcard_for_single_variants, r=flip1995
New lint: `match_wildcard_for_single_variants`

changelog: Added a new lint match_wildcard_for_single_variants to warn on enum matches where a wildcard is used to match a single variant

Closes #5556
2020-05-20 12:51:28 +00:00
flip1995
f1d3086492 Merge commit 'e214ea82ad0a751563acf67e1cd9279cf302db3a' into clippyup 2020-05-17 17:36:26 +02:00
bors
e214ea82ad Auto merge of #5568 - ThibsG:RenameIdentityConversionLint, r=flip1995
Rename lint `identity_conversion` to `useless_conversion`

Lint name `identity_conversion` was misleading, so this PR renames it to `useless_conversion`.

As decision has not really came up in the issue comments, this PR will probably need discussion.

fixes #3106

changelog: Rename lint `identity_conversion` to `useless_conversion`
2020-05-17 11:29:04 +00:00
Aleksei Latyshev
07f1edf2d4
improve and generalize option_and_then_some lint
- rename it to bind_instead_of_map
2020-05-17 12:17:03 +03:00
ThibsG
e55b920970 Rename lint identity_conversion to useless_conversion 2020-05-16 22:50:20 +02:00
ThibsG
ab87f87ba0 Fix CHANGELOG.md and lint names plural 2020-05-15 18:27:11 +02:00
ThibsG
93386563f6 Rename lint map_unwrap to map_unwrap_or and register lints as renamed 2020-05-15 09:17:39 +02:00
Vardan Margaryan
94e4b5ec31 Add the redundant_wildcard_enum_match lint 2020-05-14 22:36:46 +03:00
ThibsG
adbdf7549c Merge for_loop_over_option and for_loop_over_result lints into for_loop_over_fallible lint 2020-05-14 16:01:07 +02:00
ThibsG
0e8be599cd Merge option_expect_used and result_expect_used lints into expect_used lint 2020-05-14 16:01:07 +02:00
ThibsG
bcf61666bd Merge option_unwrap_used and result_unwrap_used lints into unwrap_used lint 2020-05-14 16:01:07 +02:00
ThibsG
6cbdd1e49d Merge option_map_unwrap_or, option_map_unwrap_or_else and result_map_unwrap_or_else lints into map_unwrap lint 2020-05-14 15:56:17 +02:00
ThibsG
945c944709 Merge block_in_if_condition_expr and block_in_if_condition_stmt lints into block_in_if_condition lint 2020-05-14 15:56:17 +02:00
Eduardo Broto
0f2b1193f9 Remove reverse_range_loop lint 2020-05-13 20:33:32 +02:00
Eduardo Broto
8ffa0bfaa2 New lint: reversed_empty_ranges 2020-05-13 20:33:32 +02:00
flip1995
d13d8987b0 Merge commit '43a1777b89cf6791f9e20878b4e5e3ae907867a5' into clippyup 2020-05-11 20:23:47 +02:00
Eduardo Broto
3b58d66b22 Add the manual_async_fn lint 2020-05-07 21:42:40 +02:00
Eduardo Broto
f072ded3bf Implement the manual_non_exhaustive lint 2020-05-01 02:10:16 +02:00
bors
d13ffbe3fe Auto merge of #5522 - CrazyRoka:match_vec_item, r=phansch
New  lint `match_vec_item`

Added new lint to warn a match on index item which can panic. It's always better to use `get(..)` instead.
Closes #5500
changelog: New lint `match_on_vec_items`
2020-04-27 06:02:05 +00:00
Eduardo Broto
149f6d6046 Implement mismatched_target_os lint 2020-04-26 21:27:29 +02:00
CrazyRoka
63b451ea25 Renamed lint to match_on_vec_items 2020-04-25 11:34:16 +03:00
CrazyRoka
96e2bc80f5 Added lint match_vec_item 2020-04-24 22:45:15 +03:00
bors
a609a9eb79 Auto merge of #5498 - phansch:update_changelog, r=flip1995
Update CHANGELOG.md for Rust 1.43 and 1.44

[Rendered](https://github.com/phansch/rust-clippy/blob/update_changelog/CHANGELOG.md)

changelog: none
2020-04-23 18:35:22 +00:00
Andy Weiss
6c25c3c381 Lint for holding locks across await points
Fixes #4226

This introduces the lint await_holding_lock. For async functions, we iterate
over all types in generator_interior_types and look for types named MutexGuard,
RwLockReadGuard, or RwLockWriteGuard. If we find one then we emit a lint.
2020-04-21 21:07:43 -07:00
Philipp Hansch
30c28a796d
Also mention --fix for nightly users 2020-04-21 07:06:44 +02:00
Philipp Hansch
803670eeb2
Address review comments 2020-04-20 22:53:00 +02:00
Philipp Hansch
ca59ff2031
remark fixes 2020-04-20 22:29:27 +02:00
Philipp Hansch
4e63faa6df
Update CHANGELOG.md for Rust 1.43 and 1.44 2020-04-20 22:22:05 +02:00
bors
6ce05bf849 Auto merge of #5332 - DevinR528:if-let-else-mutex, r=flip1995
If let else mutex

changelog: Adds lint to catch incorrect use of `Mutex::lock` in `if let` expressions with lock calls in any of the blocks.

closes: #5219
2020-04-20 20:21:33 +00:00
Devin R
001a42e632 progress work on suggestion for auto fix 2020-04-20 06:29:59 -04:00
Eduardo Broto
00b4f2819f Implement unsafe_derive_deserialize lint 2020-04-19 23:26:17 +02:00
pmk21
7c52e51d79 Added basic lint and tests 2020-04-18 11:39:54 +05:30
Roland Kuhn
d2cbbff217 add lint futures_not_send 2020-04-17 13:54:05 +02:00
Philipp Krones
ceea3c6a35
Rollup merge of #5248 - ThibsG:ConstValues, r=flip1995
Add lint on large non scalar const

This PR adds the new lint `non_scalar_const` that aims to warn against `const` declaration of large arrays. For performance, because of inlining, large arrays should be preferably declared as `static`.

Note: i made this one to warn on all const arrays, whether they are in a body function or not. I don't know if this is really necessary, i could just reduce this lint to variables out of function scope.

Fixes: #400

changelog: add new lint for large non-scalar types declared as const
2020-04-15 20:12:28 +02:00
ThibsG
72b9ae2a10 Use only check_expr with parent expr and precedence 2020-04-15 17:18:12 +02:00
ThibsG
6b4ab82746 Global rework + fix imports 2020-04-15 17:18:12 +02:00
ThibsG
380f7218b3 Add lint on large const arrays 2020-04-09 09:09:39 +02: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
Jacek Pospychala
f8e892db5e useless Rc<Rc<T>>, Rc<Box<T>>, Rc<&T>, Box<&T> 2020-04-02 00:02:25 +02:00
Tomasz Miąsko
b77b219280 Lint unnamed address comparisons 2020-03-30 21:42:16 +02:00
bors
d3989eef2d Auto merge of #5319 - 1tgr:master, r=flip1995
Lint for `pub(crate)` items that are not crate visible due to the visibility of the module that contains them

changelog: Add `redundant_pub_crate` lint

Closes #5274.
2020-03-23 20:35:49 +00:00
flip1995
552768f092
Update changelog to 1.43.0 beta 2020-03-18 14:55:44 +01:00
Tim Robinson
52208f3cf3 Lint for pub(crate) items that are not crate visible due to the visibility of the module that contains them
Closes #5274.
2020-03-16 12:21:00 +00:00
flip1995
7b08c7a36e
Change changelog formatting 2020-03-12 21:02:15 +01:00
flip1995
da29402d2e
Update CHANGELOG.md 2020-03-12 21:01:19 +01:00
Jacob Meyers
0f7f30711e add lint on File::read_to_string and File::read_to_end 2020-03-06 09:50:49 -05:00
flip1995
57393b5106
Rename macro_use_import -> macro_use_imports 2020-03-05 19:22:17 +01:00
Devin R
597e02dcdf warn on macro_use attr 2020-03-04 09:36:02 -05:00
ThibsG
2aa14c9beb Add restrictive pat use in full binded struct 2020-03-04 09:11:07 +01:00
Krishna Sai Veera Reddy
ff0d44e45a Add imprecise_flops lint
Add lint to detect floating point operations that can be computed more
accurately at the cost of performance. `cbrt`, `ln_1p` and `exp_m1`
library functions call their equivalent cmath implementations which is
slower but more accurate so moving checks for these under this new lint.
2020-02-23 22:36:15 -08:00
Krishna Sai Veera Reddy
4065ca9c8c Move manual_mul_add into suboptimal_flops lint 2020-02-23 22:20:34 -08:00
Krishna Sai Veera Reddy
6dacb1aa67 Change lint name to suboptimal_flops 2020-02-23 22:20:34 -08:00
Krishna Veera Reddy
1f4f357bf5 Consolidate the accuracy and efficiency lints
Merge the accuracy and efficiency lints into a single lint that
checks for improvements to accuracy, efficiency and readability
of floating-point expressions.
2020-02-23 22:20:33 -08:00
Krishna Veera Reddy
c636c6a55b Add lints to detect inaccurate and inefficient FP operations
Add lints to detect floating point computations that are either
inaccurate or inefficient and suggest better alternatives.
2020-02-23 22:20:33 -08:00
flip1995
4229dbcf33
Run update_lints 2020-02-21 11:14:16 +01:00
Krishna Sai Veera Reddy
219c94d028 Separate out lint to check lossy whole number float literals 2020-02-20 22:33:36 -08:00
flip1995
757bbf7feb
Fix markdown Files
Rendered:

[CHANGELOG.md](https://github.com/flip1995/rust-clippy/blob/gha/CHANGELOG.md)
[CODE_OF_CONDUCT.md](https://github.com/flip1995/rust-clippy/blob/gha/CODE_OF_CONDUCT.md)
[CONTRIBUTING.md](https://github.com/flip1995/rust-clippy/blob/gha/CONTRIBUTING.md)
[README.md](https://github.com/flip1995/rust-clippy/blob/gha/README.md)
[clippy_dummy/PUBLISH.md](https://github.com/flip1995/rust-clippy/blob/gha/clippy_dummy/PUBLISH.md)
[doc/adding_lints.md](https://github.com/flip1995/rust-clippy/blob/gha/doc/adding_lints.md)
[etc/relicense/RELICENSE_DOCUMENTATION.md](https://github.com/flip1995/rust-clippy/blob/gha/etc/relicense/RELICENSE_DOCUMENTATION.md)
2020-02-12 09:34:25 +01:00
Krishna Sai Veera Reddy
be1bc571c3 Add option-env-unwrap lint 2020-02-08 16:44:35 -08:00
Areredify
338fb7a3e9 add excessive bools lints 2020-02-05 20:54:58 +03:00
ThibsG
6afd7ea147 Use span_lint_and_sugg + move infaillible lint
- moving infaillible lint to prevent collisions
2020-02-04 22:49:08 +01:00
flip1995
1ef4509eb4
Update changelog 2020-01-30 23:34:07 +01:00
Mikhail Babenko
d1f8621711 add lint 2020-01-30 16:48:56 +03:00
xiongmao86
512efbea23 Declare lint and implement lint logic. 2020-01-30 00:21:29 +08:00
Areredify
796958c7e2 add option_as_ref_deref lint 2020-01-23 16:12:16 +03:00
Yuki Okushi
95c369fa91 Add skip_while_next lint 2020-01-20 10:56:02 +09:00
xiongmao86
96334d0d7c Declare lint. 2020-01-12 19:54:17 +08:00
ThibsG
8ae8b08e32 Change lint name to WILDCARD_IN_OR_PATTERNS 2020-01-07 18:48:16 +01:00
ThibsG
96c4198832 New lint: pats_with_wild_match_arm
- Wildcard use with other pattern in same match arm
2020-01-07 18:48:16 +01:00
Krishna Sai Veera Reddy
9e6a6069a7 Add lint to detect usage of invalid atomic ordering
Detect usage of invalid atomic ordering modes such as
`Ordering::{Release, AcqRel}` in atomic loads and
`Ordering::{Acquire, AcqRel}` in atomic stores.
2020-01-06 16:39:31 -08: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
Krishna Veera Reddy
8db319f957 Use mem::take instead of mem::replace when applicable
`std::mem::take` can be used to replace a value of type `T`
with `T::default()` instead of `std::mem::replace`.
2019-12-31 09:22:34 -08:00
mgr-inz-rafal
f191e916bd Add new lint (modulo_arithmetic) 2019-12-28 16:46:08 +01:00
bors
1837cbce6c Auto merge of #4885 - rust-lang:mut-key-types, r=flip1995
new lint: mutable_key_type

This fixes #732 - well, partly, it doesn't adress `Hash` impls, but the use of mutable types as map keys or set members

changelog: add `mutable_key_type` lint

r? @flip1995
2019-12-24 13:32:45 +00:00
Andre Bogus
40435acf3d new lint: mutable_key_type 2019-12-24 13:46:19 +01:00
bors
143ad5e2d1 Auto merge of #4911 - phansch:update_changelog, r=flip1995
Update changelog for Rust 1.39 and 1.40

[Rendered](https://github.com/phansch/rust-clippy/blob/update_changelog/CHANGELOG.md)

changelog: none
2019-12-23 16:06:56 +00:00
Philipp Hansch
b1a5d25221
Fix two commit hashes in changelog 2019-12-23 07:08:09 +01:00
Mikhail Babenko
a310cb2d0b implemented let_underscore lint
actually add files

update lints

change to pedantic
2019-12-22 22:10:25 +03:00
Philipp Hansch
123ecac655
Update changelog for Rust 1.39 and 1.40 2019-12-18 21:28:52 +01:00
Krishna Veera Reddy
c77fc06d52 Add lint to detect transmutes from float to integer
Add lint that detects transmutation from a float to an integer
and suggests usage of `{f32, f64}.to_bits()` instead.
2019-12-07 16:33:49 -08:00
RobbieClarken
f5d0a452ba Add lint for pub fns returning a Result without documenting errors
The Rust Book recommends that functions that return a `Result` type have
a doc comment with an `# Errors` section describing the kind of errors
that can be returned
(https://doc.rust-lang.org/book/ch14-02-publishing-to-crates-io.html#commonly-used-sections).
This change adds a lint to enforce this. The lint is allow by default;
it can be enabled with `#![warn(clippy::missing_errors_doc)]`.

Closes #4854.
2019-12-06 17:19:05 +10:30
Mikhail Babenko
9ec8888b91 implemented as_conversions lint
actuall add files

add better example and change pedantic to restriction
2019-11-25 18:12:52 +03:00
flip1995
9b4faf97f3
Run update_lints 2019-11-23 17:57:28 +01:00
flip1995
7db973d06f
Merge remote-tracking branch 'FlorianRohm/issue/4623' into rollup-new-lints 2019-11-23 17:56:13 +01:00
flip1995
353668ee6c
Merge remote-tracking branch 'Areredify/large_stack_arrays' into rollup-new-lints 2019-11-23 17:55:10 +01:00
flip1995
213765a1d3
Merge remote-tracking branch 'popzxc/if-same-cond-fn' into rollup-new-lints 2019-11-23 17:54:26 +01:00
Igor Aleksanov
bbb8cd4fbb Implement if_same_cond_fn lint
Run ./util/dev

Revert changelog entry

Rename lint to same_functions_in_if_condition and add a doc example

Add testcases with different arg in fn invocation
2019-11-20 06:54:46 +03:00
Andre Bogus
c21b198576 New lint: zst_offset 2019-11-15 22:39:27 +01:00
Florian Rohm
73806b72a9 register new lint "tabs in doc comments" and update readme 2019-11-15 16:26:30 +01:00
Areredify
7fddac0404 Add new lint: large stack array
added documentation

minor style fix

change as to ::from

add ignore to doc

include threshold in lint message/make suggestion more apparent/use Scalar api instead of matching

style fix

shange snippet_opt to snippet
2019-11-13 21:44:29 +03:00
Michael Wright
5817a4fa06 Add to_digit_is_some lint 2019-11-10 15:52:59 +02:00
Heinz N. Gies
60c2fdd0b9 Update lints 2019-11-07 17:10:18 +01:00
Marcel Hellwig
5572476a36 Add lint for debug_assert_with_mut_call
This lint will complain when you put a mutable function/method call
inside a `debug_assert` macro, because it will not be executed in
release mode, therefore it will change the execution flow, which is not
wanted.
2019-10-22 10:39:55 +02:00