Commit graph

12831 commits

Author SHA1 Message Date
bors
5fbfdfa319 Auto merge of #8009 - xFrednet:8004-suboptimal-flops-in-const, r=giraffate
Allow `suboptimal_flops` in const functions

This PR allows `clippy::suboptimal_flops` in constant functions. The check also effects the `clippy::imprecise_flops` lint logic. However, this doesn't have any effects as all functions checked for are not const and can therefore not be found in such functions.

---

changelog: [`suboptimal_flops`]: No longer triggers in constant functions

Closes: rust-lang/rust-clippy#8004
2021-11-22 00:01:49 +00:00
bors
de2208a351 Auto merge of #7997 - surechen:Fixes_7915, r=giraffate
Fixes shadow_same's false positive for #7915

Fix shadow_same's false positive for async function's params(Fixes #7915):

Example Code:
```rust
#![deny(clippy::shadow_same)]

pub async fn foo(_a: i32) {
}
```
Output:
```
error: `_a` is shadowed by itself in `_a
```

Hir:
```rust
pub async fn foo(_a: i32)
 ->
     /*impl Trait*/ #[lang = "from_generator"](move |mut _task_context|
                                                   {
                                                       let _a = _a;
                                                       { let _t = { }; _t }
                                                   })
```

Skip checking async function's params.

changelog: Fix shadow_same's false positive for async function's params
2021-11-21 23:48:24 +00:00
surechen
846c0bef07 Fixes #7915
Fix shadow_same's positive false for async function's params:

Example Code:
```rust
#![deny(clippy::shadow_same)]

pub async fn foo(_a: i32) {
}
```
Output:
```
error: `_a` is shadowed by itself in `_a
```

Hir:
```rust
pub async fn foo(_a: i32)
 ->
     /*impl Trait*/ #[lang = "from_generator"](move |mut _task_context|
                                                   {
                                                       let _a = _a;
                                                       { let _t = { }; _t }
                                                   })
```

Skip checking async function's params.

changelog: Fix shadow_same's positive false for async function's params
2021-11-21 14:28:44 +08:00
bors
32048ebea3 Auto merge of #8011 - birkenfeld:double_backticks, r=xFrednet
Avoid inline hints with double backticks for `doc-markdown`

The easiest route here was to ensure that the suggestion is always shown on
its own line, where no additional backticks are added by the diagnostic formatter.

Fixes #8002

---

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: Avoid inline hints with double backticks for `doc-markdown`
2021-11-20 17:50:50 +00:00
Georg Brandl
0c4055c283 Avoid inline hints with double backticks for doc-markdown 2021-11-20 18:13:24 +01:00
xFrednet
1c8085d705
Allow suboptimal_flops in const functions 2021-11-20 15:39:29 +01:00
bors
827fd501d0 Auto merge of #8000 - Jarcho:nightly_fmt, r=llogiq
Don't check for a nightly toolchain in fmt test

changelog: None
2021-11-20 14:06:17 +00:00
Jason Newcomb
1429949f9f Don't check for a nightly toolchain in fmt test 2021-11-19 19:43:31 -05:00
bors
38bd2514ad Auto merge of #7984 - phansch:disallowed-type-rename, r=xFrednet
Pluralize `disallowed_type` lint

This was brought up in [Zulip] and is also mentioned in the lint naming
conventions. Since this is still a nursery lint, I think there shouldn't
be any problem in renaming it.

[Zulip]: rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/disallow_type.20vs.20disallowed-types

changelog: Rename nursery lint [`disallowed_type`] to [`disallowed_types`].
2021-11-19 13:39:08 +00:00
bors
0d283cc44c Auto merge of #7996 - togami2864:test-map-or-none, r=Manishearth
Add test case for RESULT_MAP_OR_INTO_OPTION

just added test case for RESULT_MAP_OR_INTO_OPTION.
changelog: none
2021-11-19 07:47:39 +00:00
togami2864
cd81bb9dc3 fix stderr 2021-11-19 16:17:17 +09:00
togami2864
abb7155387 add test case for result_map_or_into_option 2021-11-19 16:12:46 +09:00
bors
2776076efa Auto merge of #7977 - Jarcho:multi_needless_borrow, r=xFrednet
Improve `needless_borrow` lint

fixes: #5327
fixes: #1726
fixes: #1212

