Commit graph

5041 commits

Author SHA1 Message Date
bors
cb0132d209 Auto merge of #7865 - Herschel:fix-match-str-case-mismatch, r=xFrednet
Fix `match_str_case_mismatch` on uncased chars

False positives would result because `char::is_lowercase` and friends will return `false` for non-alphabetic chars and alphabetic chars lacking case (such as CJK scripts). Care also has to be taken for handling titlecase characters (`Dz`) and lowercased chars with no uppercase equivalent (`ʁ`).

For example, when verifying lowercase:
 * Check `!any(char::is_ascii_uppercase)` instead of `all(char::is_ascii_lowercase)` for ASCII.
 * Check that `all(|c| c.to_lowercase() == c)` instead of `all(char::is_lowercase)` for non-ASCII

Fixes #7863.

changelog: Fix false positives in [`match_str_case_mismatch`] on uncased characters
2021-10-25 21:34:11 +00:00
xFrednet
7517ae2fb3 Refactored some string handling to prevent ICEs and FNs 2021-10-24 22:47:39 +02:00
Esteban Kuber
f674e6f49c Always sort suggestions before emitting them 2021-10-24 20:28:44 +00:00
Mike Welsh
e953dff536 Fix match_str_case_mismatch false positives
Properly consider uncased and titlecased characters.
Fixes #7863.
2021-10-23 02:03:15 -07:00
bors
df65291edd Auto merge of #7856 - Manishearth:impl-safety, r=xFrednet
missing_safety_doc: Handle 'implementation safety' headers as well

We hit some FPs on this in `yoke`, it's somewhat normal to mark trait impl safety with "implementation safety". We could also broaden the check for headers which contain the word "safety" somehow, or split out impl safety stuff to only apply to traits.

changelog: handle 'implementation safety' headers in `missing_safety_doc`
2021-10-21 21:51:24 +00:00
bors
2ba1a6a331 Auto merge of #7801 - aDotInTheVoid:empty-format, r=camsteffen
Make useless_format recognize format!("")

Closes #7796

changelog: [`useless_format`] Fix for false negitive for `format!("")`
2021-10-21 18:15:23 +00:00
bors
c97a06d9af Auto merge of #7850 - ThibsG:PossibleCastTruncation5395, r=camsteffen
Fix FP: no lint when cast is coming from `signum` method call for `cast_possible_truncation` lint

Fixes a FP when cast is coming from `signum` method call

fixes: #5395

changelog: [`cast_possible_truncation`] Fix FP when cast is coming from `signum` method call
2021-10-21 18:01:39 +00:00
Nixon Enraght-Moony
081d0f82f4 Make useless_format recognize format!("")
Closes #7796
2021-10-21 19:01:28 +01:00
ThibsG
566244a8bc Do not lint when cast is coming from signum method call 2021-10-21 19:15:26 +02:00
Manish Goregaokar
1e8d9fb18c Handle 'implementation safety' headers as well 2021-10-21 08:50:50 -07:00
flip1995
7631fc5d82 Merge commit '91496c2ac6abf6454c413bb23e8becf6b6dc20ea' into clippyup 2021-10-21 13:11:36 +02:00
flip1995
085181e29d
Merge remote-tracking branch 'upstream/master' into rustup 2021-10-21 12:18:12 +02:00
bors
300b821d51 Auto merge of #7838 - nhamovitz:trailing_zs_arr_wo_repr, r=Manishearth
Warn on structs with a trailing zero-sized array but no `repr` attribute

Closes #2868

changelog: Implement ``[`trailing_empty_array`]``, which warns if a struct is defined where the last field is a zero-sized array but there are no `repr` attributes. Zero-sized arrays aren't very useful in Rust itself, so such a struct is likely being created to pass to C code or in some other situation where control over memory layout matters. Either way, a `repr` attribute is needed.
2021-10-20 20:35:58 +00:00
bors
f11905af15 Auto merge of #7849 - ThibsG:SafetyDoc, r=llogiq
FIx FP in `missing_safety_doc` lint

Fix FP where lint souldn't fire if any parent has `#[doc(hidden)]` attribute

fixes: #7347

