Commit graph

5919 commits

Author SHA1 Message Date
Cameron Steffen
919ed2ba03 Fix needless_quesiton_mark false positive 2021-05-04 16:28:13 -05:00
bors
5e3160ca0b Auto merge of #7156 - hellow554:single_char_strip, r=flip1995
[single_char_pattern] add strip_prefix and strip_suffix

Title says it all. Adjusted ui tests.

I added the second commit in case you don't like that I moved that table into `single_char_pattern.rs` directly. I don't see any reason why it shouldn't be in that file. It isn't used anywhere else.

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

changelog: add strip_prefix and strip_suffix to single_char_pattern lint
2021-05-03 14:44:44 +00:00
Marcel Hellwig
19e7448c7f move PATTERN_METHODS table directly into file
also removed rustfmt::skip
2021-05-03 16:25:05 +02:00
Marcel Hellwig
c080899848 add strip_{prefix,suffix} to PATTERN_METHODS
this will warn, if a single_char_pattern is used in one of the above
methods
2021-05-03 16:18:41 +02:00
Cameron Steffen
499813026f Fix config parsing 2021-05-02 17:50:22 -05:00
Cameron Steffen
857d9f15da Fix error punctuation 2021-05-02 16:56:46 -05:00
Cameron Steffen
1e22e564e4 Refactor config deserialization 2021-05-01 17:38:05 -05:00
Cameron Steffen
b9c8e683d6 Disable default_trait_access in macros 2021-05-01 16:16:32 -05:00
bors
a300b0e66c Auto merge of #7144 - rust-lang:while_immutable_mut_cond, r=flip1995
while_immutable_cond: check condition for mutation

This fixes #6689 by also checking the bindings mutated in the condition, whereas it was previously only checked in the loop body.

---

changelog: Fix FP in [`while_immutable_cond`] where mutation in the loop variable wasn't picked up.
2021-04-30 15:08:27 +00:00
bors
5e49c4bd67 Auto merge of #6951 - Jarcho:implicit_return_fp, r=flip1995
`implicit_return` improvements

fixes: #6940

changelog: Fix `implicit_return` suggestion for async functions
changelog: Improve `implicit_return` suggestions when returning the result of a macro
changelog: Check for `break` expressions inside a loop which are then implicitly returned
changelog: Allow all diverging functions in `implicit_return`, not just panic functions
2021-04-30 14:55:56 +00:00
bors
14f1551075 Auto merge of #7118 - TaKO8Ki:fix-false-positive-in-comparison-chain, r=giraffate
Fix a false-positive inside const fn in `comparison_chain`

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

changelog: fix a false-positive inside const fn in [`comparison_chain`]
2021-04-30 06:30:38 +00:00
Takayuki
0dff377a62 use in_constant 2021-04-30 14:40:35 +09:00
bors
a55912c48e Auto merge of #7141 - camsteffen:conf-file, r=flip1995
Remove leftover plugin conf_file code

changelog: none

Removes dead code that used to support the following syntax:

```rust
#![plugin(clippy(conf_file="path/to/clippy's/configuration"))]
```

RLS (and others?) will need to remove the `&[]` from `clippy_lints::read_conf(&[], sess)`.

r? `@flip1995`
2021-04-29 14:57:24 +00:00
Andre Bogus
63425de77d while_immutable_cond: check condition for mutation 2021-04-29 10:10:58 +02:00
Cameron Steffen
32351d6b9f Remove leftover plugin conf_file code 2021-04-28 16:04:59 -05:00
Matthias Krüger
572c405da0 fix ice when checking rustc libstd
thread 'rustc' panicked at 'index out of bounds: the len is 0 but the index is 0', src/tools/clippy/clippy_lints/src/matches.rs:1595:53
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I don't have a minimised testcase because I don't have time to reduce libstd down to a few lines right now.
2021-04-27 23:16:19 +02:00
bors
9af07e65aa Auto merge of #7138 - mgacek8:issue6808_iter_cloned_collect_FN_with_large_array, r=Manishearth
Fix FN in `iter_cloned_collect` with a large array

