Commit Graph

6609 Commits

Author SHA1 Message Date
Philipp Krones 2bc2431fd1
Merge remote-tracking branch 'upstream/master' into rustup 2023-01-27 20:26:35 +01:00
Martin Fischer 20cc72e8a8 Improve span for module_name_repetitions 2023-01-25 07:07:10 +01:00
bors a9c251f11d Auto merge of #10106 - koka831:fix/10084, r=Alexendoo
Fix FP in `unnecessary_safety_comment`

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

changelog: FP: [`unnecessary_safety_comment`]: No longer lints code inside macros
[#10106](https://github.com/rust-lang/rust-clippy/pull/10106)
<!-- changelog_checked -->
2023-01-22 14:10:16 +00:00
Alex Macleod 5f49808bde Add machine applicable suggestion for `bool_assert_comparison` 2023-01-21 17:33:39 +00:00
bors aa0eb7fb1c Auto merge of #10206 - Niki4tap:one_unsafe_op_per_block, r=Alexendoo
Add `multiple_unsafe_ops_per_block` lint

Adds a lint, which restricts an `unsafe` block to only one unsafe operation.

Closes #10064

---

changelog: New lint: [`multiple_unsafe_ops_per_block`]
[#10206](https://github.com/rust-lang/rust-clippy/pull/10206)
<!-- changelog_checked -->
2023-01-19 13:58:09 +00:00
Niki4tap 875e36f7e4 Add `multiple_unsafe_ops_per_block` lint 2023-01-18 10:00:31 +03:00
bors 89d443a4c3 Auto merge of #10193 - Jarcho:issue_9894, r=Manishearth
Fix suggestion in `transmutes_expressible_as_ptr_casts` when the source type is a borrow.

fixes #9894

changelog: `transmutes_expressible_as_ptr_casts`: Fix suggestion when the source type is a borrow.
2023-01-17 14:58:39 +00:00
bors 07a7603994 Auto merge of #10187 - dswij:issue-10182-semicolon, r=Jarcho
[needless_return]: Remove all semicolons on suggestion

Closes #10182

Multiple semicolons currently breaks autofix for `needless_return` suggestions. Any semicolons left after removing return means that the return type will always be `()`, and thus fail to compile.

This PR allows `needless_return` to remove multiple semicolons.

The change won't cover the case where there is multiple line yet.

i.e.

```rust
fn needless_return() -> bool {
    return true;
;;
}
```

---

changelog: Sugg: [`needless_return`]: Now removes all semicolons on the same line
[#10187](https://github.com/rust-lang/rust-clippy/pull/10187)
<!-- changelog_checked -->
2023-01-15 15:49:40 +00:00
bors 483b7ac918 Auto merge of #10038 - xFrednet:9231-sugg-try-from, r=Jarcho
`cast_possible_truncation` Suggest TryFrom when truncation possible

This fixes the last issues from https://github.com/rust-lang/rust-clippy/pull/9664 as the author seems to be inactive. The PR author was sadly kept during the rebase, due to the conflict resolution.

IDK if it's worth it do to a full review, I only added the last commit, everything else remained the same, besides a rebase.

---

changelog: Sugg: [`cast_possible_truncation`]: Now suggests using `try_from` or allowing the lint
[#10038](https://github.com/rust-lang/rust-clippy/pull/10038)
<!-- changelog_checked -->

closes: https://github.com/rust-lang/rust-clippy/issues/9231
2023-01-14 16:04:51 +00:00
bors ac95db69fd Auto merge of #106801 - JohnTitor:rollup-xqkraw0, r=JohnTitor
Rollup of 6 pull requests

Successful merges:

 - #106608 (Render missing generics suggestion verbosely)
 - #106716 ([RFC 2397] Deny incorrect locations)
 - #106754 (Rename `Ty::is_ty_infer` -> `Ty::is_ty_or_numeric_infer`)
 - #106782 (Ignore tests move in git blame)
 - #106785 (Make blame spans better for impl wfcheck)
 - #106791 (Fix ICE formatting)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-01-13 10:56:53 +00:00
Yuki Okushi 71b99c48ee Rollup merge of #106608 - compiler-errors:missing-generics-verbose, r=estebank
Render missing generics suggestion verbosely

It's a bit easier to read like this, especially ones that are appending new generics onto an existing list, like ": `, T`" which render somewhat poorly inline.

Also don't suggest `dyn` as a type parameter to add, even if technically that's valid in edition 2015.
2023-01-13 16:54:22 +09:00
bors 83dba6e8bb Auto merge of #106092 - asquared31415:start_lang_item_checks, r=davidtwco
Add checks for the signature of the `start` lang item

Closes #105963
2023-01-13 07:45:34 +00:00
Michael Goulet 2253646395 Don't suggest dyn as parameter to add 2023-01-12 22:04:30 +00:00
Jason Newcomb b38848d8f7 Fix suggestion in `transmutes_expressible_as_ptr_casts` when the source type is a borrow. 2023-01-12 16:01:24 -05:00
Philipp Krones d21616737b Merge commit '7f27e2e74ef957baa382dc05cf08df6368165c74' into clippyup 2023-01-12 19:48:13 +01:00
bors 7f27e2e74e Auto merge of #10192 - Jarcho:revert_9701, r=flip1995
Partially revert #9701

This partially reverts #9701 due to #10134

r? `@flip1995`

changelog: None
2023-01-12 18:47:17 +00:00
Jason Newcomb 5eed9c69ca Revert 4dbd8ad34e, c7dc961558, ed519ad746 and c6477eb711 2023-01-12 13:28:22 -05:00
Philipp Krones 631481ffb3
Merge remote-tracking branch 'upstream/master' into rustup 2023-01-12 18:59:59 +01:00
Philipp Krones fe007179ec
Add cargo-clippy sysroot test
Whne SYSROOT is defined, clippy-driver will insert a --sysroot argument
when calling rustc. However, when a sysroot argument is already defined,
e.g. through RUSTFLAGS=--sysroot=... the `cargo clippy` call would
error. This tests that the sysroot argument is only passed once and that
SYSROOT is ignored in this case.
2023-01-12 18:32:47 +01:00
Joshua Nelson 321c530fad
Don't pass `--sysroot` twice if SYSROOT is set
This is useful for rust-lang/rust to allow setting a sysroot that's
*only* for build scripts, different from the regular sysroot passed in
RUSTFLAGS (since cargo doesn't apply RUSTFLAGS to build scripts or
proc-macros).

That said, the exact motivation is not particularly important: this
fixes a regression from
5907e9155e (r1060215684).

Note that only RUSTFLAGS is tested in the new integration test; passing
--sysroot through `clippy-driver` never worked as far as I can tell, and
no one is using it, so I didn't fix it here.
2023-01-12 18:32:47 +01:00
bors decaba97cc Auto merge of #10184 - robertbastian:master, r=xFrednet
Allow implementing `Hash` with derived `PartialEq` (`derive_hash_xor_eq`

This is a common pattern and is totally allowed by the `Hash` trait.

Fixes #2627

changelog: Move: Renamed `derive_hash_xor_eq` to [`derived_hash_with_manual_eq`]
[#10184](https://github.com/rust-lang/rust-clippy/pull/10184)
changelog: Enhancement: [`derived_hash_with_manual_eq`]: Now allows `#[derive(PartialEq)]` with custom `Hash` implementations
[#10184](https://github.com/rust-lang/rust-clippy/pull/10184)
<!-- changelog_checked -->
2023-01-12 14:59:41 +00:00
Robert Bastian 920633258f fix 2023-01-12 14:22:18 +01:00
bors 7c01721434 Auto merge of #10179 - llogiq:trim-suspicious-to-owned-paths, r=xFrednet
trim paths in `suspicious_to_owned`

This continues my path trimming spree. I'm not going to add yet another changelog entry, we should have one "trim paths in some applicable lints" entry instead.

---

changelog: none
2023-01-12 12:10:56 +00:00
xFrednet 5cb6246c3e
Address PR reivew 2023-01-12 12:37:56 +01:00
navh 51aaba6e8c
`cast_possible_truncation` Suggest TryFrom when truncation possible 2023-01-12 12:16:06 +01:00
asquared31415 c319440311 add checks for the signature of the lang item 2023-01-11 14:35:08 -08:00
Alex Macleod 34024adc88 expl_impl_clone_on_copy: ignore packed structs with type/const params 2023-01-11 17:37:19 +00:00
Andre Bogus bd76d9133b trim paths in `suspicious_to_owned` 2023-01-11 16:39:34 +01:00
Albert Larsan 5f8686ec3b Change `src/test` to `tests` in source files, fix tidy and tests 2023-01-11 09:32:13 +00:00
bors 15226f91bb Auto merge of #10166 - sulami:master, r=giraffate
unused_self: Don't trigger if the method body contains todo!()

If the author is using todo!(), presumably they intend to use self at some point later, so we don't have a good basis to recommend factoring out to an associated function.

Fixes #10117.

---

changelog: Enhancement: [`unused_self`]: No longer lints, if the method body contains a `todo!()` call
[#10166](https://github.com/rust-lang/rust-clippy/pull/10166)
<!-- changelog_checked -->
2023-01-11 00:30:19 +00:00
dswij 96e306843e tests: add case for multiple semis 2023-01-11 07:09:57 +08:00
Robert Bastian 8ca900b01c rename 2023-01-10 11:12:54 +01:00
Robert Bastian 53c12e085a hash xor peq 2023-01-09 21:29:42 +01:00
bors 41b2a3d9fe Auto merge of #10170 - c410-f3r:arith, r=dswij
[arithmetic_side_effects] Add more tests related to custom types

Add tests to ensure that custom types are triggered with any type of arithmetic operation as well as combinations with or without references.

---

changelog: none
<!-- changelog_checked -->
2023-01-09 14:54:12 +00:00
koka 1a7ef02dcb
Fix fp in unnecessary_safety_comment 2023-01-09 18:49:46 +09:00
Andre Bogus d23dce54ec add a test against #100898 2023-01-08 20:25:42 +01:00
bors cf1d3d0370 Auto merge of #10162 - tamaroning:fix10018, r=xFrednet
Fix FP of single-element-loop

closes #10018

---

changelog: [`single_element_loop`]: No longer lints, if the loop contains a `break` or `continue`
[#10162](https://github.com/rust-lang/rust-clippy/pull/10162)
<!-- changelog_checked -->
2023-01-07 11:53:45 +00:00
Caio fb34fbf7e0 [arithmetic_side_effects] Add more tests related to custom types 2023-01-06 14:50:25 -03:00
Caio 4262aebeaa [arithmetic-side-effects] Consider negative numbers and add more tests 2023-01-06 12:25:51 -03:00
bors 179a22f624 Auto merge of #10153 - llogiq:box-default-trim-paths, r=Jarcho
trim paths in `box_default`

This might help with #10089, though I have not tested that yet. In any event, it keeps the suggestion short and to the point.

---
changelog: Trim paths in [`box_default`] suggestion
2023-01-06 09:21:27 +00:00
bors 3f48ed523f Auto merge of #10160 - llogiq:default-trim-paths, r=dswij
trim paths in `default_trait_access`/`clone_on_copy` suggestions

This should help making the suggestions more palatable. Similar to #10153.

---

changelog: trim paths in [`default_trait_access`]/[`clone_on_copy`] suggestions
2023-01-06 09:07:58 +00:00
bors 3816f9a6f9 Auto merge of #10137 - euclio:dbg-macro, r=giraffate
reword dbg_macro labels

---

This change rewords the `dbg_macro` lint labels to be clearer.

changelog: none
<!-- changelog_checked -->
2023-01-06 05:25:34 +00:00
Robin Schroer e443604a24
unused_self: Don't trigger if the method body contains todo!()
If the author is using todo!(), presumably they intend to use self at
some point later, so we don't have a good basis to recommend factoring
out to an associated function.

Fixes #10117.

changelog: Don't trigger [`unused_self`] if the method body contains a `todo!()` call
2023-01-06 12:58:51 +09:00
bors 4f4c96155a Auto merge of #10142 - EricWu2003:drop_ref-FP, r=llogiq
[`drop_ref`]: don't lint idiomatic in match arm

fixes #10122

As established in issue #9482, it is idiomatic to use a single `drop()` expression in a match arm to achieve a side-effect of a function while discarding its output. This should also apply to cases where the function returns a reference.

The change to the lint's code was less than 1 line, because all the heavy lifting was done in PR #9491.

---

changelog: FP: [`drop_ref`]: No longer lints idiomatic expression in `match` arms
[#10142](https://github.com/rust-lang/rust-clippy/pull/10142)
<!-- changelog_checked -->
2023-01-05 23:36:49 +00:00
Raiki Tamura 79ed23ff81 fix 2023-01-05 18:30:13 +09:00
Kyle Huey 1c42dbba60 Expand derivable-impls to cover enums with a default unit variant. 2023-01-04 19:08:37 -08:00
bors d5d8ef13d7 Auto merge of #10159 - khuey:iter_kv_map_ref_mut, r=llogiq
Make the iter_kv_map lint handle ref/mut annotations.

For the degenerate (`map(|(k, _)| k)`/`map(|(_, v)| v)`) cases a mut annotation is superfluous and a ref annotation won't compile, so no additional handling is required. For cases where the `map` call must be preserved ref/mut annotations should also be presereved so that the map body continues to work as expected.

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

changelog: [`iter_kv_map`]: handle ref/mut annotations
2023-01-04 23:13:39 +00:00
Andre Bogus 05ba519a3a trim paths in `default_trait_access`/`clone_on_copy` suggestions 2023-01-04 23:39:46 +01:00
Kyle Huey d0c1605d51 Make the iter_kv_map lint handle ref/mut annotations.
For the degenerate (`map(|(k, _)| k)`/`map(|(_, v)| v)`) cases a mut annotation is superfluous and a ref annotation won't compile, so no additional handling is required. For cases where the `map` call must be preserved ref/mut annotations should also be presereved so that the map body continues to work as expected.
2023-01-04 13:32:34 -08:00
bors a385d34fc2 Auto merge of #10107 - tylerjw:suggest_path, r=Alexendoo
Suggest using Path for comparing extensions

fixes #10042

changelog: Sugg: [`case_sensitive_file_extension_comparisons`]: Now displays a suggestion with `Path`
[#10107](https://github.com/rust-lang/rust-clippy/pull/10107)
<!-- changelog_checked -->
2023-01-04 19:27:11 +00:00