changelog: [`missing_safety_doc`] Fix FP if any parent has `#[doc(hidden)]` attribute
2021-10-20 16:46:38 +00:00
ThibsG
3630afb57f Do not lint if any parent has hidden attribute 2021-10-20 17:53:05 +02:00
bors
06722c0c15 Auto merge of #7775 - F3real:no_effect, r=xFrednet
Detect underscored variables with no side effects

Fixes #7545

changelog: Lint on underscored variables with no side effects in [`no_effect`]
2021-10-20 09:33:45 +00:00
bors
ee8c155527 Auto merge of #7840 - dswij:question-mark-result, r=llogiq
Cover `Result` for `question_mark`

closes #7135

changelog: [`question_mark`] now covers `Result`
2021-10-20 07:27:13 +00:00
Michael Wright
c4d5471a45 Add test for #7829 2021-10-20 06:13:42 +02:00
F3real
6b22bba902 Lint on underscore variable assignment
Fix tests after no_effect update

Add a drop testcase

Don't lint _ variables in macro expansion

Address review comments and update tests

Don't shadow unnecessary operation lint if no_effect is allowed

Revert shadowing change and remove no_effect allows

Update clippy_lints/src/no_effect.rs

Co-authored-by: Takayuki Nakata <f.seasons017@gmail.com>

Update clippy_lints/src/no_effect.rs

Co-authored-by: Takayuki Nakata <f.seasons017@gmail.com>

Address review comments
2021-10-20 00:39:28 +02:00
Nathaniel Hamovitz
0f9f591e30 Rename lint 2021-10-19 14:33:43 -07:00
Nathaniel Hamovitz
60da4c9cb6 remove resolved note 2021-10-19 14:23:55 -07:00
bors
c1e7a07c9c Auto merge of #7811 - rust-lang:eq-op-testless, r=xFrednet
avoid `eq_op` in test code

Add a check to `eq_op` that will avoid linting in functions annotated with `#[test]`

---

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

changelog: avoid `eq_op` in test functions
2021-10-19 19:54:40 +00:00
Andre Bogus
e88c956e1e avoid eq_op in test code 2021-10-19 21:02:30 +02:00
dswij
3fc99b6a33 Update test for question_mark to cover Result 2021-10-19 18:50:49 +08:00
Nathaniel Hamovitz
c654cc56da One more test + final tidying 2021-10-18 17:41:27 -07:00
Nathaniel Hamovitz
6303d2d075 Revert "!: this is the commit that demonstrates the ICE"
This reverts commit d85f903c91.
2021-10-18 17:18:07 -07:00
Nathaniel Hamovitz
d85f903c91 !: this is the commit that demonstrates the ICE 2021-10-18 17:07:51 -07:00
Nathaniel Hamovitz
ab9fa25e82 Better testcase names 2021-10-18 04:59:03 -07:00
Nathaniel Hamovitz
d25b4eeefb One more test 2021-10-18 04:22:43 -07:00
Nathaniel Hamovitz
5b78907be7 Still renaming lmao 2021-10-18 03:56:49 -07:00
Nathaniel Hamovitz
a6aa9864a3 Rename stderr 2021-10-18 03:52:37 -07:00
Nathaniel Hamovitz
7f84e3d791 Rename lint 2021-10-18 03:45:08 -07:00
Nathaniel Hamovitz
6377fb2fe7 Tidy import + update expected stderr 2021-10-18 03:13:48 -07:00
Nathaniel Hamovitz
c5d3167a23 update testsuite and expand if_chain 2021-10-18 03:05:19 -07:00
Nathaniel Hamovitz
a3420f7004 Tidy comments + tests; revert 'size-is-zero' detection 2021-10-18 03:05:19 -07:00
Nathaniel Hamovitz
9b3f55ee61 tried to simplify but it doesn't work :/ 2021-10-18 03:05:19 -07:00
Nathaniel Hamovitz
5fdf93415b intermediate step 2021-10-18 03:05:19 -07:00
Nathaniel Hamovitz
003972f428 add multiple get_attrs and includes_repr and they all work! 2021-10-18 03:05:18 -07:00
Nathaniel Hamovitz
b9948c4be6 Ran dev bless! 2021-10-18 03:05:18 -07:00
Nathaniel Hamovitz
4b4db59772 output looks fantastic 2021-10-18 03:05:18 -07:00
Nathaniel Hamovitz
e53a4da4a1 it works i think (incl some dbgs) 2021-10-18 03:05:18 -07:00
Nathaniel Hamovitz
7ee8e7a9b8 Implement detecting trailing zero-sized array 2021-10-18 03:05:18 -07:00
Nathaniel Hamovitz
c69387a0d5 Well it builds 2021-10-18 03:05:18 -07:00
Nathaniel Hamovitz
797507c583 Add boilerplate and basic tests 2021-10-18 03:05:18 -07:00
Matthias Krüger
e84537bcdd Rollup merge of #89990 - petrochenkov:idempty, r=wesleywiser
rustc_span: `Ident::invalid` -> `Ident::empty`