This is merging `needless_borrow` into the `dereference` pass in preparation for `explicit_auto_deref`. `explicit_auto_deref` needs to implement most of what `needless_borrow` implements in order to work.

There is a minor regression here where `let x: &str = &x.deref()` will trigger `needless_borrow` without triggering `explicit_deref_methods`. Removing the redundant borrow will cause `explicit_deref_methods` to trigger. This will be fixed when `explicit_auto_deref` is implemented.

changelog: Lint `needless_borrow` when a borrow is auto-derefed more than once
changelog: Lint `needless_borrow` in the trailing expression of a block for a match arm
2021-11-18 23:35:03 +00:00
flip1995
9b38fb7b71
Also pluralize disallowed_method(s) lint
To stay consistent with the sister lint disallowed_type, also rename the
disallowed_method lint to disallowed_methods.
2021-11-18 17:37:06 +01:00
Philipp Hansch
a0d81d1327
Pluralize disallowed_type lint filenames
This way they match up with the pluralized lint name as well.
2021-11-18 17:37:06 +01:00
Philipp Hansch
b7f18916fa
Pluralize disallowed_type lint
This was brought up in [Zulip] and is also mentioned in the lint naming
conventions. Since this is still a nursery lint, I think there shouldn't
be any problem in renaming it.

[Zulip]: https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/disallow_type.20vs.20disallowed-types
2021-11-18 17:37:02 +01:00
bors
8dd1bce263 Auto merge of #7994 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2021-11-18 11:31:49 +00:00
flip1995
4bccd59a69
Bump nightly version -> 2021-11-18 2021-11-18 12:22:22 +01:00
flip1995
731dfde267
Merge remote-tracking branch 'upstream/master' into rustup 2021-11-18 12:22:00 +01:00
bors
8536647e61 Auto merge of #7992 - togami2864:fix-typo, r=giraffate
fix typo

just fixed typo

changelog: none
2021-11-18 08:46:52 +00:00
togami2864
b5a61aa901 fix typo 2021-11-18 17:37:00 +09:00
bors
bb58dc84c1 Auto merge of #7968 - Jarcho:manual_map_unsafe, r=xFrednet
Fix `manual_map` with unsafe functions

fixes: #7820
changelog: Fix `manual_map` suggestion when used with unsafe functions and unsafe blocks
2021-11-17 16:20:04 +00:00
bors
6ac42fe6fa Auto merge of #7971 - togami2864:fix/option-map-or-none, r=llogiq
fix suggestion in option_map_or_none

fix: #7960
changelog: change suggestion in the lint rule `option_map_or_none`
2021-11-17 16:01:55 +00:00
togami2864
8e317f5283 fix suggestion message 2021-11-18 00:43:49 +09:00
Jason Newcomb
5f861ee1ae Addition manual_map test for unsafe blocks 2021-11-17 10:39:53 -05:00
Jason Newcomb
8506f66294 Minor simplification to manual_map 2021-11-17 10:36:13 -05:00
togami2864
006c442657 check whether stmts is empty or not in block 2021-11-18 00:36:11 +09:00
bors
d550e5f5e6 Auto merge of #7988 - giraffate:fix_ice_on_undocumented_unsafe_blocks, r=flip1995
Fix ICE on `undocumented_unsafe_blocks`

fix https://github.com/rust-lang/rust-clippy/issues/7979

changelog: Fix ICE on `undocumented_unsafe_blocks`
2021-11-17 15:24:07 +00:00
togami2864
e34927ecf6 add multi-line test case 2021-11-18 00:13:55 +09:00
bors
94ca94fa5f Auto merge of #7898 - F3real:unit_struct, r=camsteffen
Don't show no_effect warning on unit structs implementing fn_once

Fixes #7792

changelog: Don't show [`no_effect`] or [`unecessary_operation`] warning for unit struct implementing FnOnce
2021-11-17 14:09:51 +00:00
Takayuki Nakata
3f3d7c2005 Fix ICE on undocumented_unsafe_blocks 2021-11-17 22:35:01 +09:00
bors
46687f1313 Auto merge of #7896 - surechen:fix_manual_split_once, r=camsteffen
Fix for #7889 and add new lint needless_splitn

fixes: #7889
1. Fix the problem of manual_split_once changing the original behavior.
2. Add a new lint needless_splitn.

