Commit Graph

9837 Commits

Author SHA1 Message Date
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
Aaron Hill
33f3cfcadc Fix inconsistencies in handling of inert attributes on statements
When the 'early' and 'late' visitors visit an attribute target, they
activate any lint attributes (e.g. `#[allow]`) that apply to it.
This can affect warnings emitted on sibiling attributes. For example,
the following code does not produce an `unused_attributes` for
`#[inline]`, since the sibiling `#[allow(unused_attributes)]` suppressed
the warning.

```rust
trait Foo {
    #[allow(unused_attributes)] #[inline] fn first();
    #[inline] #[allow(unused_attributes)] fn second();
}
```

However, we do not do this for statements - instead, the lint attributes
only become active when we visit the struct nested inside `StmtKind`
(e.g. `Item`).

Currently, this is difficult to observe due to another issue - the
`HasAttrs` impl for `StmtKind` ignores attributes for `StmtKind::Item`.
As a result, the `unused_doc_comments` lint will never see attributes on
item statements.

This commit makes two interrelated fixes to the handling of inert
(non-proc-macro) attributes on statements:

* The `HasAttr` impl for `StmtKind` now returns attributes for
  `StmtKind::Item`, treating it just like every other `StmtKind`
  variant. The only place relying on the old behavior was macro
  which has been updated to explicitly ignore attributes on item
  statements. This allows the `unused_doc_comments` lint to fire for
  item statements.
* The `early` and `late` lint visitors now activate lint attributes when
  invoking the callback for `Stmt`. This ensures that a lint
  attribute (e.g. `#[allow(unused_doc_comments)]`) can be applied to
  sibiling attributes on an item statement.

For now, the `unused_doc_comments` lint is explicitly disabled on item
statements, which preserves the current behavior. The exact locatiosn
where this lint should fire are being discussed in PR #78306
2020-10-24 11:55:48 -04: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
ThibsG
62f60e1ae5 No lint with cfg! and fix sugg for macro in needless_bool lint 2020-10-24 09:37:23 +02:00
Geoffrey Copin
d46edd9966 Keep sign in int-to-float casts 2020-10-24 00:04:37 +02:00
Eduardo Broto
6caeed1bfa Remove duplicate import of Target 2020-10-23 23:45:37 +02:00
Eduardo Broto
cdb555f4fc Merge commit 'bf1c6f9871f430e284b17aa44059e0d0395e28a6' into clippyup 2020-10-23 22:16:59 +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
Joe Richey
3807634a47
clippy_lints: Update empty_loop lint
We also update the documentation to note that the remediations are
different for `std` and `no_std` crates.

Signed-off-by: Joe Richey <joerichey@google.com>
2020-10-22 22:03:13 -07: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
Andre Bogus
c693de350a New lint: manual-range-contains 2020-10-22 08:45:21 +02:00
cgm616
e70817e712 Update tests and add known problems to docs 2020-10-21 21:21:11 -04:00
cgm616
4a4f998c39 Add new lint for undropped ManuallyDrop values 2020-10-21 21:21:11 -04: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
Tim Nielens
65b52d84f8 needless-lifetime / multiple where clause predicates regression 2020-10-20 00:42:00 +02: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
Patrick José Pereira
ba1ca19c3b tests: if_same_then_else2: Ignore single_element_loop lint
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
2020-10-19 09:53:35 -03: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
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
Takayuki Nakata
114cb218f3 Remove an extra blank line in doc examples 2020-10-19 10:34:01 +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