The equivalent for `Symbol`s was renamed some time ago (`kw::Invalid` -> `kw::Empty`), and it makes sense to do the same thing for `Ident`s as well.
2021-10-18 08:13:30 +02:00
Vadim Petrochenkov
5f2ecc37f8 rustc_span: Ident::invalid -> Ident::empty
The equivalent for `Symbol`s was renamed some time ago (`kw::Invalid` -> `kw::Empty`), and it makes sense to do the same thing for `Ident`s.
2021-10-17 23:20:30 +03:00
Matthias Krüger
79b73ac98d Rollup merge of #89963 - r00ster91:parenthesisparentheses, r=nagisa
Some "parenthesis" and "parentheses" fixes

"Parenthesis" is the singular (e.g. one `(` or one `)`) and "parentheses" is the plural (multiple `(` or `)`s) and this is not hard to mix up so here are some fixes for that.

Inspired by #89958
2021-10-17 18:18:59 +02:00
Paul Gey
a550133b8f Fix false positive of implicit_saturating_sub with else clause
Fixes #7831
2021-10-17 15:56:59 +02:00
r00ster91
599d9126a2 Some "parenthesis" and "parentheses" fixes 2021-10-17 12:04:01 +02:00
bors
e1871ba0da Auto merge of #7743 - smoelius:master, r=camsteffen
Add `format_in_format_args` and `to_string_in_format_args` lints

Fixes #7667 and #7729

I put these in `perf` since that was one of `@jplatte's` suggestions, and `redundant_clone` (which I consider to be similar) lives there as well.

However, I am open to changing the category or anything else.

r? `@camsteffen`

changelog: Add `format_in_format_args` and `to_string_in_format_args` lints
2021-10-15 17:05:13 +00:00
Samuel E. Moelius III
47014d81a1 Fix adjacent tests 2021-10-15 12:44:49 -04:00
Samuel E. Moelius III
c9599d79a3 Add format_in_format_args and to_string_in_format_args lints
Fixes #7667 and #7729
2021-10-15 12:44:38 -04:00
bors
db403bb889 Auto merge of #7823 - mikerite:match-overlapping-arm-20211015, r=xFrednet
Some small improvements to the `match_overlapping_arm` tests

changelog: none
2021-10-15 12:42:16 +00:00
dswij
e4ac4c2e1a Add test on unnecessary_sort_by when argument does not implement Ord 2021-10-15 18:12:47 +08:00
Cameron Steffen
0a23fff82d Fix clippy with changed macro statement spans 2021-10-15 02:36:58 -05:00
Michael Wright
28a249b53e Add unbounded pats to match_overlapping_arm tests 2021-10-15 06:25:11 +02:00
Michael Wright
e664a76add Refactor overlapping arm tests
Make the `println!`s match the patterns. Currently they are using the
deprecated syntax for inclusive ranges and extra spacing.
2021-10-15 06:20:28 +02:00
bors
b9b11a96d2 Auto merge of #7805 - aDotInTheVoid:transmute-num-bits, r=camsteffen
Add lint transmute_num_to_bytes

Closes #7803

changelog: [`transmute_num_to_bytes`] new lint
2021-10-13 19:40:33 +00:00
Nixon Enraght-Moony
58969807ab Add lint transmute_num_to_bytes
Closes #7803