fixes #6808
changelog: Fix FN in `iter_cloned_collect` with a large array

I spotted that [is_iterable_array](a362a4d1d0/clippy_lints/src/loops/explicit_iter_loop.rs (L67-L75)) function that `explicit_iter_loop` lint is using only works for array sizes <= 32.
There is this comment:
> IntoIterator is currently only implemented for array sizes <= 32 in rustc

I'm a bit confused, because I read that [IntoIterator for arrays](https://doc.rust-lang.org/src/core/array/mod.rs.html#194-201) with const generic `N` is stable since = "1.0.0". Although Const Generics MVP were stabilized in Rust 1.51.

Should I set MSRV for the current change? I will try to test with older compilers soon.
2021-04-27 13:44:51 +00:00
bors
0a330e6824 Auto merge of #7136 - mgacek8:issue6965_manual_unwrap_or_invalid_sugg_macro_expansion, r=llogiq
manual_unwrap_or: fix invalid code suggestion, due to macro expansion

fixes #6965

changelog: fix invalid code suggestion in `manual_unwrap_or` lint, due to macro expansion
2021-04-26 21:39:40 +00:00
Cameron Steffen
340b570ea0 Refactor MSRV aliases 2021-04-26 16:07:48 -05:00
Cameron Steffen
33ed8b5b24 Remove needless_question_mark MSRV 2021-04-26 16:02:11 -05:00
Mateusz Gacek
d7627dcfc8 Fix FN in iter_cloned_collect with a large array 2021-04-26 13:03:51 -07:00
Mateusz Gacek
84003aa7a1 fix invalid code suggestion in manual_unwrap_or, due to macro expansion 2021-04-26 12:19:23 -07:00
bors
a362a4d1d0 Auto merge of #7134 - camsteffen:copied-msrv, r=Manishearth
Finish MSRV for cloned_instead_of_copied

changelog: none

r? `@Manishearth`
2021-04-26 16:12:04 +00:00
Cameron Steffen
dcf4e07458 Finish MSRV for cloned_instead_of_copied 2021-04-26 11:09:24 -05:00
bors
1bb3b12dfb Auto merge of #7132 - rust-lang:single_element_loop_iter, r=Manishearth
extend `single_element_loop` to match `.iter()`

This extends `single_element_loop` to also match `[..].iter()` in the loop argument. Related to #7125, but not completely fixing it due to the lint only firing if the array expression contains a local variable.

---

changelog: none
2021-04-26 14:28:31 +00:00
Andre Bogus
efc4c6c957 extend single_element_loop to match .iter() 2021-04-26 15:58:58 +02:00
Cameron Steffen
3f5be5e235 Fix cloned_instead_of_copied MSRV 2021-04-25 09:54:04 -05:00
bors
74f55996fe Auto merge of #7120 - cherryblossom000:7106, r=Manishearth
`single_component_path_imports`: ignore `pub(crate) use some_macro;`

Fixes #7106

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

changelog: Ignore exporting a macro within a crate using `pub(crate) use some_macro;` for [`single_component_path_imports`]
2021-04-22 14:36:21 +00:00
bors
0ab7acc890 Auto merge of #7100 - ABouttefeux:unused_io_amount, r=camsteffen
Unused io amount detects `.read().ok()?`