changelog: Fix the problem of manual_split_once changing the original behavior and add a new lint needless_splitn.
2021-11-17 01:46:58 +00:00
surechen
c051656c83 fixes: #7889
1. Fix the problem of manual_split_once changing the original behavior.
2. Add a new lint needless_splitn.

changelog: Fix the problem of manual_split_once changing the original behavior and add a new lint needless_splitn.
2021-11-17 08:38:45 +08:00
F3real
e9bf5ec659 Don't show no_effect warning on unit structs implementing fn* traits 2021-11-17 00:50:07 +01:00
bors
83ad51108b Auto merge of #7982 - Blckbrry-Pi:master, r=llogiq
Fix `needless_collect`'s tendency to suggest code requiring multiple mutable borrows of the same value.

Fixes error specified in #7975.

changelog: [`needless_collect`] no longer suggests removal of `collect` when removal would create code requiring mutably borrowing a value multiple times.
2021-11-16 23:01:02 +00:00
Skyler Calaman
c52b389b16 Fix readability suggestions.
1. Make the lifetime contained in LateContext `'tcx`.
2. Fix `'txc` to `'tcx` because it was a typo.
3. Refactor `IterFunctionVisitor`'s `visit_block` method to be more readable.
4. Replace uses of `rustc_middle::ty::TyKind` with `rustc::middle::ty`, and remove the `#[allow(...)]`.

(Thank you llogiq for all these suggestions!)
2021-11-16 11:29:26 -05:00
Skyler Calaman
5b3c00f012 Successfully generalize prevention of suggestions causing multiple mutable borrows.
Also add some more tests to check that it's working.
2021-11-16 09:18:49 -05:00
togami2864
7605bac2cb resolve CI 2021-11-16 23:07:19 +09:00
bors
5b1b65b876 Auto merge of #7639 - Jarcho:whitelist_cheap_functions, r=camsteffen
Improve heuristic for eagerness suggestion

Still to be done:

* a more complete list of cheap functions
* a way to limit the complexity of cheap expressions

changelog: Improve heuristics for `or_fun_call` and `unnecessary_lazy_evaluations`
2021-11-16 03:12:30 +00:00
Jason Newcomb
2938ffd0d9 Improve heuristics for determining whether eager of lazy evaluation is preferred 2021-11-15 20:54:13 -05:00
Jason Newcomb
8ded385ddc Improve needless_borrow lint.
* Lint when a borrow is auto dereferenced more than once
* Lint when the expression is used as the expression of a block for a match arm

Moves `needless_borrow` and `ref_binding_to_reference` to `dereference`
lint pass in preperation for `explicit_auto_deref` lint.
2021-11-15 13:17:59 -05:00
togami2864
0a30fdcd3c move the let statement out of the macro 2021-11-16 03:02:08 +09:00
togami2864
300282c09a fix fmt 2021-11-16 02:53:35 +09:00
togami2864
cd5781648a add comment 2021-11-16 02:30:54 +09:00
togami2864
02e0726149 fix a bug that the closure arguments are not displayed 2021-11-16 02:29:02 +09:00
togami2864
bbffe825ed add reduce_unit_expression 2021-11-16 02:06:31 +09:00
bors
0def42fd7b Auto merge of #7974 - matthiaskrgr:7973_opt_map_or_else_dont_expand_sugg_macro, r=flip1995
option_if_let_else: don't expand macros in suggestion

Fixes #7973

changelog: don't expand macros in suggestion of clippy::option_if_let_else
2021-11-15 10:27:29 +00:00
togami2864
4f71ff3f84 add test case for option_map_or_none 2021-11-15 15:47:57 +09:00
bors
f82bf470d0 Auto merge of #7957 - surechen:fix_for_7854, r=giraffate
Support suggestion for #7854

I think the detection of parking_lot's mutex and rwlock is valuable, so submit this pr, please help judge and review, thank you.

Make let_underscore_lock support parking_lot.(Fixes #7854)

changelog: Make let_underscore_lock support parking_lot
2021-11-15 00:50:28 +00:00
surechen
634e79c655 Support suggestion for #7854
I think the detection of parking_lot's mutex and rwlock is valuable, so submit this pr, please help judge and review, thank you.

Make let_underscore_lock support parking_lot.

changelog: Make let_underscore_lock support parking_lot
2021-11-15 08:36:36 +08:00