changelog: [`transmute_num_to_bytes`] new lint
2021-10-13 20:05:05 +01:00
bors
57dc0343bd Auto merge of #7788 - flip1995:eq_if_let_sugg, r=giraffate
Do not expand macros in equatable_if_let suggestion

Fixes #7781

Let's use Hacktoberfest as a motivation to start contributing PRs myself again :)

changelog: [`equatable_if_let`]: No longer expands macros in the suggestion
2021-10-13 12:04:57 +00:00
Oli Scherer
049ab82662 Update clippy ui output 2021-10-13 11:06:14 +00:00
bors
3d9c4a655b Auto merge of #7682 - Qwaz:uninit_vec, r=xFrednet
Implement uninit_vec lint

changelog: add the new lint [`uninit_vec`]

Fix #7681
2021-10-12 21:04:13 +00:00
bors
d3905af454 Auto merge of #7806 - Serial-ATA:lint-match-case-mismatch, r=llogiq
Add match_str_case_mismatch lint

changelog: Added a new lint [`match_str_case_mismatch`]

Fixes #7440
2021-10-12 18:39:09 +00:00
Serial
0c99de0ab2 Add a suggestion 2021-10-12 07:13:19 -04:00
bors
175738677c Auto merge of #89770 - jkugelman:must-use-from-and-into, r=joshtriplett
Add #[must_use] to From::from and Into::into

Risk of churn: **High**
Magic 8-Ball says: **Outlook not so good**

I figured I'd put this out there. If we don't do it now maybe we save it for a rainy day.

Parent issue: #89692

r? `@joshtriplett`
2021-10-12 09:43:37 +00:00
Serial
9e0ce14700 Add match_str_case_mismatch lint 2021-10-11 20:19:34 -04:00
bors
77dda9c6b1 Auto merge of #7791 - JamesHinshelwood:reason-in-disallowed-type, r=giraffate
Allow giving reasons for `disallowed_types`

Similar to #7609 but for the `disallowed_type` lint. The permitted form of configuration is the same as for `disallowed_methods`.

changelog: Allow giving reasons for [`disallowed_type`]
2021-10-12 00:17:37 +00:00
John Kugelman
44db271272 Add #[must_use] to From::from and Into::into 2021-10-11 18:10:30 -04:00
flip1995
f44a904a56 Deprecate mem_discriminant_non_enum
This lint has been uplifted and is now included in
enum_intrinsics_non_enums.
2021-10-11 10:10:16 +02:00
bors
bc9ad848eb Auto merge of #7795 - ThibsG:MutMut6922, r=giraffate
Fix FP in external macros for `mut_mut` lint

Fix FP in `mut_mut` lint when type is defined in external macros.

fixes: #6922

changelog: [`mut_mut`] Fix FP when type is defined in external macros
2021-10-11 01:14:53 +00:00
bors
9205e3d800 Auto merge of #7800 - 1nF0rmed:no-lint-in-match-single-amp, r=llogiq
Refactor `clippy::match_ref_pats` to check for multiple reference patterns

fixes #7740

When there is only one pattern, to begin with, i.e. a single deref(`&`), then in such cases we suppress `clippy::match_ref_pats`.
This is done by checking the count of the reference pattern and emitting `clippy::match_ref_pats` when more than one pattern is present.

Removed certain errors in the `stderr` tests as they would not be triggered.

