Commit Graph

18529 Commits

Author SHA1 Message Date
Jacherr
7bc39f3af8 format and fix examples 2023-11-11 00:59:05 +00:00
Jacherr
cb90674aed add iter_over_hash_type lint 2023-11-11 00:20:47 +00:00
Alex Macleod
f1979d48d7 Destructure Conf in register_lints 2023-11-10 23:47:52 +00:00
bors
9a4dd106d9 Auto merge of #11750 - Alexendoo:let-chains, r=flip1995
Replace if_chain with let chains

Closes #9353

Let chains are now supported by rustfmt 🎉

The PR is split into two commits
1. The result of running [`if-to-let-chain clippy*/**/*.rs`](https://github.com/Alexendoo/if-to-let-chain)
2. The manual clean up: fixing some errors/formatting, dogfood lints, removing the if_chain internal lint

r? `@flip1995`

changelog: none
2023-11-10 18:09:19 +00:00
Alex Macleod
13b4bb12ad Clean up after if chain removal 2023-11-10 18:03:13 +00:00
Alex Macleod
9681b4afe0 Run if-to-let-chain clippy*/**/*.rs
https://github.com/Alexendoo/if-to-let-chain
2023-11-10 17:29:28 +00:00
bors
6be0f7414d Auto merge of #11780 - Jacherr:vec-allocator-nolint, r=xFrednet
Disable `vec_box` when using different allocators

Fixes #7114

This PR disables the `vec_box` lint when the `Box` and `Vec` use different allocators (but not when they use the same - custom - allocator).

For example - `Vec<Box<i32, DummyAllocator>>` will disable the lint, and `Vec<Box<i32, DummyAllocator>, DummyAllocator>` will not disable the lint.

In addition, the applicability of this lint has been changed to `Unspecified` due to the automatic fixes potentially breaking code such as the following:

```rs
fn foo() -> Vec<Box<i32>> { // -> Vec<i32>
  vec![Box::new(1)]
}
```

It should be noted that the `if_chain->let-chains` fix has also been applied to this lint, so the diff does contain many changes.

changelog: disable `vec_box` lint when using nonstandard allocators
2023-11-09 23:33:46 +00:00
Jacherr
eabc64f56c add additonal non-trigger testcase 2023-11-09 23:03:44 +00:00
Jason Newcomb
a44bb07900 Change divergence checking to match the compiler's type system based definition of divergence. 2023-11-09 17:57:06 -05:00
Jason Newcomb
16d58a2982 Lift expr_diverges to clippy_utils as is_never_expr 2023-11-09 17:45:59 -05:00
Alex Macleod
d8c0e6460b Make macro_use_imports lint ordering more stable 2023-11-09 13:34:00 +00:00
bors
34b7d1559f Auto merge of #11779 - partiallytyped:11775, r=blyxyas
[`mod_module_files`] Don't emit lint for mod.rs in tests

fixes: #11775

current state: indiscriminately emits the lint for mod files in tests.

The following

```
tests/
  common/
    mod.rs
  test.rs
```

is a common pattern for code shared across the tests and is suggested in the rust book. The change adds an additional check to verify that the mod file is not in tests.

changelog: Fix [`mod_module_files`]: false positive for mod files in tests folder
2023-11-08 22:27:13 +00:00
Jacherr
7cdaa3b574 replace incorrect bool 2023-11-08 21:47:58 +00:00
PartiallyTyped
7e716ff955 [mod_module_files] Don't emit lint for modules in tests
fixes: #11775

current state: indiscriminately emits the lint for mod files in tests.

The following

tests/
  common/
    mod.rs
  test.rs

is a common pattern for code shared across the tests and is suggested in
the rust book. The change adds an additional check to verify that the
mod file is not in tests.

changelog: Fix [`mod_module_files`]: false positive for mod files in
tests folder
2023-11-08 22:42:12 +01:00
Jacherr
483b109e6e cargo dev fmt 2023-11-08 21:17:40 +00:00
Jacherr
b6d56c47f9 add no-rustfix since suggestions are invalid 2023-11-08 21:15:11 +00:00
Jacherr
67bb503f26 add support for std::alloc::Global, add more tests 2023-11-08 21:10:27 +00:00
bors
e16d42f540 Auto merge of #11772 - partiallytyped:11714, r=blyxyas
[arc_with_non_send_sync] Improve suggested resolution

Fixes: #11714

Improved the lint message for [`arc_with_non_send_sync`] to suggest using `RC` unless user needs an Arc, then suggests wrapping in a mutex, and then suggests implementing `Sync` and `Send`.

---

changelog: [`arc_with_non_send_sync`]: Suggest RC over unsafe impl of Send and Sync
2023-11-08 20:30:02 +00:00
Jacherr
79325604da update testcases, cleanup 2023-11-08 18:42:58 +00:00
PartiallyTyped
399fe32893 [arc_with_non_send_sync] Improve suggested resolution
Fixes: #11714
changelog: [`arc_with_non_send_sync`]: Suggest RC over unsafe impl

Co-authored-by: Alejandra González <blyxyas@gmail.com>
2023-11-08 19:38:59 +01:00
Jacherr
3a91a11740 add logic to check allocator matching 2023-11-08 18:27:33 +00:00
Jacherr
73b9841a3e remove unnecessary find_map calls 2023-11-08 17:41:28 +00:00
bors
ba43632808 Auto merge of #11736 - gernot-ohner:issue-10267, r=flip1995
Make SpanlessEq more consistent

1) Remove wildcard as requested in https://github.com/rust-lang/rust-clippy/issues/10267.
2) Implement `hir_utils::eq_expr` for `ExprKind::Closure`, `ExprKind::ConstBlock`, `ExprKind::InlineAsm` and `ExprKind::Yield`.
3) Reorder branches of `hir_utils::eq_expr` to be in alphabetical order.

