Commit Graph

15197 Commits

Author SHA1 Message Date
Alex Macleod
86d18b50ed Fix unused_peekable closure and f(&mut peekable) false positives 2022-09-11 12:40:52 +00:00
Lukas Lueg
1e23c65d5e Don't panic on invalid shift while constfolding
Fixes #9463
2022-09-11 12:26:13 +02:00
bors
42361da5d9 Auto merge of #98559 - jackh726:remove-reempty, r=oli-obk
Remove ReEmpty

r? rust-lang/types
2022-09-10 20:54:01 +00:00
bors
c8c2a234b3 Auto merge of #9457 - kraktus:nonminimal_bool, r=Manishearth
Do not expand macro in `nonminimal_bool` suggestions

fix https://github.com/rust-lang/rust-clippy/issues/9428

changelog: Do not expand macros in [`nonminimal_bool`] suggestions
2022-09-10 19:11:08 +00:00
Alex Macleod
1b245e7e0e Use visit_expr_field for ParamPosition 2022-09-10 18:33:04 +00:00
kraktus
d50f366612 Do not expand macro in nonminimal_bool suggestions 2022-09-10 19:48:14 +02:00
bors
da8afc9ecf Auto merge of #9453 - kraktus:a_on_re_state, r=Jarcho
[`assertions_on_result_states`]: Fix suggestion when `assert!` is not in a statement.

fix https://github.com/rust-lang/rust-clippy/issues/9450

changelog: [`assertions_on_result_states`]: Fix suggestion when `assert!` is not in a statement.
2022-09-10 13:18:06 +00:00
Niklas Jonsson
41b3084391 rustc_error, rustc_private, rustc_ast: Switch to stable hash containers 2022-09-10 11:49:12 +02:00
kraktus
59ee6a89a3 Remove duplicate context check 2022-09-10 11:47:07 +02:00
kraktus
c433d542cf Do not lint use_self in proc macro expansion 2022-09-10 11:42:37 +02:00
kraktus
bdb13cd887 refactor: move has_debug_impl to clippy_utils::ty 2022-09-10 10:39:51 +02:00
kraktus
cd69d86c89 assertions_on_result_states fix suggestion when assert! not in a statement 2022-09-10 10:30:19 +02:00
kraktus
cea10f74b7 Fix dev book
fix `implements_trait` and `in_external_macro` import path

Remove example using `match_trait_method` since its deprecated
2022-09-09 22:43:19 +02:00
bors
5652ccbc0f Auto merge of #9448 - Alexendoo:large-enum-variant-u128, r=Manishearth
Replace u128 with u64 in large_enum_variant uitest