changelog: Refactor `clippy::match_ref_pats` to check for multiple reference patterns
2021-10-10 11:13:05 +00:00
1nF0rmed
1080f6c70c Adds additional tests for lint 2021-10-10 14:46:28 +05:30
1nF0rmed
fc32425521 Refactor to check for multiple reference patterns 2021-10-09 22:30:12 +05:30
ThibsG
1e18b8a269 Fix FP in external macros for mut_mut lint 2021-10-09 15:54:16 +02:00
ThibsG
7aaed02b8c Fix false positive when Drop and Copy involved 2021-10-09 14:56:33 +02:00
Yechan Bae
2181387c3a Improved error message for set_len() on empty Vec 2021-10-09 05:47:07 -04:00
Yechan Bae
de0d2b1500 Add testcases 2021-10-09 05:47:07 -04:00
Yechan Bae
b1aa3064b6 Address PR comments 2021-10-09 05:47:06 -04:00
Yechan Bae
fdc06d9b2b Improve error messages 2021-10-09 05:38:19 -04:00
Yechan Bae
759200b699 Handle PR feedbacks first round 2021-10-09 05:38:19 -04:00
Yechan Bae
452181c69d Implement uninit_vec lint 2021-10-09 05:38:19 -04:00
James Hinshelwood
72078faf91
Allow giving reasons for disallowed_types
Co-authored-by: James Hinshelwood <james.hinshelwood@bigpayme.com>
2021-10-08 20:47:52 +01:00
flip1995
b423b85ca9
Don't trigger semicolon_if_nothing_returned in expanded code
Before this lint didn't trigger on macros. With rust-lang/rust#88175
this isn't enough anymore. In this PR a `WhileLoop` desugaring kind was
introduced. This overrides the span of expanded expressions when
lowering the while loop. So if a while loop is in a macro, the
expressions that it expands to are no longer marked with
`ExpnKind::Macro`, but with `ExpnKind::Desugaring`. In general, this is
the correct behavior and the same that is done for `ForLoop`s. It just
tripped up this lint.
2021-10-08 16:16:56 +02:00
flip1995
28fb591b6e
Do not expand macros in equatable_if_let suggestion 2021-10-08 15:26:10 +02:00
Serial
412b862fba Add undocumented_unsafe_blocks lint 2021-10-07 17:06:21 -04:00
bors
8aff5dd570 Auto merge of #7705 - michaelsproul:fn_to_numeric_cast_any, r=camsteffen
Restriction lint for function pointer casts

The existing lints for function pointer casts cover the cases where a cast is non-portable or would result in truncation, however there's currently no way to forbid numeric function pointer casts entirely.

I've added a new lint `fn_to_numeric_cast_any`, which allows one to ban _all_ numeric function pointer casts, including to `usize`. This is useful if you're writing high-level Rust and want to opt-out of potentially surprising behaviour, avoiding silent bugs from forgotten parentheses, e.g.

```rust
fn foo() -> u32 {
    10
}

fn main() {
    let _ = foo as usize; // oops, forgot to call foo and got a random address instead!
}
```

~~I'm open to suggestions for the naming of the lint, because `fn_to_numeric_cast_any` is a bit clunky. Ideally I'd call this lint `fn_to_numeric_cast`, but that name is already taken for the more specific lint~~. We've stuck with `fn_to_numeric_cast_any` to avoid renaming the existing lint, or choosing a different name that's too generic (like `fn_cast`).

I'm also open to changing the suggestion behaviour, as adding parentheses is only one of many possible ways to fix the lint.

changelog: add ``[`fn_to_numeric_cast_any`]`` restriction lint
2021-10-07 14:14:19 +00:00
Michael Sproul
fbd0fb9aed Restriction lint for function pointer casts 2021-10-07 09:11:47 -05:00
bors
872f3213f2 Auto merge of #7782 - dswij:shadow-unrelated-block, r=flip1995
Make `shadow_reuse` suggestion less verbose

Closes #7764

Make `shadow_reuse` suggestion less verbose.

changelog: [`shadow_reuse`] does not warn shadowing statement
2021-10-07 09:49:19 +00:00
bors
a04a7cd9f9 Auto merge of #7779 - rust-lang:test_module, r=flip1995
make test module detection more strict

I started with some small improvements to clippy_utils/src/lib.rs, but then found that our "test" module detection would also catch words containing "test" like e.g. "attestation". So I made this a bit more strict (splitting by `'_'` and checking for `test` or `tests`), adding a test case as I went.

---

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

