Commit graph

4243 commits

Author SHA1 Message Date
flip1995
78c740e2f3
Merge remote-tracking branch 'upstream/master' into rustup 2021-03-11 10:37:58 +01:00
bors
8222d48cde Auto merge of #6814 - hyd-dev:issue-6486, r=flip1995
Fix false positives on procedural macros of `missing_inline_in_public_items` lint

Fixes #6486.

changelog: Fix false positives on procedural macros of `missing_inline_in_public_items` lint.
2021-03-10 16:40:33 +00:00
bors
8a5f98a0e4 Auto merge of #6866 - anall:ice6840, r=flip1995
Fix ICE 6840 - make is_normalizable more strict

fixes #6840

make `is_normalizable` more strict, which should catch this ICE and related cases

changelog: Fix ICE in [`zero_sized_map_values`]
2021-03-09 14:58:24 +00:00
Andrea Nall
e322c773e3 use TyS::walk 2021-03-08 23:03:45 -06:00
bors
2cb5bbf80c Auto merge of #6871 - camsteffen:redundant-closure-macro, r=Manishearth
Fix redundant closure with macros

changelog: Fix redundant_closure FPs with macros

Fixes #6732
Fixes #6850
Fixes #4354 (addresses the error message confusion)
2021-03-08 21:32:21 +00:00
Cameron Steffen
8c540dcd2d Improve the redundant_closure message 2021-03-08 13:16:53 -06:00
Cameron Steffen
bf98aa6fb8 Fix redundant closure with macros 2021-03-08 13:15:13 -06:00
bors
d0d5232c72 Auto merge of #6834 - hyd-dev:clippy-args, r=phansch,flip1995,oli-obk
Let Cargo track CLIPPY_ARGS

This PR makes `clippy-driver` emit `CLIPPY_ARGS` in its `dep-info` output.

Just like #6441, this allows this workflow to work:
```shell
cargo clippy # warning: empty `loop {}` wastes CPU cycles
cargo clippy -- -A clippy::empty_loop # no warnings emitted
```
But without rebuilding all dependencies.

cc https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/CLIPPY_ARGS.20is.20not.20tracked.20by.20Cargo/near/228599088

changelog: Cargo now re-runs Clippy if arguments after `--` provided to `cargo clippy` are changed.
2021-03-08 13:18:39 +00:00
hyd-dev
2d53b6b824
Move test_no_deps_ignores_path_deps_in_workspaces() out of dogfood_subprojects() 2021-03-08 18:29:36 +08:00
Andrea Nall
b27cbda32b make is_normalizable more strict 2021-03-07 21:45:54 -06:00
Jason Newcomb
47145dec36
len_without_is_empty will now consider multiple impl blocks
`len_without_is_empty` will now consider `#[allow]` on both the `len` method, and the type definition
2021-03-07 09:40:18 -05:00
flip1995
5ebe6d3234
Fix dogfood test
Since clippy cannot be a workspace, we have to check the sub-crates separately
2021-03-05 11:10:29 +01:00
bors
7be3a32f25 Auto merge of #6843 - Jarcho:match_on_same_arms_macro, r=Manishearth
Compare empty blocks for equality based on tokens

fixes: #1390

This only considers empty blocks for now, though we should also catch something like this:

```rust
match 0 {
    0 => {
        do_something();
        trace!(0);
        0
    }
    1 => {
        do_something();
        trace!(1);
        1
    }
    x => x,
}
```

As far as I can tell there aren't any negative effects on other lints. These blocks only happen to be the same for a given compilation, not all compilations.

