Commit Graph

9729 Commits

Author SHA1 Message Date
Francis Murillo
f82f9c2c55 Add lint for &mut Mutex::lock 2020-10-25 17:18:52 +08: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
bors
b06856eae0 Auto merge of #6187 - geoffreycopin:master, r=ebroto
Lint unnecessary int-to-int and float-to-float casts

This is an implementation of a lint that detects unnecessary casts of number literals, as discussed here:
https://github.com/rust-lang/rust-clippy/issues/6116

---

changelog: lint unnecessary as-casts of literals when they could be written using literal syntax.
2020-10-24 23:29:49 +00:00
bors
29979ad043 Auto merge of #6190 - montrivo:manual_result_unwrap_or, r=ebroto
manual_unwrap_or / support Result::unwrap_or

Implements partially #5923.

changelog: support Result::unwrap_or in manual_unwrap_or
2020-10-24 23:09:14 +00:00
bors
5c78d26e5e Auto merge of #6135 - cauebs:master, r=ebroto
Add large_types_passed_by_value lint

Creates a new lint that checks for large function parameters passed by value. ~Types that are Copy were ignored, because I understand they are explicitly marked as being cheap (or just acceptable) to copy. Arrays were excluded from that restriction because they are always Copy, independently of the size, if the elements are Copy.~ Only Copy types are considered, because if a type is not Copy it cannot be dereferenced, as pointed out by `@ebroto,` and that would require analyzing the whole function body to check if the argument is moved somewhere else. `self` and `mut` parameters are also skipped.

I refactored `trivially_copy_pass_by_ref` and the new lint into a new `pass_by_ref_or_value` module, since both share most of their implementations, as was pointed out to me in #4499.

~Some questions that remain:~
~1. Should `self` be disregarded for this lint?~
~2. Should we special case types like Vec and String when suggesting changes? (to slices and &str)~
~3. What should be the default size limit?~
~4. Are there any special cases I'm missing?~

I ask the maintainers to add the `hacktoberfest-accepted` label if this PR is decent, even if there are some minor details to work out, but I do intend to stick around and finish the job.

Fixes #4499

changelog: Add new lint [`large_types_passed_by_value`]
2020-10-24 22:31:53 +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
Geoffrey Copin
71ac0c0be8 Keep separators in cast_size_32bits stderr 2020-10-24 14:08:53 +02:00
Tim Nielens
0d21ae0e19 manual-unwrap-or / pr remarks, round 3 2020-10-24 11:35:05 +02:00
Geoffrey Copin
d46edd9966 Keep sign in int-to-float casts 2020-10-24 00:04:37 +02:00
bors
bf1c6f9871 Auto merge of #6206 - ebroto:rustup, r=ebroto
Rustup

changelog: none

r? `@ghost`
2020-10-23 16:58:39 +00:00
Eduardo Broto
d17edaa152 Merge remote-tracking branch 'upstream/master' into rustup 2020-10-23 14:37:17 +02:00
Geoffrey Copin
30f80c3b8c Fix test file 2020-10-23 00:33:15 +02:00
Geoffrey Copin
02f01104bf Add test case for negative literals 2020-10-23 00:04:27 +02:00
Geoffrey Copin
e8f12d2f02 Address review comments 2020-10-22 23:56:49 +02:00
Tim Nielens
6533d8becf manual-unwrap-or / pr remarks, round 2 2020-10-22 23:39:59 +02:00
Tim Nielens
f2da0c701e manual-unwrap-or / pr remarks 2020-10-22 22:46:10 +02:00
varkor
fcde7683fe Fix clippy tests 2020-10-22 13:23:14 +01:00
bors
fbe75a8497 Auto merge of #6203 - giraffate:fix_link_to_labeled_issues, r=Manishearth
Fix links to labeled issues

These labels seems wrong.
- <https://github.com/rust-lang/rust-clippy/labels/L-crash%20%3Aboom%3A>
- <https://github.com/rust-lang/rust-clippy/labels/L-bug%20%3Abeetle%3A>

changelog: none
2020-10-22 07:37:02 +00:00
Takayuki Nakata
496dbb6fe8 Fix links to labeled issues 2020-10-22 08:51:03 +09:00
Daniel Smith
4d3322525d Separate tests for each lint 2020-10-21 11:04:26 -04:00
Daniel Smith
86f2b29d2f Merge lints into one pass 2020-10-21 11:04:26 -04:00
Daniel Smith
d8c6bce440 Convert the await holding lints to correctness 2020-10-21 11:04:26 -04:00
Daniel Smith
ee20ebadaf Move refcell lint into shared module 2020-10-21 11:04:26 -04:00
Daniel Smith
3ed69cdb13 Move existing lint into shared file 2020-10-21 11:04:26 -04:00
Daniel Smith
b3a427d873 Add another test case 2020-10-21 11:04:26 -04:00
Daniel Smith
0f4abbf99a Better naming post copy/paste 2020-10-21 11:04:26 -04:00
Daniel Smith
070a751d4c update_lints 2020-10-21 11:04:26 -04:00
Daniel Smith
8727169f72 fmt 2020-10-21 11:04:26 -04:00
Daniel Smith
57bf80f776 Add lint for holding RefCell Ref across an await 2020-10-21 11:04:26 -04:00
bors
85959be606 Auto merge of #6193 - Ryan1729:add-more-LintStore-documentation, r=phansch
Add more infomation about LintStore registration

