]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoAuto merge of #6260 - matthiaskrgr:ices, r=ebroto
bors [Fri, 30 Oct 2020 22:19:11 +0000 (22:19 +0000)]
Auto merge of #6260 - matthiaskrgr:ices, r=ebroto

add a couple of ICE testcases

Fixes #6250
Fixes #6251
Fixes #6252
Fixes #6255
Fixes #6256

changelog: none

3 years agoAuto merge of #6197 - ThibsG:ImproveFilterNext, r=ebroto
bors [Fri, 30 Oct 2020 21:58:09 +0000 (21:58 +0000)]
Auto merge of #6197 - ThibsG:ImproveFilterNext, r=ebroto

Improve suggestions for several lints

This PR is a follow-up of this [Zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/filter_next.20lint).

It unifies placeholders for `methods` module and improves several suggestions for `filter_next`, `filter_map_next` and `map_unwrap_or` lints.

changelog: none

3 years agoAuto merge of #6229 - henil:improve-integer-division-lint, r=phansch
bors [Fri, 30 Oct 2020 12:37:46 +0000 (12:37 +0000)]
Auto merge of #6229 - henil:improve-integer-division-lint, r=phansch

Update the existing arithmetic lint

re: #6209

Updates the lint to not the error message if RHS of binary operation `/` of `%` is a literal/constant that is not `0` or `-1`, as suggested [here](https://github.com/rust-lang/rust-clippy/issues/6209#issuecomment-715624354)

changelog: Expand [`integer_arithmetic`] to work with RHS literals and constants

3 years agoremoved lint for division/modulo for literal `0`
henil [Fri, 30 Oct 2020 11:41:44 +0000 (17:11 +0530)]
removed lint for division/modulo for literal `0`

3 years agoAuto merge of #6200 - rail-rain:borrowed_box_invalid_sugg, r=phansch
bors [Fri, 30 Oct 2020 10:40:44 +0000 (10:40 +0000)]
Auto merge of #6200 - rail-rain:borrowed_box_invalid_sugg, r=phansch

fix the error-causing suggestion of 'borrowed_box'

Fixes #3128

Fix the suggestion of 'borrowed_box', which causes a syntax error because it misses necessary parentheses.

---

changelog: Fix the error-causing suggestion of 'borrowed_box'

3 years agoAuto merge of #6248 - giraffate:replace_e_easy_with_good_first_issue, r=flip1995
bors [Thu, 29 Oct 2020 15:54:38 +0000 (15:54 +0000)]
Auto merge of #6248 - giraffate:replace_e_easy_with_good_first_issue, r=flip1995

Replace `E-easy` with `good first issue` in `CONTRIBUTING.md`

`E-easy` isn't used, so `good first issue` is more appropriate.

changelog: none

3 years agoAuto merge of #6227 - HMPerson1:collect_map, r=phansch
bors [Thu, 29 Oct 2020 15:34:15 +0000 (15:34 +0000)]
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`

3 years agoUpdate CONTRIBUTING.md to describe `E-medium` in detail
Takayuki Nakata [Thu, 29 Oct 2020 15:24:29 +0000 (00:24 +0900)]
Update CONTRIBUTING.md to describe `E-medium` in detail

Co-authored-by: Philipp Krones <hello@philkrones.com>
3 years agoAuto merge of #6226 - Urcra:master, r=flip1995
bors [Thu, 29 Oct 2020 15:12:24 +0000 (15:12 +0000)]
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

3 years agoAuto merge of #6176 - achris:issues/578, r=phansch
bors [Thu, 29 Oct 2020 14:51:41 +0000 (14:51 +0000)]
Auto merge of #6176 - achris:issues/578, r=phansch

Lint items after statements in local macro expansions

The items_after_statements lint was skipping all expansions.  Instead
we should still lint local macros.

Fixes #578

---

*Please keep the line below*
changelog: The items_after_statements now applies to local macro expansions

3 years agoRemove empty lines in doc comment
Christian Nielsen [Thu, 29 Oct 2020 14:49:42 +0000 (15:49 +0100)]
Remove empty lines in doc comment

Co-authored-by: Philipp Krones <hello@philkrones.com>
3 years agoAuto merge of #6212 - ThibsG:MacroTopLevelRefArg, r=flip1995
bors [Thu, 29 Oct 2020 14:29:30 +0000 (14:29 +0000)]
Auto merge of #6212 - ThibsG:MacroTopLevelRefArg, r=flip1995

No lint in macro for `toplevel_ref_arg`

Do not lint when the span is from a macro.

Question: shouldn't we extend this for external macros also ?

Fixes: #5849
changelog: none

3 years agoUpdate existing arithmetic lint and add new tests related to it.
henil [Mon, 26 Oct 2020 13:58:22 +0000 (19:28 +0530)]
Update existing arithmetic lint and add new tests related to it.

3 years agoAuto merge of #6264 - matthiaskrgr:ra_setup_no_twice, r=llogiq
bors [Thu, 29 Oct 2020 07:49:27 +0000 (07:49 +0000)]
Auto merge of #6264 - matthiaskrgr:ra_setup_no_twice, r=llogiq

cargo dev ra-setup: don't inject deps multiple times if we have already done so

Fixes #6220

changelog: none

3 years agocargo dev ra-setup: don't inject deps multiple times if we have already done so
Matthias Krüger [Thu, 29 Oct 2020 02:22:02 +0000 (03:22 +0100)]
cargo dev ra-setup: don't inject deps multiple times if we have already done so

Fixes #6220

3 years agoadd a couple of ICE testcases
Matthias Krüger [Wed, 28 Oct 2020 13:45:21 +0000 (14:45 +0100)]
add a couple of ICE testcases

Fixes #6250
Fixes #6251
Fixes #6252
Fixes #6255
Fixes #6256

3 years agoAuto merge of #6263 - matthiaskrgr:diff_u, r=ebroto
bors [Wed, 28 Oct 2020 22:33:01 +0000 (22:33 +0000)]
Auto merge of #6263 - matthiaskrgr:diff_u, r=ebroto

use diff -u in driver.sh test

this changs the add/delete indication from
>
>
<
to
+
+
-
(same as git diff)

changelog: none

3 years agouse diff -u in driver.sh test
Matthias Krüger [Wed, 28 Oct 2020 22:19:04 +0000 (23:19 +0100)]
use diff -u in driver.sh test

this changs the add/delete indication from
>
>
<
to
+
+
-
(same as git diff)

3 years agoAuto merge of #6257 - giraffate:sync-from-rust, r=ebroto
bors [Wed, 28 Oct 2020 21:53:23 +0000 (21:53 +0000)]
Auto merge of #6257 - giraffate:sync-from-rust, r=ebroto

Rustup

changelog: none

3 years agoReinstate link to temporary_cstr_as_ptr
Eduardo Broto [Wed, 28 Oct 2020 21:36:22 +0000 (22:36 +0100)]
Reinstate link to temporary_cstr_as_ptr

3 years agoDeprecate temporary_cstr_as_ptr
Eduardo Broto [Wed, 28 Oct 2020 21:32:13 +0000 (22:32 +0100)]
Deprecate temporary_cstr_as_ptr

3 years agoUse `double_neg.stderr`
Takayuki Nakata [Wed, 28 Oct 2020 16:02:09 +0000 (01:02 +0900)]
Use `double_neg.stderr`

3 years agoFix reference
Takayuki Nakata [Wed, 28 Oct 2020 05:36:29 +0000 (14:36 +0900)]
Fix reference

3 years agocargo dev update_lints
Takayuki Nakata [Wed, 28 Oct 2020 05:25:41 +0000 (14:25 +0900)]
cargo dev update_lints

3 years agoMerge remote-tracking branch 'upstream/master' into sync-from-rust
Takayuki Nakata [Wed, 28 Oct 2020 05:14:09 +0000 (14:14 +0900)]
Merge remote-tracking branch 'upstream/master' into sync-from-rust

3 years agoAuto merge of #6216 - alex-700:improve-match-like-matches-lint, r=ebroto
bors [Tue, 27 Oct 2020 23:01:35 +0000 (23:01 +0000)]
Auto merge of #6216 - alex-700:improve-match-like-matches-lint, r=ebroto

Improve match like matches lint

fixes #6186

changelog: improve MATCH_LIKE_MATCHES_MACRO lint

3 years agoimprove MATCH_LIKE_MATCHES_MACRO lint
Aleksei Latyshev [Sat, 24 Oct 2020 15:06:07 +0000 (18:06 +0300)]
improve MATCH_LIKE_MATCHES_MACRO lint

- add tests
- refactor match_same_arms lint
- prioritize match_expr_like_matches_macro over match_same_arms

3 years agosimplify SpanlessEq::eq_path_segment
Aleksei Latyshev [Sat, 24 Oct 2020 15:05:02 +0000 (18:05 +0300)]
simplify SpanlessEq::eq_path_segment

3 years agoReplace `E-easy` with `good first issue` in `CONTRIBUTING.md`
Takayuki Nakata [Tue, 27 Oct 2020 14:32:38 +0000 (23:32 +0900)]
Replace `E-easy` with `good first issue` in `CONTRIBUTING.md`

`E-easy` isn't used, so `good first issue` is more appropriate.

3 years agoAuto merge of #6244 - mikerite:invalid_paths_20201027, r=flip1995
bors [Tue, 27 Oct 2020 11:16:21 +0000 (11:16 +0000)]
Auto merge of #6244 - mikerite:invalid_paths_20201027, r=flip1995

New internal lint: Invalid paths

Add a new internal lint that detects invalid paths in the `util::paths` and fix some invalid paths found.

This commit partially addresses #6047 but the lint would have to be run before running tests to close that issue.

changelog: none

3 years agoFix invalid paths
Michael Wright [Tue, 27 Oct 2020 05:43:38 +0000 (07:43 +0200)]
Fix invalid paths

3 years agoAdd `invalid_paths` internal lint
Michael Wright [Tue, 27 Oct 2020 05:42:13 +0000 (07:42 +0200)]
Add `invalid_paths` internal lint

3 years agofix the error-causing suggestion of 'borrowed_box'
rail [Tue, 20 Oct 2020 20:42:00 +0000 (09:42 +1300)]
fix the error-causing suggestion of 'borrowed_box'

fix the error-causing suggestion of 'borrowed_box',
which missed parentheses and was ambiguous.

3 years agoRemove lint from clippy
Nathan Whitaker [Tue, 22 Sep 2020 16:23:22 +0000 (12:23 -0400)]
Remove lint from clippy

3 years agoFix tests for `map_unwrap_or*`
ThibsG [Mon, 26 Oct 2020 10:02:01 +0000 (11:02 +0100)]
Fix tests for `map_unwrap_or*`

3 years agoMove fixable `filter_next` and `filter_map_next` cases to rustfixed tests
ThibsG [Fri, 23 Oct 2020 07:49:47 +0000 (09:49 +0200)]
Move fixable `filter_next` and `filter_map_next` cases to rustfixed tests

3 years agoMove fixable `map_unwrap_or` cases to rustfixed test
ThibsG [Fri, 23 Oct 2020 07:24:25 +0000 (09:24 +0200)]
Move fixable `map_unwrap_or` cases to rustfixed test

3 years agoImprove some suggestions for `filter_map_next`, `filter_next` and `map_unwrap_or...
ThibsG [Mon, 19 Oct 2020 16:47:02 +0000 (18:47 +0200)]
Improve some suggestions for `filter_map_next`, `filter_next` and `map_unwrap_or` lints

3 years agoUse better placeholders for some methods lint messages
ThibsG [Sun, 18 Oct 2020 11:09:06 +0000 (13:09 +0200)]
Use better placeholders for some methods lint messages

3 years agoNo lint in external macro for `toplevel_ref_arg`
ThibsG [Sat, 24 Oct 2020 08:50:11 +0000 (10:50 +0200)]
No lint in external macro for `toplevel_ref_arg`

3 years agoAdd lint for replacing `.map().collect()` with `.try_for_each()`
HMPerson1 [Mon, 26 Oct 2020 01:20:57 +0000 (21:20 -0400)]
Add lint for replacing `.map().collect()` with `.try_for_each()`

3 years agoRemove unnecesary format
Urcra [Mon, 26 Oct 2020 00:55:44 +0000 (01:55 +0100)]
Remove unnecesary format

3 years agorun cargo fmt
Urcra [Mon, 26 Oct 2020 00:31:13 +0000 (01:31 +0100)]
run cargo fmt

3 years agoRun update lints
Urcra [Mon, 26 Oct 2020 00:21:34 +0000 (01:21 +0100)]
Run update lints

3 years agoAdd description to lint
Urcra [Mon, 26 Oct 2020 00:02:10 +0000 (01:02 +0100)]
Add description to lint

3 years agoRevert changes to Cargo.toml file
Urcra [Sun, 25 Oct 2020 23:53:51 +0000 (00:53 +0100)]
Revert changes to Cargo.toml file

3 years agoMove implementation into len_zero.rs
Urcra [Sun, 25 Oct 2020 23:51:18 +0000 (00:51 +0100)]
Move implementation into len_zero.rs

3 years agoInitial implementation of comparison_to_empty
Urcra [Sun, 25 Oct 2020 23:31:25 +0000 (00:31 +0100)]
Initial implementation of comparison_to_empty

3 years agoAuto merge of #6225 - rust-lang:flip1995-patch-1, r=flip1995
bors [Sun, 25 Oct 2020 20:35:17 +0000 (20:35 +0000)]
Auto merge of #6225 - rust-lang:flip1995-patch-1, r=flip1995

Update triagebot.toml

r? `@ghost`
changelog: none

3 years agoUpdate triagebot.toml
Philipp Krones [Sun, 25 Oct 2020 20:34:46 +0000 (21:34 +0100)]
Update triagebot.toml

3 years agoAuto merge of #6202 - giraffate:fix_invalid_suggestion_in_needless_collect_test,...
bors [Sun, 25 Oct 2020 17:35:33 +0000 (17:35 +0000)]
Auto merge of #6202 - giraffate:fix_invalid_suggestion_in_needless_collect_test, r=flip1995

Fix an invalid suggestion in `needless_collect` test

A test, https://github.com/rust-lang/rust-clippy/blob/master/tests/ui/needless_collect_indirect.rs#L11-L12, suggests following codes, but the suggested codes don't work. An example is here: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=6947d9f2806a83f41cc5eb8e39b09d0b.
```
error: avoid using `collect()` when not needed
  --> $DIR/needless_collect_indirect.rs:11:5
   |
LL | /     let indirect_contains = sample.iter().collect::<VecDeque<_>>();
LL | |     indirect_contains.contains(&&5);
   | |____^
   |
help: Check if the original Iterator contains an element instead of collecting then checking
   |
LL |
LL |     sample.iter().any(|x| x == &&5);
```

changelog: none

3 years agoAuto merge of #6194 - giraffate:remove_an_extra_blank_line, r=flip1995
bors [Sun, 25 Oct 2020 17:15:42 +0000 (17:15 +0000)]
Auto merge of #6194 - giraffate:remove_an_extra_blank_line, r=flip1995

Remove an extra blank line in doc examples

It seems to be an extra blank line in doc example.

changelog: none

<img width="1141" alt="スクリーンショット 2020-10-19 10 32 21" src="https://user-images.githubusercontent.com/17407489/96392372-d0583200-11f6-11eb-9aab-f7e8f87eb04e.png">

3 years agoAuto merge of #6183 - cgm616:hex_bin_digit_grouping, r=flip1995
bors [Sun, 25 Oct 2020 16:40:14 +0000 (16:40 +0000)]
Auto merge of #6183 - cgm616:hex_bin_digit_grouping, r=flip1995

Hex bin digit grouping

This revives and updates an old pr (#3391) for the current API.

Closes #2538.

---

*Please keep the line below*
changelog: Add [`unusual_byte_groupings`] lint.

3 years agoAuto merge of #6224 - flip1995:rustup, r=flip1995
bors [Sun, 25 Oct 2020 15:45:12 +0000 (15:45 +0000)]
Auto merge of #6224 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: none

3 years agoMerge remote-tracking branch 'upstream/master' into rustup
flip1995 [Sun, 25 Oct 2020 15:43:53 +0000 (16:43 +0100)]
Merge remote-tracking branch 'upstream/master' into rustup

3 years agoIntegrate suggestions from code review
cgm616 [Sun, 25 Oct 2020 15:31:24 +0000 (11:31 -0400)]
Integrate suggestions from code review

3 years agoAdd test case
Takayuki Nakata [Sun, 25 Oct 2020 14:55:41 +0000 (23:55 +0900)]
Add test case

3 years agoFix an invalid suggestion in `needless_collect` test
Takayuki Nakata [Wed, 21 Oct 2020 13:33:41 +0000 (22:33 +0900)]
Fix an invalid suggestion in `needless_collect` test

3 years agoFix logic mistake
cgm616 [Sun, 25 Oct 2020 13:34:46 +0000 (09:34 -0400)]
Fix logic mistake

3 years agoRemove accidental test inclusion
cgm616 [Sun, 25 Oct 2020 13:19:58 +0000 (09:19 -0400)]
Remove accidental test inclusion

3 years agoAllow hex literals to pass w/ groups of 2
cgm616 [Sun, 25 Oct 2020 13:18:06 +0000 (09:18 -0400)]
Allow hex literals to pass w/ groups of 2

3 years agoAdd lint for unusually-grouped hex/binary literals
Florian Hartwig [Wed, 31 Oct 2018 16:14:55 +0000 (17:14 +0100)]
Add lint for unusually-grouped hex/binary literals

3 years agoAuto merge of #6222 - JohnTitor:redundant-local-def-id, r=flip1995
bors [Sun, 25 Oct 2020 11:58:51 +0000 (11:58 +0000)]
Auto merge of #6222 - JohnTitor:redundant-local-def-id, r=flip1995

Remove redundant `expect_local()` call

The field `owner` of `HirId` is `LocalDefId` and `hir_id.owner.to_def_id().expect_local()` is redundant. I wonder they were introduced in some rustups.

changelog: none

3 years agoAuto merge of #6211 - ThibsG:NeedlessBoolCfg, r=flip1995
bors [Sun, 25 Oct 2020 11:37:18 +0000 (11:37 +0000)]
Auto merge of #6211 - ThibsG:NeedlessBoolCfg, r=flip1995

No lint with `cfg!` and fix sugg for macro in `needless_bool` lint

Don't lint if `cfg!` macro is one of the operand.
Fix suggestion when the span originated from a macro, using `hir_with_macro_callsite`.

Fixes: #3973
changelog: none

3 years agoAuto merge of #6198 - montrivo:needless-lifetime, r=flip1995
bors [Sun, 25 Oct 2020 11:15:01 +0000 (11:15 +0000)]
Auto merge of #6198 - montrivo:needless-lifetime, r=flip1995

needless-lifetime / multiple where clause predicates regression

Closes #6159.

changelog: fix regression in needless-lifetimes

3 years agoAuto merge of #6177 - rust-lang:manual-range-contains, r=flip1995
bors [Sun, 25 Oct 2020 10:35:46 +0000 (10:35 +0000)]
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

3 years agoRemove redundant `expect_local()` call
Yuki Okushi [Sun, 25 Oct 2020 10:30:00 +0000 (19:30 +0900)]
Remove redundant `expect_local()` call

3 years agoAuto merge of #6103 - FrancisMurillo:mut_mutex_lock, r=flip1995
bors [Sun, 25 Oct 2020 10:16:23 +0000 (10:16 +0000)]
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.

3 years agoAuto merge of #6162 - josephlr:empty-loop-no-std, r=flip1995
bors [Sun, 25 Oct 2020 09:56:16 +0000 (09:56 +0000)]
Auto merge of #6162 - josephlr:empty-loop-no-std, r=flip1995

Update empty_loop documentation/message.

Originally part of #6161, but now this PR only deals with `std` crates

This change:
  - Updates the `std` message .
  - Updates the docs to mention how the busy loops should be fixed
    - Gives examples of how to do this for `no_std` targets
  - Updates the tests/stderr files to test this change.

changelog: Update `empty_loop` lint documentation

3 years agoRollup merge of #78326 - Aaron1011:fix/min-stmt-lints, r=petrochenkov
Yuki Okushi [Sun, 25 Oct 2020 09:43:49 +0000 (18:43 +0900)]
Rollup merge of #78326 - Aaron1011:fix/min-stmt-lints, r=petrochenkov

Split out statement attributes changes from #78306

This is the same as PR https://github.com/rust-lang/rust/pull/78306, but `unused_doc_comments` is modified to explicitly ignore statement items (which preserves the current behavior).

This shouldn't have any user-visible effects, so it can be landed without lang team discussion.

---------
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

3 years agoChange from correctness to style and MaybeIncorrect instead of MachineApplicable
Francis Murillo [Sun, 18 Oct 2020 01:09:07 +0000 (09:09 +0800)]
Change from correctness to style and MaybeIncorrect instead of MachineApplicable

3 years agoUse `sugg_lint_and_help`
Francis Murillo [Sat, 10 Oct 2020 10:07:47 +0000 (18:07 +0800)]
Use `sugg_lint_and_help`

3 years agoInline is_mut_mutex_lock_call
Francis Murillo [Mon, 5 Oct 2020 03:44:54 +0000 (11:44 +0800)]
Inline is_mut_mutex_lock_call

3 years agoRun update_lints
Francis Murillo [Fri, 2 Oct 2020 23:53:45 +0000 (07:53 +0800)]
Run update_lints

3 years agoChange lint doc test
Francis Murillo [Fri, 2 Oct 2020 02:54:44 +0000 (10:54 +0800)]
Change lint doc test

3 years agoAuto merge of #6181 - cgm616:undropped-manually-drops, r=flip1995
bors [Sun, 25 Oct 2020 09:37:09 +0000 (09:37 +0000)]
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

3 years agoAdd lint for `&mut Mutex::lock`
Francis Murillo [Fri, 2 Oct 2020 01:05:30 +0000 (09:05 +0800)]
Add lint for `&mut Mutex::lock`

3 years agoAuto merge of #6109 - patrickelectric:single_element_for_check, r=flip1995
bors [Sun, 25 Oct 2020 09:15:55 +0000 (09:15 +0000)]
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

3 years agoAuto merge of #6029 - Daniel-B-Smith:refcell_ref_await, r=flip1995
bors [Sun, 25 Oct 2020 08:54:27 +0000 (08:54 +0000)]
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

3 years agoAuto merge of #6187 - geoffreycopin:master, r=ebroto
bors [Sat, 24 Oct 2020 23:29:49 +0000 (23:29 +0000)]
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.

3 years agoAuto merge of #6190 - montrivo:manual_result_unwrap_or, r=ebroto
bors [Sat, 24 Oct 2020 23:09:14 +0000 (23:09 +0000)]
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

3 years agoAuto merge of #6135 - cauebs:master, r=ebroto
bors [Sat, 24 Oct 2020 22:31:53 +0000 (22:31 +0000)]
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`]

3 years agoAdd large_types_passed_by_value lint
Cauê Baasch de Souza [Thu, 8 Oct 2020 05:17:32 +0000 (02:17 -0300)]
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

3 years agoFix inconsistencies in handling of inert attributes on statements
Aaron Hill [Fri, 23 Oct 2020 22:17:00 +0000 (18:17 -0400)]
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

3 years agoKeep separators in cast_size_32bits stderr
Geoffrey Copin [Sat, 24 Oct 2020 12:07:34 +0000 (14:07 +0200)]
Keep separators in cast_size_32bits stderr

3 years agomanual-unwrap-or / pr remarks, round 3
Tim Nielens [Sat, 24 Oct 2020 09:35:05 +0000 (11:35 +0200)]
manual-unwrap-or / pr remarks, round 3

3 years agoNo lint with `cfg!` and fix sugg for macro in `needless_bool` lint
ThibsG [Sat, 24 Oct 2020 07:31:32 +0000 (09:31 +0200)]
No lint with `cfg!` and fix sugg for macro in `needless_bool` lint

3 years agoKeep sign in int-to-float casts
Geoffrey Copin [Fri, 23 Oct 2020 21:40:57 +0000 (23:40 +0200)]
Keep sign in int-to-float casts

3 years agoRemove duplicate import of `Target`
Eduardo Broto [Fri, 23 Oct 2020 21:45:37 +0000 (23:45 +0200)]
Remove duplicate import of `Target`

3 years agoMerge commit 'bf1c6f9871f430e284b17aa44059e0d0395e28a6' into clippyup
Eduardo Broto [Fri, 23 Oct 2020 20:16:59 +0000 (22:16 +0200)]
Merge commit 'bf1c6f9871f430e284b17aa44059e0d0395e28a6' into clippyup

3 years agoAuto merge of #6206 - ebroto:rustup, r=ebroto
bors [Fri, 23 Oct 2020 16:58:39 +0000 (16:58 +0000)]
Auto merge of #6206 - ebroto:rustup, r=ebroto

Rustup

changelog: none

r? `@ghost`

3 years agoMerge remote-tracking branch 'upstream/master' into rustup
Eduardo Broto [Fri, 23 Oct 2020 12:37:17 +0000 (14:37 +0200)]
Merge remote-tracking branch 'upstream/master' into rustup

3 years agoclippy_lints: Update empty_loop lint
Joe Richey [Sun, 11 Oct 2020 23:04:33 +0000 (16:04 -0700)]
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>
3 years agoFix test file
Geoffrey Copin [Thu, 22 Oct 2020 22:04:27 +0000 (00:04 +0200)]
Fix test file

3 years agoAdd test case for negative literals
Geoffrey Copin [Thu, 22 Oct 2020 22:04:27 +0000 (00:04 +0200)]
Add test case for negative literals

3 years agoAddress review comments
Geoffrey Copin [Thu, 22 Oct 2020 21:53:50 +0000 (23:53 +0200)]
Address review comments

3 years agomanual-unwrap-or / pr remarks, round 2
Tim Nielens [Thu, 22 Oct 2020 21:39:59 +0000 (23:39 +0200)]
manual-unwrap-or / pr remarks, round 2

3 years agomanual-unwrap-or / pr remarks
Tim Nielens [Thu, 22 Oct 2020 20:46:10 +0000 (22:46 +0200)]
manual-unwrap-or / pr remarks

3 years agoFix clippy tests
varkor [Thu, 22 Oct 2020 12:23:14 +0000 (13:23 +0100)]
Fix clippy tests

3 years agoAuto merge of #6203 - giraffate:fix_link_to_labeled_issues, r=Manishearth
bors [Thu, 22 Oct 2020 07:37:02 +0000 (07:37 +0000)]
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