changelog: none
2021-10-07 09:36:51 +00:00
flip1995
5cf4984872 Merge commit 'b7f3f7f6082679da2da9a0b3faf1b5adef3afd3b' into clippyup 2021-10-07 11:21:30 +02:00
flip1995
1f955158dd
Merge remote-tracking branch 'upstream/master' into rustup 2021-10-07 11:11:23 +02:00
dswij
64f8b9d0ea Make shadow_reuse suggestion less verbose 2021-10-07 16:50:13 +08:00
Andre Bogus
86811e9b1b make test module detection more strict 2021-10-07 00:14:06 +02:00
Manish Goregaokar
2a8d7bd0dd Handle intra-doc links in doc_markdown 2021-10-06 08:38:35 -07:00
Manish Goregaokar
80408ef8dc Add regression test for #7758 2021-10-06 08:31:14 -07:00
dswij
e476d05c8f Add tests for zero exponents in excessive_precision 2021-10-06 15:33:05 +08:00
Matthias Kaak
7c82e78f30 improved help message for suspicious_map 2021-10-05 19:09:08 +00:00
hkalbasi
388a3d0983 Implement equatable if let lint 2021-10-04 22:16:42 +03:30
Takayuki Nakata
72f0180f7b Fix ICE in implicit_hasher 2021-10-04 23:31:40 +09:00
bors
87bb18e7c2 Auto merge of #88175 - camsteffen:let-desugar-span, r=Manishearth
Add expansion to while desugar spans

In the same vein as #88163, this reverts a change in Clippy behavior as a result of #80357 (and reverts some `#[allow]`s): This changes `clippy::blocks_in_if_conditions` to not fire on `while` loops. Though we might actually want Clippy to lint those cases, we should introduce the change purposefully, with tests, and possibly under a different lint name.

The actual change here is to add a desugaring expansion to the spans when lowering a `while` loop.

r? `@Manishearth`
2021-10-03 21:44:10 +00:00
bors
63b04f7d7f Auto merge of #7755 - HKalbasi:master, r=xFrednet
exclude enum from derivable impls

fix #7753

changelog: Exclude enum from ``[`derivable_impls`]``
2021-10-03 10:30:16 +00:00
bors
33c34fb2d7 Auto merge of #7709 - Qwaz:drop_non_send, r=xFrednet
Implement `non_send_field_in_send_ty` lint

changelog: Implement [`non_send_fields_in_send_ty`] lint

Fixes #7703
2021-10-03 08:43:32 +00:00
hkalbasi
ea8e65f0da exclude enum from derivable impls 2021-10-03 11:58:27 +03:30
Cameron Steffen
e165c12932 Make diangostic item names consistent 2021-10-02 19:38:19 -05:00
Yechan Bae
fb0353b28d Update documentation and name for non_send_fields_in_send_ty lint 2021-10-02 19:22:37 -04:00
Cameron Steffen
9c2d52fabe Add desugaring mark to while loop 2021-10-02 17:41:14 -05:00
Manish Goregaokar
6bf5c0b185 Correctly handle signs in exponents in numeric_literal::format() 2021-10-01 17:27:47 -07:00
Manish Goregaokar
51160808b8 Add regression test 2021-10-01 16:14:35 -07:00
Yechan Bae
ef8df9df68 Forgot to bless ui-toml test 2021-10-01 14:26:04 -04:00
Yechan Bae
dfed2e31d5 Do not use full type path in help message 2021-10-01 14:04:20 -04:00
Yechan Bae
4f01656a7d Add ui-test for enable-raw-pointer-heuristic-for-send config 2021-10-01 14:04:20 -04:00
Yechan Bae
08f0aecffd Minor changes from PR feedback 2021-10-01 14:04:20 -04:00
Yechan Bae
427a09ba7b Add configuration for raw pointer heuristic 2021-10-01 14:04:20 -04:00
Yechan Bae
d413e157a5 Look into tuple, array, ADT args in raw pointer heuristic 2021-10-01 14:04:20 -04:00
Yechan Bae
ee74574876 Emit one report for all fields in the same ADT 2021-10-01 14:04:20 -04:00
Yechan Bae
d7a9ec2c50 Fix attribute handling 2021-10-01 14:04:20 -04:00
Yechan Bae
e4c3000e5b Initial implementation 2021-10-01 14:04:20 -04:00
bors
fe999e88ed Auto merge of #7741 - surechen:fix_if_then_panic, r=flip1995
Make if_then_panic handle situation of BinOpKind::And || BinOpKind::Or