Backstory: I somehow missed the fact that I needed to register a lint pass in order for it to run, and I spent some time confused until I figured it out. So I wanted to make it clear that a missing `register_(early|late)_pass` call is a likely cause of a lint not running.

changelog: none
2020-10-20 09:38:38 +00:00
bors
eaffd0e418 Auto merge of #6167 - ThibsG:IdenticalArgumentsAssertEq3574, r=ebroto
Identical arguments on assert macro family

Lint when identical args are used on `assert_eq!`, `debug_assert_eq!`, `assert_ne!` and `debug_assert_ne!` macros.

Added to the lint `eq_op`.

Common functions added to `utils/higher.rs`

Fixes: #3574
Fixes: #4694

changelog: Lint on identical args when calling `assert_eq!`, `debug_assert_eq!`, `assert_ne!` and `debug_assert_ne!` macros
2020-10-19 19:50:12 +00:00
ThibsG
16b5f37b5a Split eq_op ui tests to avoid file limit error in CI 2020-10-19 17:36:48 +02:00
bors
74530adcba Auto merge of #6166 - achris:master, r=flip1995
Suggest a compatible shell for setup-toolchain.sh

setup-toolchain.sh uses "[[" which is a bash builtin, but the guide
suggests running it with sh.  On Ubuntu, /bin/sh points to dash and
running the script fails.

---

*Please keep the line below*
changelog: none
2020-10-19 13:17:07 +00:00
bors
3d3507230c Auto merge of #6195 - giraffate:sync-from-rust, r=ebroto
Rustup

I followed these steps: <https://github.com/rust-lang/rust-clippy/blob/master/CONTRIBUTING.md#fixing-build-failures-caused-by-rust>.

changelog: none
2020-10-19 06:01:21 +00:00
Takayuki Nakata
be136b2712 Merge remote-tracking branch 'upstream/master' into sync-from-rust 2020-10-19 13:05:51 +09:00
Ryan Wiedemann
67bc11bd04
Add more infomation about LintStore registration
Backstory: I somehow missed the fact that I needed to register a lint pass in order for it to run, and I spent some time confused until I figured it out. So I wanted to make it clear that a missing `register_(early|late)_pass` call is a likely cause of a lint not running.
2020-10-18 17:01:57 -06:00
Tim Nielens
915ce36087 manual_unwrap_or / support Result::unwrap_or 2020-10-18 01:18:59 +02:00
bors
01dd31fa60 Auto merge of #6189 - ebroto:rustup, r=ebroto
Rustup

changelog: none

r? `@ghost`
2020-10-17 20:13:34 +00:00
Eduardo Broto
bc43862820 Merge remote-tracking branch 'upstream/master' into rustup 2020-10-17 21:55:46 +02:00
Yuki Okushi
82f775d2c4 Rollup merge of #77851 - exrook:split-btreemap, r=dtolnay
BTreeMap: refactor Entry out of map.rs into its own file

btree/map.rs is approaching the 3000 line mark, splitting out the entry
code buys about 500 lines of headroom.

I've created this PR because the changes I've made in #77438 will push `map.rs` over the 3000 line limit and cause tidy to complain.

I picked `Entry` to factor out because it feels less tightly coupled to the rest of `BTreeMap` than the various iterator implementations.

Related: #60302
2020-10-18 04:11:07 +09:00
Jacob Hughes
29392a1728 Appease the almightly lord clippy, hallowed be thy name 2020-10-17 13:48:54 -04:00
Geoffrey Copin
bb0ce32423 Lint unnecessary int-to-int and float-to-float casts 2020-10-17 16:12:51 +02:00
ThibsG
5a13217ea9 Assert macro args extractor as a common function in higher 2020-10-17 11:54:25 +02:00
bors
4e83a38618 Auto merge of #6123 - montrivo:less_concise_than, r=ebroto
add lint manual_unwrap_or

Implements partially #5923.

changelog: add lint manual_unwrap_or
2020-10-16 20:43:45 +00:00
bors
81890c541e Auto merge of #6184 - ebroto:bump_cargo_metadata, r=ebroto
bump cargo_metadata version

changelog: none

r? `@ghost` (master broken)
2020-10-16 20:20:05 +00:00
Santiago Pastorino
0af467ebf2 Handle ExprKind::ConstBlock on clippy 2020-10-16 17:14:34 -03:00
Eduardo Broto
701c7e2fba bump cargo_metadata version 2020-10-16 22:11:37 +02:00
bors
e351e5ca69 Auto merge of #6180 - flip1995:rustup, r=flip1995
Update semver 0.10 -> 0.11

r? `@ghost,` blocking CI

changelog: none
2020-10-16 12:24:23 +00:00
flip1995
6d358d29b0
Update semver 0.10 -> 0.11 2020-10-16 14:23:17 +02:00
bors
a771557ee9 Auto merge of #6178 - josephlr:sync-from-rust, r=phansch
Sync from rust

Fix rustc breakage by running:
```rust
git subtree push -P src/tools/clippy git@github.com:josephlr/rust-clippy sync-from-rust
```
and then adding a commit that runs `cargo dev fmt`

---

changelog: none
2020-10-16 07:45:42 +00:00