A u128 has [an 8 byte alignment on x86](https://github.com/rust-lang/rust/issues/54341), but a 16 byte alignment on aarch64 which changes the size of the enums due to extra padding. This means the test fails on aarch64

changelog: none
2022-09-09 17:21:53 +00:00
Philipp Krones
98bf99e2f8 Merge commit 'b52fb5234cd7c11ecfae51897a6f7fa52e8777fc' into clippyup 2022-09-09 13:36:26 +02:00
Michael Goulet
854f751b26 Appease clippy again 2022-09-09 01:31:46 +00:00
Michael Goulet
ac1c68a5e6 Make clippy happy 2022-09-09 01:31:45 +00:00
Jack Huey
b640eaa71d Remove ReEmpty 2022-09-08 20:55:55 -04:00
bors
b52fb5234c Auto merge of #9446 - mikerite:fix-9431-2, r=giraffate
Fix `range_{plus,minus}_one` bad suggestions

Fixes #9431.

The current `range_plus_one` and `range_minus_one` suggestions are completely incorrect when macros are involved.

This commit resolves this by disabling the lints for any range expression that is expanded from a macro. The reasons for this are that it is very difficult to create a correct suggestion in this case and that false negatives are less important for pedantic lints.

changelog: Fix `range_{plus,minus}_one` bad suggestions
2022-09-08 23:48:08 +00:00
Alex Macleod
8b25e53d50 Replace u128 with u64 in large_enum_variant uitest
A u128 has an 8 byte alignment on x86, but a 16 byte alignment on
aarch64 which changes the size of the enums due to extra padding
2022-09-08 20:44:32 +00:00
Alex Macleod
6fc6d87fd0 Migrate write.rs to a late pass 2022-09-08 20:18:02 +00:00
bors
32fa80dda5 Auto merge of #9447 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2022-09-08 19:42:33 +00:00
Philipp Krones
df536c9086
Bump nightly version -> 2022-09-08 2022-09-08 21:27:37 +02:00
Philipp Krones
4ee55c5528
Merge remote-tracking branch 'upstream/auto' into rustup 2022-09-08 21:27:09 +02:00
Michael Wright
a6d8afd958 Fix range_{plus,minus}_one bad suggestions
Fixes #9431.

The current `range_plus_one` and `range_minus_one` suggestions
are completely incorrect when macros are involved.

This commit resolves this by disabling the lints for any range
expression that is expanded from a macro. The reasons for this
are that it is very difficult to create a correct suggestion in
this case and that false negatives are less important for
pedantic lints.
2022-09-08 20:04:43 +02:00
bors
1f92c9dccc Auto merge of #9443 - c410-f3r:arith, r=flip1995
Rename the arithmetic lint

changelog: Rename the `arithmetic` lint
2022-09-08 17:58:57 +00:00
bors
b30c5c0554 Auto merge of #9444 - Alexendoo:lintcheck-cargo, r=matthiaskrgr
Update cargo in lintcheck_crates.toml

0.49.0 depends on a version of socket2 that no longer builds due to

```
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
   --> /home/alex/.cargo/registry/src/github.com-1ecc6299db9ec823/socket2-0.3.11/src/sockaddr.rs:156:9
    |
156 |         mem::transmute::<SocketAddrV4, sockaddr_in>(v4);
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: source type: `SocketAddrV4` (48 bits)
    = note: target type: `sockaddr_in` (128 bits)
```

changelog: none
2022-09-08 16:50:52 +00:00
bors
f47a1e24c7 Auto merge of #101577 - Dylan-DPC:rollup-l9xw7i7, r=Dylan-DPC
Rollup of 7 pull requests

Successful merges:

 - #98933 (Opaque types' generic params do not imply anything about their hidden type's lifetimes)
 - #101041 (translations(rustc_session): migrates rustc_session to use SessionDiagnostic - Pt. 2)
 - #101424 (Adjust and slightly generalize operator error suggestion)
 - #101496 (Allow lower_lifetime_binder receive a closure)
 - #101501 (Allow lint passes to be bound by `TyCtxt`)
 - #101515 (Recover from typo where == is used in place of =)
 - #101545 (Remove unnecessary `PartialOrd` and `Ord`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-09-08 15:53:14 +00:00
Alex Macleod
2c5524f835 Update cargo in lintcheck_crates.toml 2022-09-08 15:29:26 +00:00
Dylan DPC
9faa588446 Rollup merge of #101501 - Jarcho:tcx_lint_passes, r=davidtwco
Allow lint passes to be bound by `TyCtxt`

This will allow storing things like `Ty<'tcx>` inside late lint passes. It's already possible to store various id types so they're already implicitly bound to a specific `TyCtxt`.

r? rust-lang/compiler
2022-09-08 20:48:36 +05:30
Caio
51d8b6c664 Rename the arithmetic lint 2022-09-08 12:04:55 -03:00
bors
30a5815505 Auto merge of #101467 - nnethercote:shrink-hir-Ty-Pat, r=spastorino
Shrink `hir::Ty` and `hir::Pat`

r? `@ghost`
2022-09-08 13:11:57 +00:00
Dylan DPC
c3db185c52 Rollup merge of #101498 - petrochenkov:visparam, r=cjgillot
rustc: Parameterize `ty::Visibility` over used ID

It allows using `LocalDefId` instead of `DefId` when possible, and also encode cheaper `Visibility<DefIndex>` into metadata.
2022-09-08 11:55:09 +05:30
Nicholas Nethercote
c86a9c077c Introduce DotDotPos.
This shrinks `hir::Pat` from 88 to 72 bytes.
2022-09-08 15:25:50 +10:00
Nicholas Nethercote
977b6e29a3 Arena-allocate hir::Lifetime.
This shrinks `hir::Ty` from 72 to 48 bytes.

`visit_lifetime` is added to the HIR stats collector because these types
are now stored in memory on their own, instead of being within other
types.
2022-09-08 15:07:19 +10:00
bors
617417e9ad Auto merge of #9365 - c410-f3r:arith, r=Alexendoo
[Arithmetic] Consider literals

Fixes https://github.com/rust-lang/rust-clippy/issues/9307 and makes the `arithmetic` lint behave like `integer_arithmetic`.

It is worth noting that literal integers of a binary operation (`1 + 1`, `i32::MAX + 1`), **regardless if they are in a constant environment**, won't trigger the lint. Assign operations also have similar reasoning.

changelog: Consider literals in the arithmetic lint
2022-09-07 19:55:34 +00:00
bors
da29f8928d Auto merge of #9441 - Jarcho:hang_9433, r=Alexendoo
Fix hang in `vec_init_then_push`

fixes #9433
changelog: Fix infinite loop in `vec_init_then_push`
2022-09-07 19:43:00 +00:00
Jason Newcomb
15859323ea Fix hang in vec_init_then_push 2022-09-07 15:26:44 -04:00
bors
567e1bbca7 Auto merge of #101432 - nnethercote:shrink-PredicateS, r=lcnr
Shrink `PredicateS`

r? `@ghost`
2022-09-07 13:49:58 +00:00
Caio
0d078c9fd6 [Arithmetic] Consider literals 2022-09-07 10:00:45 -03:00
Vadim Petrochenkov
9136096629 rustc: Parameterize ty::Visibility over used ID
It allows using `LocalDefId` instead of `DefId` when possible, and also encode cheaper `Visibility<DefIndex>` into metadata.
2022-09-07 13:35:41 +04:00
bors
7babd1b099 Auto merge of #9421 - xphoniex:fix-#9420, r=giraffate
Suggest `unwrap_or_default` when closure returns `"".to_string`

Closes https://github.com/rust-lang/rust-clippy/issues/9420

changelog: [`unwrap_or_else_default`]: suggest `unwrap_or_default()` instead of `unwrap_or_else` with a closure that returns an empty `to_string`.
2022-09-06 23:44:38 +00:00
Jason Newcomb
abd3e7eabb Allow lint passes to be bound by TyCtxt 2022-09-06 14:23:03 -04:00
Oli Scherer
9cbbd4a80e Generalize the Assume intrinsic statement to a general Intrinsic statement 2022-09-06 14:18:32 +00:00
Oli Scherer
e1b3483ee8 Lower the assume intrinsic to a MIR statement 2022-09-06 14:18:32 +00:00
xphoniex
b21d9d307b
Suggest unwrap_or_default when closure returns "".to_string
Signed-off-by: xphoniex <xphoniex@users.noreply.github.com>
2022-09-06 04:38:29 +00:00
bors
ce339b219a Auto merge of #101241 - camsteffen:refactor-binding-annotations, r=cjgillot
`BindingAnnotation` refactor

* `ast::BindingMode` is deleted and replaced with `hir::BindingAnnotation` (which is moved to `ast`)
* `BindingAnnotation` is changed from an enum to a tuple struct e.g. `BindingAnnotation(ByRef::No, Mutability::Mut)`
* Associated constants added for convenience `BindingAnnotation::{NONE, REF, MUT, REF_MUT}`

One goal is to make it more clear that `BindingAnnotation` merely represents syntax `ref mut` and not the actual binding mode. This was especially confusing since we had `ast::BindingMode`->`hir::BindingAnnotation`->`thir::BindingMode`.

I wish there were more symmetry between `ByRef` and `Mutability` (variant) naming (maybe `Mutable::Yes`?), and I also don't love how long the name `BindingAnnotation` is, but this seems like the best compromise. Ideas welcome.
2022-09-06 03:16:29 +00:00
bors
2ccf843471 Auto merge of #101261 - TaKO8Ki:separate-receiver-from-arguments-in-hir, r=cjgillot
Separate the receiver from arguments in HIR

Related to #100232

cc `@cjgillot`
2022-09-05 16:21:40 +00:00
Takayuki Maeda
8931da40e3 use propagate_through_exprs instead of propagate_through_expr
fix `ExprKind` static_assert_size

fix hir-stats
2022-09-05 23:11:34 +09:00
bors
5ea99770d8 Auto merge of #101228 - nnethercote:simplify-hir-PathSegment, r=petrochenkov
Simplify `hir::PathSegment`

r? `@petrochenkov`
2022-09-05 13:36:54 +00:00