Commit graph

4966 commits

Author SHA1 Message Date
bors
7cd9bf5af3 Auto merge of #7866 - rust-lang:edition-2021-tests, r=Manishearth
update most tests to 2021 edition

Some tests would no longer work at all, so I added `edition:2015` or `edition:2018` to them.

Notably 2021 panics are not yet detected correctly. Once ready, this closes #7842.

---

changelog: none
2021-11-01 15:18:57 +00:00
Andre Bogus
a4ede72b3d update most tests to 2021 edition 2021-10-30 14:50:53 +02:00
bors
4c70c182c0 Auto merge of #7895 - ahmedkrmn:master, r=Manishearth
Disable "if_not_else" lints from firing on else-ifs

Fixes #7892

1. Convert `['if_not_else']` to `LateLintPass` and use `clippy_utils::is_else_clause` for checking.
2. Update tests.

changelog: [`if_not_else`] now ignores else if statements.
2021-10-29 20:31:51 +00:00
Ahmed Karaman
2f327aaba5
Disable "if_not_else" lints firing on else-ifs
1. Convert IfNotElse to LateLintPass and use clippy_utils::is_else_clause for checking.
2. Handle the case where the span comes from desugaring.
3. Update tests.
2021-10-29 22:07:05 +02:00
bors
dbe167daaa Auto merge of #7890 - Alexendoo:ptr-arg-alias, r=camsteffen
Ignore references to type aliases in ptr_arg

Works using the fact that the hir path will point to a TyAlias, rather than being resolved to the underlying type

Fixes #7699

changelog: [`ptr_arg`] No longer lints references to type aliases
2021-10-29 19:45:26 +00:00
Cameron Steffen
022146d2c3 Rename if_then_panic to manual_assert 2021-10-28 09:41:53 -05:00
Cameron Steffen
d8fcfd7d64 Move if_then_panic to pedantic 2021-10-28 09:38:01 -05:00
bors
7788af9c47 Auto merge of #7891 - giraffate:fix_ice_for_undocumented_unsafe_blocks, r=flip1995
Fix ice in `undocumented_unsafe_blocks`

Fix https://github.com/rust-lang/rust-clippy/issues/7868

changelog: Fix ice in [`undocumented_unsafe_blocks`]
2021-10-28 13:37:40 +00:00
Takayuki Nakata
35bf041c21 Fix ICE in undocumented_unsafe_blocks 2021-10-28 22:10:59 +09:00
bors
89a11564cc Auto merge of #7847 - mikerite:fix-7829, r=flip1995
Fix false positive in `match_overlapping_arm`

Fixes #7829

changelog: Fix false positive in [`match_overlapping_arm`].
2021-10-28 08:59:21 +00:00
bors
ed71addee7 Auto merge of #7885 - devonhollowood:deprecated-cleanup, r=llogiq
Clean up `tests/ui/deprecated.rs`

Clean up `tests/ui/deprecated.rs`

Along with #7884, this fixes #7057

changelog: none
2021-10-27 18:38:38 +00:00
Alex Macleod
e2c30f05c1 Ignore references to type aliases in ptr_arg
Works using the fact that the hir path will point to a TyAlias, rather
than being resolved to the underlying type
2021-10-27 19:08:42 +01:00
bors
962e21cf15 Auto merge of #7875 - mbStavola:unit-hash, r=xFrednet
Add unit-hash lint

changelog: [`unit_hash`] Add lint for hashing unit values

This will lint for situations where the end user is attempting to hash a unit value (`()`), as the implementation in `std` simply [does nothing][impl]. Closes #7159 .

Example:

```rust
().hash(&mut state);

// Should (probably) be replaced with:
0_u8.hash(&mut state);
```

[impl]: a5f164faad/library/core/src/hash/mod.rs (L656)
2021-10-27 14:37:54 +00:00
Matt Stavola
36d4a4ea82
Add unit-hash lint 2021-10-27 06:32:37 -07:00
Takayuki Nakata
73c026b73f Add test case 2021-10-27 09:12:13 +09:00
bors
ba2ac3e263 Auto merge of #7860 - dswij:question-mark-fp, r=giraffate
Fix `question_mark` FP on custom error type

Closes #7859

#7840 aims to ignore `question_mark` when the return type is custom, which is [covered here](df65291edd/tests/ui/question_mark.rs (L144-L149)). But this fails when there is a call in conditional predicate

changelog: [`question_mark`] Fix false positive when there is call in conditional predicate
2021-10-26 23:46:21 +00:00
bors
a48367e21c Auto merge of #7884 - devonhollowood:rename-cleanup, r=xFrednet
Clean up tests/ui/rename.rs

Part one of #7057, cleaning up `tests/ui/rename.rs`. `tests/ui/deprecated.rs` will be updated in a subsequent PR.

changelog: none
2021-10-26 21:16:44 +00:00
Devon Hollowood
ab9a8f24cd Update tests after reviewer suggestions 2021-10-26 14:01:46 -07:00
Devon Hollowood
5733c754d5
Apply suggestions from code review
Co-authored-by: Fridtjof Stoldt <xFrednet@gmail.com>
2021-10-26 13:55:51 -07:00
Devon Hollowood
e48ab448f9 Clean up tests/ui/deprecated.rs
This also removes the uplifted lints from this test suite -- these are now
tested in `tests/ui/rename.rs`
2021-10-26 10:52:35 -07:00
Devon Hollowood
6c89c00a98 Further clean up tests/ui/rename.rs
Now it is just a collection of lints + an empty main function
2021-10-26 10:26:35 -07:00
dswij
2fd168285a Update question_mark test to behave better 2021-10-26 21:21:46 +08:00
dswij
a91ec59460 Update question_mark expected test output 2021-10-26 21:21:46 +08:00
dswij
d4196d0293 Add #7859 FP test case for question_mark 2021-10-26 21:21:46 +08:00
bors
075996efd7 Auto merge of #7878 - rust-lang:string-slice, r=giraffate
new lint: string-slice

This is a restriction lint to highlight code that should have tests containing non-ascii characters. See #6623.

changelog: new lint: [`string-slice`]
2021-10-26 08:11:49 +00:00
Devon Hollowood
d0c04b4d78 Clean up tests/ui/rename.rs 2021-10-26 00:53:53 -07:00
Andre Bogus
999b3004c4 new lint: string-slice 2021-10-26 09:05:28 +02:00
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
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
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