fixes #7731

Make if_then_panic handle situation of cond.kind = ExprKind::DropTemps(ExprKind::Binary(BinOpKind::And || BinOpKind::Or, left, right), ..) =

changelog: [`if_then_panic`] Fix suggestion for more complex conditions
2021-10-01 10:04:19 +00:00
surechen
41e2c68a6e use sugg::Sugg::maybe_par 2021-10-01 13:13:09 +08:00
Manish Goregaokar
730d86f521 Rollup merge of #88782 - asquared31415:issue-79559, r=cjgillot
Fix ICE when `start` lang item has wrong generics

In my previous pr #87875 I missed the requirements on the `start` lang item due to its relative difficulty to test and opting for more conservative estimates.  This fixes that by updating the requirement to be exactly one generic type.

The `start` lang item should have exactly one generic type for the return type of the `main` fn ptr passed to it.  I believe having zero would previously *sometimes* compile (often with the use of `fn() -> ()` as the fn ptr but it was likely UB to call if the return type of `main` was not `()` as far as I know) however it also sometimes would not for various errors including ICEs and LLVM errors depending on exact situations.  Having more than 1 generic has always failed with an ICE because only the one generic type is expected and provided.

Fixes #79559, fixes #73584, fixes #83117 (all duplicates)
Relevant to #9307

r? ````@cjgillot````
2021-09-30 18:05:20 -07:00
Cameron Steffen
a17359c696 Remove shadow allows 2021-09-30 14:07:58 -05:00
Cameron Steffen
8c0e4d5ccf Rewrite shadow lint 2021-09-30 14:07:58 -05:00
Cameron Steffen
99861c0e88 Remove initialization note from shadow lint 2021-09-30 13:54:30 -05:00
bors
a893eb993b Auto merge of #7677 - surechen:edit_large_enum_variant, r=camsteffen
fix bug for large_enum_variants

Fix the discussion problem in the issue of https://github.com/rust-lang/rust-clippy/issues/7666#issuecomment-919654291

About the false positive problem of case:
```rust
enum LargeEnum6 {
    A,
    B([u8;255]),
    C([u8;200]),
}
```

changelog: Fix largest_enum_variant wrongly identifying the second largest variant.
2021-09-30 12:45:17 +00:00
surechen
4babfae9cb fix issue #7731
Make if_then_else handle situation of cond.kind = ExprKind::DropTemps(ExprKind::Binary(BinOpKind::And || BinOpKind::Or, left, right), ..) =
2021-09-30 19:06:42 +08:00
bors
ab99eec15f Auto merge of #7684 - surechen:solve_derivable_impls, r=flip1995
fix for issue #7683

Fixes #7683.

For Repeat  [x; y] (x is the type and y is the times to repeat) . When y > 32, the compiler will report an error:

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=7148558162685e91056e0550797ea74c

Because 6cdd42f9f8/library/std/src/primitive_docs.rs (L538)
/// Arrays of sizes from 0 to 32 (inclusive) implement [`Default`] trait
/// if the element type allows it. As a stopgap, trait implementations are
/// statically generated up to size 32.

So here to detect this situation.

changelog: [`derivable_impls`]: No longer lints when arrays bigger than 32 elements are involved
2021-09-30 08:19:58 +00:00
surechen
a3d3735515 Arrays of sizes from 0 to 32 (inclusive) implement [Default] trait, edit method is_default_equivalent() to satisfy with this. 2021-09-30 10:41:36 +08:00
surechen
56f0c9afdd fix bug for large_enum_variants 2021-09-30 10:07:57 +08:00
bors
fb17671eb0 Auto merge of #7734 - Manishearth:doc-unsafe-trait, r=camsteffen
Make `doc_unsafe` warn on unsafe traits as well

Fixes #7732

changelog: Make [`doc_unsafe`] warn on unsafe traits as well
2021-09-28 17:09:34 +00:00
flip1995
23d5457e6d Merge commit 'cb7915b00c235e9b5861564f3be78dba330980ee' into clippyup 2021-09-28 18:03:12 +01:00
bors
9fc4b92eb2 Auto merge of #7711 - camsteffen:depinfo-error, r=flip1995
Improve depinfo error