---
changelog: none
2023-11-08 09:58:56 +00:00
Gernot Ohner
171845d5a8 Reorder ExprKinds in hash_expr alphabetically 2023-11-06 11:51:07 -07:00
bors
6d9516ac1e Auto merge of #11758 - y21:clippy_config_references, r=flip1995
update references of old `msrvs` and `conf` paths

In #11685, `clippy_lints::utils::conf` and `clippy_utils::msrvs` were moved to a separate `clippy_config` crate.
I noticed that not all references to those paths were updated, so this small PR intends to fix those.

changelog: none
2023-11-06 10:03:11 +00:00
Dinu Blanovschi
67cc4b0cad fix clippy author and failing test 2023-11-04 21:43:18 +01:00
Nadrieril
17c7d21650 Warn when lint level is set on a match arm 2023-11-04 14:44:00 +01:00
y21
b9efa3ee2c update references of clippy_utils::msrvs and clippy_lints::util::conf 2023-11-04 01:15:32 +01:00
bors
789bc73d8a Auto merge of #11756 - y21:issue11755, r=Manishearth
[`unused_enumerate_index`]: don't ICE on empty tuples

Fixes #11755

changelog: [`unused_enumerate_index`]: don't ICE on empty tuples

I'm going to nominate for beta backport because the code that is needed to trigger this seems likely to occur in real code
`@rustbot` label +beta-nominated
2023-11-03 23:39:14 +00:00
sjwang05
4388158d24
Fix formatting 2023-11-03 13:48:04 -07:00
y21
294df80e2c [unused_enumerate_index]: don't ICE on empty tuples 2023-11-03 21:13:51 +01:00
sjwang05
c50af350a1
Use fm_method_str in lint formatting
Co-authored-by: Catherine Flores <catherine.3.flores@gmail.com>
2023-11-03 10:32:19 -07:00
bors
2d9af160af Auto merge of #117507 - nnethercote:rustc_span, r=Nilstrieb
`rustc_span` cleanups