changelog: Fix `match_on_same_arms` and others. Only consider empty blocks equal if the tokens contained are the same.
2021-03-04 18:23:39 +00:00
Jason Newcomb
39c5e86337
When checking if two empty hir blocks are equal also check to see if the tokens used are the same as well 2021-03-04 11:06:24 -05:00
hyd-dev
03e72d5446
Let Cargo track CLIPPY_ARGS 2021-03-04 03:29:21 +08:00
daxpedda
5656510eed
Fix false-positive in use_self 2021-03-03 17:32:49 +01:00
Ryan Levick
09c4503cae Fix borrow and deref 2021-03-03 11:23:29 +01:00
Ryan Levick
e3f48559ed Allow noop_method_call in clippy ui test 2021-03-03 11:22:58 +01:00
bors
ece3543c9f Auto merge of #6801 - Jarcho:manual_match_fix, r=phansch
Fix `manual_map` false positives

fixes: #6795
fixes: #6797
fixes: #6811
fixes: #6819

changelog: Fix false positives for `manual_map` when `return`, `break`, `continue`, `yield`, `await`, and partially moved values are used.
changelog: Don't expand macros in suggestions  for `manual_map`
2021-03-02 15:36:00 +00:00
bors
eb04beb005 Auto merge of #6791 - TaKO8Ki:iter-count, r=matthiaskrgr
New lint: `iter_count`

This pull request adds a new lint named `iter_count`.

---

closes https://github.com/rust-lang/rust-clippy/issues/6262

changelog: new lint `iter_count`
2021-03-02 11:31:43 +00:00
Jason Newcomb
2c485e36cd
Don't move yield or inline assembly into closure 2021-03-01 17:25:23 -05:00
Cameron Steffen
ada8c72f3f Add version = "Two" to rustfmt.toml
Ignore UI tests since this change makes rustfmt less friendly with UI
test comments.
2021-03-01 16:17:33 -06:00
Jason Newcomb
a3278a16d3
Fix manual_map: do not expand macros in suggestions 2021-02-28 09:13:24 -05:00
hyd-dev
da3a57377e
Fix false positives on procedural macros of missing_inline_in_public_items lint 2021-02-28 21:10:44 +08:00
Matthias Krüger
ebc5c8f271 use different example (C-like) for valid capitalized start of lint message 2021-02-28 14:01:45 +01:00
Matthias Krüger
e00b1cc73a change some lint messages and remove old entries from the ignorelist 2021-02-28 02:22:05 +01:00
Matthias Krüger
e107b65b5a disable lint_message_convention test inside the rustc test suite 2021-02-28 02:22:05 +01:00
Matthias Krüger
8eb2bd13d0 update the lint messages and tests 2021-02-28 02:22:05 +01:00
Matthias Krüger
5370576882 fix clippy lint warnings 2021-02-28 02:22:05 +01:00
Matthias Krüger
b119b65859 tests: add test that roughly ensures that our lint messages conform with the diagnostics convention of the rustc dev guide
lint message should not start with uppercase letters
lint messages should not have punctuation at the end of the last line

https://rustc-dev-guide.rust-lang.org/diagnostics.html#diagnostic-structure

The test reads through all the .stderr files in the testsuit and checks lint messages that start with "help: ", "error: " etc.
There is also an exception list for special messages that are deemed acceptable.

changelog: make sure lint messages conform with the rustc dev guide and add test
2021-02-28 02:22:05 +01:00
bors
abd2c7ebfb Auto merge of #6802 - camsteffen:dogfood-fix, r=llogiq
Remove workspace and fix dogfood (again)

changelog: none