fixes #7096
changelog: unused_io_amount now detect expertion like `.read().ok()?`,  `.read().or_else(|err| ...)?` and similar expressions.
2021-04-22 13:57:06 +00:00
Aliénore Bouttefeux
5625d58f9f add detection unused_io_amount of "or", "or_else" and "ok" 2021-04-22 15:52:42 +02:00
Jason Newcomb
3d793f3111
Minor cleanup of implicit_return 2021-04-22 09:36:49 -04:00
Jason Newcomb
74cf5f2fc6
Fix implicit_return suggestion for async functions 2021-04-22 09:36:32 -04:00
Jason Newcomb
22f8c13cf5
Improve implicit_return
Better suggestions when returning macro calls.
Suggest changeing all the break expressions in a loop, not just the final statement.
Don't lint divergent functions.
Don't suggest returning the result of any divergent fuction.
2021-04-22 09:13:06 -04:00
cherryblossom
b48699e4cf
single_component_path_imports: ignore pub(crate) use some_macro; (fixes #7106) 2021-04-22 19:34:36 +10:00
bors
1f7aef336e Auto merge of #7102 - taralx:taralx-patch-1, r=flip1995
Switch transmute_ptr_to_ptr to "pedantic" class.

Per discussion in https://github.com/rust-lang/rust-clippy/issues/6372, this lint has significant false positives.

changelog: transmute_ptr_to_ptr defaults to "allow".
2021-04-22 08:26:14 +00:00
Takayuki
65778fa5e8 fix a false-positive inside const fn in comparison_chain 2021-04-22 16:58:12 +09:00
bors
79b9eb5371 Auto merge of #7072 - ebobrow:imports-ending-with-self, r=camsteffen
add unnecessary_self_imports lint

fixes #6552

changelog: add `unnecessary_self_imports` lint
2021-04-21 14:47:49 +00:00
Elliot Bobrow
224881b94d add unnecessary_self_imports lint 2021-04-21 07:17:42 -07:00
bors
bbc22e2ef3 Auto merge of #7083 - GuillaumeGomez:bool-assert-eq, r=camsteffen
Add lint to check for boolean comparison in assert macro calls

This PR adds a lint to check if an assert macro is using a boolean as "comparison value". For example:

```rust
assert_eq!("a".is_empty(), false);
```

Could be rewritten as:

```rust
assert!(!"a".is_empty());
```

PS: The dev guidelines are amazing. Thanks a lot for writing them!

changelog: Add `bool_assert_comparison` lint
2021-04-21 13:58:53 +00:00
bors
ec38ea1ac1 Auto merge of #7097 - yawara:fix/7069, r=llogiq
Fixed inconsistent_struct_constructor triggers in macro-generated code

fixes #7069

changelog: `inconsistent_struct_constructor`: Fix FP in macro expansion.
2021-04-20 08:26:21 +00:00
Yawara ISHIDA
6eae905808 Add a test for FP in macro expansion 2021-04-20 13:34:30 +09:00
bors
b7c12f3aab Auto merge of #7092 - basavesh:fix#7066, r=giraffate
useless use of format! should return function directly

fixes #7066

changelog: [`useless_format`] wraps the content in the braces when it's needed.

r? `@giraffate`
2021-04-19 23:06:21 +00:00
Guillaume Gomez
e2e104b993 Add lint to check for boolean comparison in assert macro calls 2021-04-19 22:15:51 +02:00
Basavesh Shivakumar
c6b381c59b useless use of format! should return function directly 2021-04-19 17:20:21 +02:00
bors
fe5cefceba Auto merge of #7101 - camsteffen:flat-map-option, r=giraffate
Add flat_map_option lint

changelog: Add flat_map_option lint

Closes #2241
2021-04-19 13:34:23 +00:00
Andre Bogus
243dc46250 un-double return on try_err 2021-04-18 23:49:54 +02:00
JP Sugarbroad
8b5faf4ab0 Switch transmute_ptr_to_ptr to "pedantic" class.
Per discussion in https://github.com/rust-lang/rust-clippy/issues/6372, this lint has significant false positives.
2021-04-16 14:29:23 -07:00
bors
e441b33ba0 Auto merge of #7099 - ABouttefeux:master, r=llogiq
add type in help message of from_over_into

fixes #7088
changelog: add type in help message of from_over_into
2021-04-16 21:22:24 +00:00
Cameron Steffen
5af078ac1b Add flat_map_option lint 2021-04-16 15:23:49 -05:00
bors
831c15737c Auto merge of #7087 - Jarcho:allman_style_else, r=camsteffen
Allow allman style braces in `suspicious_else_formatting`

fixes: #3864

Indentation checks could be added as well, but the lint already doesn't check for it.

changelog: Allow allman style braces in `suspicious_else_formatting`
2021-04-16 20:16:52 +00:00