changelog: none

r? `@flip1995`
2021-09-28 16:56:02 +00:00
bors
cb7915b00c Auto merge of #7733 - flip1995:rustup, r=flip1995
Rustup

This needs a review this time. Especially 521bf8f0fa cc `@camsteffen` I think this is necessary now, because `itertools` is no longer a dependency of `clippy_utils` and therefore this path can't be found 🤔

( I forgot about the sync last week. I should get to document this process better, so other people can do it when I'm not around )

changelog: none
2021-09-28 16:42:31 +00:00
Manish Goregaokar
53c534d11b Update clippy_lints/src/doc.rs
Co-authored-by: Cameron Steffen <cam.steffen94@gmail.com>
2021-09-28 09:37:58 -07:00
flip1995
ec38746b4a
Allow internal lint INVALID_PATHS for itertools path
Since clippy_utils doesn't depend on the itertools crate anymore, the
lint can't find the path.
2021-09-28 17:07:51 +01:00
Manish Goregaokar
25850fc264 Make doc_unsafe lint on unsafe traits as well 2021-09-28 08:40:59 -07:00
flip1995
707494eca9
Merge remote-tracking branch 'upstream/master' into rustup 2021-09-28 10:52:31 +01:00
Andrew Pollack
b7d40bc103 Adding new linting 2021-09-27 22:23:17 -07:00
David Tolnay
e63d69244e
Stop suggesting a float truncation that is not shorter 2021-09-25 22:55:23 -07:00
Cameron Steffen
f6c5d580b8 Improve depinfo error 2021-09-24 10:27:11 -05:00
Labelray
543b638dbe Add new lint if_then_panic 2021-09-24 22:14:20 +08:00
bors
cd3f3cf8a8 Auto merge of #7707 - Jarcho:suspicious_else_proc_mac, r=Manishearth
Don't lint `suspicious_else_formatting` inside proc-macros

fixes: #7650

I'll add a test for this one soon.

changelog: Don't lint `suspicious_else_formatting` inside proc-macros
2021-09-23 16:14:29 +00:00
Jason Newcomb
e69154f370
Add test for #7650 2021-09-23 11:22:38 -04:00
bors
ef2e2f0a0c Auto merge of #7693 - F3real:vec2, r=Manishearth
Expand box_vec lint to box_collection

fixed #7451

changelog: Expand `box_vec` into [`box_collection`], and have it error on all sorts of boxed collections
2021-09-22 22:13:13 +00:00
bors
a4a8ec2d52 Auto merge of #7679 - lengyijun:issue4546, r=xFrednet
add #4546 test

changelog: none
fixed #4546

I notice #4546 was fixed some time, I just add the tests.
2021-09-22 09:00:30 +00:00
lengyijun
b68325ecf6 add #4546 test 2021-09-22 16:04:04 +08:00
bors
8a75002930 Auto merge of #7685 - camsteffen:let-else-needless-ret, r=giraffate
Fix needless_return with let-else

changelog: Fix needless_return FP with `let...else`

Fixes #7637
2021-09-22 00:23:23 +00:00
F3real
63ed2f9eb4 Expand BOX_VEC to BOX_COLLECTION 2021-09-20 10:23:55 +02:00
bors
871ad80bb0 Auto merge of #7690 - Jarcho:while_loop_by_ref, r=xFrednet
Change `while_let_on_iterator` suggestion to use `by_ref()`

It came up in the discussion #7659 that suggesting `iter.by_ref()` is a clearer suggestion than `&mut iter`. I personally think they're equivalent, but if `by_ref()` is clearer to people then that should be the suggestion.

changelog: Change `while_let_on_iterator` suggestion when using `&mut` to use `by_ref()`
2021-09-19 17:37:04 +00:00
Cameron Steffen
b36591217d Fix needless_return with let-else 2021-09-18 09:42:51 -05:00
Jason Newcomb
ee6a6b55c4
Change the suggestion for while_let_on_iterator when the iterator cannot be consumed to iter.by_ref() 2021-09-17 21:44:21 -04:00