In response to https://github.com/rust-lang/rust-clippy/pull/6733#issuecomment-785792060
2021-02-28 00:49:02 +00:00
Yoshitomo Nakanishi
e51bb0ee26 Add test for ICE 6793 2021-02-27 22:57:30 +09:00
Yoshitomo Nakanishi
bdeec5dbd6 Use TypeckResults::expr_ty instead of TyCtxt::type_of to fix "Not a type" ICE 2021-02-27 22:57:29 +09:00
Takayuki Maeda
cc2b00055c return when the ty doesn't have len() 2021-02-27 14:16:02 +09:00
Takayuki Maeda
204b27937c lint for into_iter().count() 2021-02-27 14:16:02 +09:00
Takayuki Maeda
7223ee6590 allow clippy::iter_count 2021-02-27 14:16:01 +09:00
Takayuki Maeda
51617b83a1 new lint: iter_count 2021-02-27 14:15:57 +09:00
Andrea Nall
3d3cfd3754 added new lint implicit_clone 2021-02-26 19:13:47 -06:00
Jason Newcomb
ef87e58993
Fix manual_map: don't lint when partially moved values are used.
Fix `manual_map`: don't lint when `return`, `break`, and `continue` are used.
2021-02-26 16:24:25 -05:00
Cameron Steffen
d71ed26fd2 Revert "Fix versioncheck test"
This reverts commit 1e7b1ccb2a.
2021-02-26 12:30:43 -06:00
Cameron Steffen
aef6dc23ee Add package arguments to dogfood test
This is necessary after migrating to RUSTC_WORKSPACE_WRAPPER.
2021-02-26 12:12:33 -06:00
bors
d5223be2e3 Auto merge of #6601 - mdm:fix-unit-args-false-positive, r=camsteffen
Fix false positive for unit_arg lint

Fixes #6447

To avoid false positives don't complain about unit args when they come from a path expression, e.g. a local variable.

**Note:** This is my first contribution to Clippy, so I might have messed up somewhere. Any feedback is welcome and I'm happy to work out any kinks.

---

changelog: Do not lint unit arguments when they come from a path expression.
2021-02-25 21:16:02 +00:00
Marc Dominik Migge
cbe6eec3e6 Add original test case from issue 2021-02-25 22:03:11 +01:00
bors
5c6cd87b94 Auto merge of #6790 - mgacek8:issue_6748, r=Manishearth
or_fun_call: fix suggestion for `or_insert(vec![])`

fixes #6748
changelog: or_fun_call: fix suggestion for `or_insert(vec![])` on `std::collections::hash_map::Entry` or `std::collections::btree_map::Entry`
2021-02-25 15:05:06 +00:00
Mateusz Gacek
2f0e9f7d3a or_fun_call: fix suggestion for or_insert(vec![])
Applies for `std::collections::hash_map::Entry` and `std::collections::btree_map::Entry`

Example:
Previously, for the following code:
`let _ = hash_map.entry("test".to_owned()).or_insert(vec![]);`
clippy would suggest to use:
`or_insert_with(vec![])`, which causes a compiler error (E0277).

Now clippy suggests:
`or_insert_with(Vec::new)`
2021-02-25 14:23:38 +01:00
flip1995
b303f7d6f9 Fix Clippy build and test 2021-02-25 11:25:45 +01:00
flip1995
f64149dd04 Merge commit '928e72dd10749875cbd412f74bfbfd7765dbcd8a' into clippyup 2021-02-25 11:25:22 +01:00
bors
ef41f2baf7 Auto merge of #6788 - matthiaskrgr:upper_case_acronyms, r=flip1995
move upper_case_acronyms back to style, but make the default behaviour less aggressive by default (can be unleashed via config option)

Previous discussion in the bi-weekly clippy meeting for reference: https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Meeting.202021-02-23/near/227458019

Move the `upper_case_acronyms` lint back to the style group.
Only warn on fully-capitalized names by default.
Add add a clippy-config option `upper-case-acronyms-aggressive: true/false` to enabled more aggressive linting on
all substrings that could be capitalized acronyms.

---
changelog: reenable upper_case_acronyms by default but make the more aggressive linting opt-in via config option
2021-02-25 09:01:41 +00:00
Matthias Krüger
913c71018c upper_case_acronyms: add io-toml tests and bless previous tests 2021-02-24 23:50:55 +01:00
avitex
b0d18e93d6
add test coverage for all doc-valid-idents 2021-02-25 09:30:33 +11:00