Just some things I found while looking over this crate.

r? `@oli-obk`
2023-11-03 14:57:40 +00:00
sjwang05
10f3977eba
Split arg/method checking into its own function 2023-11-02 18:42:58 -07:00
sjwang05
103200967e
Use match on method args instead of if let 2023-11-02 18:24:24 -07:00
sjwang05
39eded7b05
Lint flatten() under lines_filter_map_ok 2023-11-02 18:24:15 -07:00
y21
c9d2961100 teach eager_or_lazy that arithmetic ops can panic 2023-11-02 23:53:00 +01:00
bors
902c79c654 Auto merge of #11743 - Alexendoo:dbg-macro-stmt-span, r=xFrednet
Fix `dbg_macro` semi span calculation

`span_including_semi` was using a `BytePos` to index into a file's source which happened to work because the root file of the test started at `BytePos` 0, it didn't work for other files

changelog: none
2023-11-02 20:11:32 +00:00
Philipp Krones
77c1e3aaa1 Merge commit '09ac14c901abc43bd0d617ae4a44e8a4fed98d9c' into clippyup 2023-11-02 17:35:56 +01:00
bors
09ac14c901 Auto merge of #11747 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2023-11-02 16:32:10 +00:00
Philipp Krones
62a82b361c
Format let-chains across the code base
In the updated nightly version, it seems that rustfmt now supports formatting
let-chains. Since we're using them a lot, it's a lot of reformatting.
2023-11-02 17:24:30 +01:00
Philipp Krones
5eee19e1dc
Bump nightly version -> 2023-11-02 2023-11-02 17:24:26 +01:00
Philipp Krones
95dc7be92f
Merge remote-tracking branch 'upstream/master' into rustup 2023-11-02 17:24:19 +01:00
bors
01a0a36666 Auto merge of #11744 - matthri:get-first-deque-fix, r=Jarcho
Fix get_first false negative for VecDeque

fixes #11695

Also run the lint on `VecDeque` and suggest using `.front()` instead of `.get(0)` when trying to access the first element.

PS: At first I implemented the VecDeque Lint in a separate `if_chain` (see the previous commit).
Let me know if thats the preferred way, then I will remove the refactoring into one block.

changelog: [`get_first`]: fix false negative: Also lint `VecDeque` and suggest using `front()`
2023-11-02 09:23:39 +00:00
Nicholas Nethercote
e1ec2d5cc9 Minimize pub usage in source_map.rs.
Most notably, this commit changes the `pub use crate::*;` in that file
to `use crate::*;`. This requires a lot of `use` items in other crates
to be adjusted, because everything defined within `rustc_span::*` was
also available via `rustc_span::source_map::*`, which is bizarre.

The commit also removes `SourceMap::span_to_relative_line_string`, which
is unused.
2023-11-02 19:35:00 +11:00
Matthias Richter
61c76dd4ff remove code duplication 2023-11-01 23:35:28 +01:00
Matthias Richter
3b759bce9d fix get_first false negative for VecDeque 2023-11-01 23:26:43 +01:00
Camille GILLOT
aae86ccc47 Rename hook. 2023-11-01 16:49:18 +00:00
Alex Macleod
57a464439e Fix dbg_macro semi span calculation 2023-11-01 16:25:15 +00:00
bors
919f698da0 Auto merge of #10404 - dnbln:feat/unused_enumerate_index, r=blyxyas
Add `unused_enumerate_index` lint

A lint for unused `.enumerate()` indexes (`for (_, x) in iter.enumerate()`).

I wasn't able to find a `rustc_span::sym::Enumerate`, so the code for checking that it's the correct `Enumerate` iterator is a bit weird.

---

changelog: New lint: [`unused_enumerate_index`]: A new lint for checking that the indexes from `.enumerate()` calls are used.
[#10404](https://github.com/rust-lang/rust-clippy/pull/10404)
<!-- changelog_checked -->
2023-11-01 15:52:56 +00:00