Commit graph

11453 commits

Author SHA1 Message Date
Aliénore Bouttefeux
8e5dd4b2e9 add test for missing_panic_doc on assert_eq/assert_ne 2021-04-05 09:16:48 +02:00
Jason Newcomb
a00de90ceb
Fix ICE in missing_panics_doc 2021-04-05 00:09:13 -04:00
bors
a15d987c8f Auto merge of #7021 - camsteffen:7012, r=giraffate
Fix ICE #7012

changelog: none

Fixes #7012
2021-04-04 23:51:31 +00:00
Dylan DPC
44e3ccb6dc Rollup merge of #83820 - petrochenkov:nolinkargs, r=nagisa
Remove attribute `#[link_args]`

Closes https://github.com/rust-lang/rust/issues/29596

The attribute could always be replaced with `-C link-arg`, but cargo didn't provide a reasonable way to pass such flags to rustc.
Now cargo supports `cargo:rustc-link-arg*` directives in build scripts (https://doc.rust-lang.org/cargo/reference/unstable.html#extra-link-arg), so this attribute can be removed.
2021-04-05 00:24:33 +02:00
xFrednet
da04e873b3 Quick fix to access the correct css files 2021-04-04 20:15:41 +02:00
bors
6bb608c00c Auto merge of #7030 - xFrednet:6877-clippy-going-dark, r=llogiq
Clippy going dark: Adding a dark theme to Clippy's lint list

This PR adds the MdBook color themes to the lint list of Clippy. Well at least an adaption of these themes.

<details>
<summary>Here are some beautiful screenshots:</summary>

**light theme**
![image](https://user-images.githubusercontent.com/17087237/113510593-e31fb280-955b-11eb-8ab1-8b5bcf287475.png)

**Rust theme**
![image](https://user-images.githubusercontent.com/17087237/113510734-79ec6f00-955c-11eb-981c-8ebe890acf79.png)

**Coal theme**
![image](https://user-images.githubusercontent.com/17087237/113510752-8ec90280-955c-11eb-8f5c-c87ca07c35c2.png)

**Navy theme**
![image](https://user-images.githubusercontent.com/17087237/113510675-3f82d200-955c-11eb-8992-8c784abe19ea.png)

**Ayu theme**
![image](https://user-images.githubusercontent.com/17087237/113510700-588b8300-955c-11eb-83e0-a8f770e9f913.png)

</details>

The theme is also stored in the browser to ensure that the next session applies the theme and doesn't burn your eyes out.

cc: `@matthiaskrgr`

---

Closes #6877

changelog: [Clippy's lint list](https://rust-lang.github.io/rust-clippy/master/index.html) now supports themes
2021-04-04 16:59:14 +00:00
xFrednet
e25b1060f5 Adding a dark theme to the clippy lint list 2021-04-04 15:36:30 +02:00
ThibsG
81dfb9ecfb Check path imports per module 2021-04-04 14:25:05 +02:00
Aliénore Bouttefeux
2f81e4e34f modification not working: fixing 2021-04-04 13:03:05 +02:00
Aliénore Bouttefeux
984ab98712 added core::panicking::assert_failed_inner as panicking 2021-04-04 11:56:45 +02:00
Cameron Steffen
6f31ed6c8d Use DefIdMap and similar aliases 2021-04-03 18:02:49 -05:00
daxpedda
5102c9cc69
Remove author requirement for cargo_common_metadata 2021-04-03 22:52:48 +02:00
Cameron Steffen
7014340d57 Fix ICE 2021-04-03 14:17:58 -05:00
Vadim Petrochenkov
c7264483e7 Remove attribute #[link_args] 2021-04-03 21:25:53 +03:00
Jason Newcomb
c05760ff90
Fix macro_use_import ICE 2021-04-02 22:27:13 -04:00
Roxane
2ca5368628 fix clippy error 2021-04-02 19:11:51 -04:00
bors
86fb0e8266 Auto merge of #7020 - camsteffen:needless-collect, r=Manishearth
Improve needless_collect output

changelog: Improve needless_collect output

Fixes #6908
Partially addresses #6164
2021-04-02 15:27:54 +00:00
Cameron Steffen
33798bb064 Improve needless_collect output 2021-04-02 10:10:54 -05:00
bors
9ce23730e2 Auto merge of #7016 - camsteffen:bind-map-paths, r=Manishearth
Remove paths from bind_instead_of_map

changelog: none
2021-04-02 15:10:24 +00:00
Cameron Steffen
4356a8f8f7 Remove redundant emit() 2021-04-02 09:38:13 -05:00
Cameron Steffen
a064534b9e Refactor needless_collect 2021-04-02 08:41:05 -05:00
bors
1931db20b1 Auto merge of #6988 - mikerite:fix-6984, r=camsteffen
Fix hidden variant suggestion on single variant

Fixes #6984

changelog: Fix hidden variant suggestion on `match_wildcard_for_single_variants`
2021-04-02 12:42:40 +00:00
Yoshitomo Nakanishi
9f6f001988 same_item_push: Don't trigger same_item_push if the vec is used in the loop body 2021-04-02 16:28:16 +09:00
Cameron Steffen
08a8ad3a36 Remove paths from bind_instead_of_map 2021-04-01 15:41:25 -05:00
bors
72eb60a28b Auto merge of #7013 - Y-Nak:fix-needless-paren, r=flip1995
clippy_utils: fix needless parenthesis output from sugg::Sugg::maybe_par

changelog: clippy_utils: fix needless parenthesis output from `sugg::Sugg::maybe_par`

fixes: #6767
2021-04-01 15:09:46 +00:00
bors
92c4fc3cd8 Auto merge of #7011 - Jarcho:redundant_clone_fp, r=flip1995
Fix `redundant_clone` fp

fixes: #5973
fixes: #5595
fixes: #6998

changelog: Fix `redundant_clone` fp  where the cloned value is modified while the clone is in use.
2021-04-01 14:06:04 +00:00
bors
38b1fd0fa7 Auto merge of #7002 - mgacek8:issue6983_wrong_self_convention_inside_trait_impls, r=phansch
wrong_self_convention: fix FP inside trait impl for `to_*` method taking `&self`

fixes #6983
changelog: `wrong_self_convention`: fix FP inside trait impl for `to_*` method taking `&self`
2021-04-01 05:48:16 +00:00
bors
75d73e95a0 Auto merge of #6976 - Jarcho:manual_map_const, r=phansch
Don't lint `manual_map` in const functions

fixes: #6967

changelog: Don't lint `manual_map` in const functions
2021-04-01 05:34:34 +00:00
Yoshitomo Nakanishi
6325fe1f54 clippy_utils: fix needless parenthesis output from sugg::Sugg::maybe_par 2021-04-01 10:40:44 +09:00
bors
8cf7d9b037 Auto merge of #7010 - camsteffen:if-chain-lint, r=llogiq
Internal `if_chain!` lints

changelog: none

We use `if_chain!` a lot. So this enforces some style rules around it, internal only.

Lints when...
* Nested `if`/`if_chain!` can be collapsed
* An `if_chain!` starts with `let` or ends with `let ..; then {..}`
* An `if_chain!` has only one `if`
* An `if_chain!` contains `if .. && ..;` that spans multiple lines
2021-03-31 21:57:48 +00:00
Jason Newcomb
aaba9b78a2
Fix redundant_clone fp where the cloned value is modified while the clone is in use. 2021-03-31 15:35:34 -04:00
Cameron Steffen
827d6aaad4 Eat dogfood 2021-03-31 14:06:27 -05:00
Cameron Steffen
5f887d09b8 Add if_chain lints 2021-03-31 14:06:27 -05:00
bors
459bca84b7 Auto merge of #7008 - matthiaskrgr:ltchk, r=camsteffen
lintcheck: warn if we get a bad exit status while running clippy

Right now we won't notice if a crate fails to build.
Print a warning message to indicate that there is a problem of some sort.
I'll still have to do more investigation on why this actually happens.

I suspect that the problem is that `clippy fix` might run  --all-targets  but when we download the crate source from crates.io, some path deps (used for internal tests etc...) are not available (which is usually not a problem because the internal tests are not needed when using the crate as a lib..?)

changelog: none
2021-03-31 18:58:52 +00:00
bors
487c2e8d4e Auto merge of #6913 - camsteffen:method-chain, r=flip1995
Destructure args in `methods`

changelog: none

This changes the main pattern in `methods` to match and destructure the method call args at the same time as the method name, and pass individual arg `Expr`s to the lint impls.

```rust
// before
["expect", ..] => expect::check(cx, expr, arg_lists[0]);
// after
("expect", [arg]) => expect::check(cx, expr, recv, arg);
```

This makes the code safer since there is no risk of out of bounds `args[n]` everywhere. There will be no more collecting `method_names`, `arg_lists`, `method_spans` as a separate step - everything comes out of the `match`es. Chained methods are parsed in a nested `match`. This makes the code more verbose in some ways, but IMO it is much easier to follow.

~Definitely should wait for #6896. Just putting out the idea.~
2021-03-31 18:30:32 +00:00
Cameron Steffen
21083875d2 Destructure args in methods module 2021-03-31 13:25:55 -05:00
bors
775ef473d7 Auto merge of #6342 - bbqbaron:issue-6061, r=flip1995
Lint: filter(Option::is_some).map(Option::unwrap)

Fixes #6061

*Please write a short comment explaining your change (or "none" for internal only changes)*
changelog:
* add new lint for filter(Option::is_some).map(Option::unwrap)

First Rust PR, so I'm sure I've violated some idioms. Happy to change anything.

I'm getting one test failure locally -- a stderr diff for `compile_test`. I'm having a hard time seeing how I could be causing it, so I'm tentatively opening this in the hopes that it's an artifact of my local setup against `rustc`. Hoping it can at least still be reviewed in the meantime.

I'm gathering that since this is a method lint, and `.filter(...).map(...)` is already checked, the means of implementation needs to be a little different, so I didn't exactly follow the setup boilerplate. My way of checking for method calls seems a little too direct (ie, "is the second element of the expression literally the path for `Option::is_some`?"), but it seems like that's how some other lints work, so I went with it. I'm assuming we're not concerned about, eg, closures that just end up equivalent to `Option::is_some` by eta reduction.
2021-03-31 16:19:07 +00:00
bors
c1021b806c Auto merge of #6706 - Y-Nak:excessive-for-each, r=camsteffen
New Lint: needless_for_each

resolves: #6543

changelog: Added pedantic lint: `needless_for_each`
2021-03-31 15:59:55 +00:00
Eric Loren
56fbbf7b8f Suggest flatten instead of is_some -> unwrap 2021-03-31 11:35:24 -04:00
Yoshitomo Nakanishi
e61f9782c8 Tweak a suggestion message of needless_for_each 2021-04-01 00:08:59 +09:00
Yoshitomo Nakanishi
bf1e3f7a9f Skip needless_for_each if an input stmt is local 2021-04-01 00:05:42 +09:00
Yoshitomo Nakanishi
1109dc8838 Fix codes that make dogfood fail 2021-04-01 00:05:42 +09:00
Yoshitomo Nakanishi
f2cc995bcf Remove method_calls 2021-04-01 00:05:42 +09:00
Yoshitomo Nakanishi
527fbbef48 Refactor excessive_for_each 2021-04-01 00:05:42 +09:00
Yoshitomo Nakanishi
5543c34699 Use ".." as default value of snippet in excessive_for_each 2021-04-01 00:05:42 +09:00
Yoshitomo Nakanishi
3843171299 Improve the document of excessive_for_each 2021-04-01 00:05:42 +09:00
Yoshitomo Nakanishi
25d8b94cec Add comments to clarify why RetCollector is needed 2021-04-01 00:05:42 +09:00
Yoshitomo Nakanishi
ccd7a60023 Refactor: Remove duplicated codes from excessive_for_each 2021-04-01 00:05:42 +09:00
Yoshitomo Nakanishi
90cbbb2da3 Avoid to suggest using label 2021-04-01 00:05:42 +09:00
Yoshitomo Nakanishi
5bb0f16552 Trigger the lint iff exposure's body is ExprKind::Block. 2021-04-01 00:05:42 +09:00