Commit graph

544 commits

Author SHA1 Message Date
Jason Newcomb
70f7c624e4 Allow more complex expressions in let_unit_value 2022-04-14 21:34:33 -04:00
bors
80bcd9bc6e Auto merge of #8614 - pitaj:fix-7597, r=giraffate
assertions_on_constants: ignore indirect `cfg!`

Fixes #7597

changelog: [`assertions_on_constants`] ignore constants indirectly based on `cfg!`
2022-04-14 23:58:51 +00:00
bors
aade96f902 Auto merge of #8626 - pitaj:format_add_string, r=llogiq
New lint `format_add_strings`

Closes #6261

changelog: Added [`format_add_string`]: recommend using `write!` instead of appending the result of  `format!`
2022-04-14 14:29:22 +00:00
Peter Jaszkowiak
67badbeef6 New lint format_add_strings 2022-04-13 22:48:36 -06:00
Peter Jaszkowiak
9f131e5a0b assertions_on_constants: ignore indirect cfg! 2022-04-13 22:47:08 -06:00
bors
38ba05508c Auto merge of #8676 - Alexendoo:local-used-across-loop, r=xFrednet
Check for loops/closures in `local_used_after_expr`

Follow up to #8646, catches when a local is used multiple times because it's in a loop or a closure

changelog: none
2022-04-14 04:44:33 +00:00
bors
06b1695814 Auto merge of #8647 - Jarcho:mut_from_ref_6326, r=giraffate
Only lint `mut_from_ref` when unsafe code is used

fixes #6326

changelog: Only lint `mut_from_ref` when unsafe code is used.
2022-04-13 00:38:54 +00:00
bors
dbcd82885f Auto merge of #8624 - pitaj:is_digit_ascii_radix, r=xFrednet
New lint `is_digit_ascii_radix`

Closes #6399

changelog: Added [`is_digit_ascii_radix`]: recommend `is_ascii_digit()` or `is_ascii_hexdigit()` in place of `is_digit(10)` and `is_digit(16)`
2022-04-11 18:56:21 +00:00
bors
89ee6aa6e3 Auto merge of #8667 - Jarcho:proc_macro_check, r=flip1995
Don't lint various match lints when expanded by a proc-macro

fixes #4952

As always for proc-macro output this is a hack-job of a fix. It would be really nice if more proc-macro authors would set spans correctly.

changelog: Don't lint various lints on proc-macro output.
2022-04-11 16:41:51 +00:00
bors
131ff87a1e Auto merge of #8673 - Jarcho:same_functions_8139, r=Manishearth
Fix `same_functions_in_if_condition` FP

fixes #8139

changelog: Don't consider `Foo<{ SomeConstant }>` and `Foo<{ SomeOtherConstant }>` to be the same, even if the constants have the same value.
2022-04-11 15:36:55 +00:00
Yoav Lavi
a4d1837f07 unnecessary_string_new 2022-04-11 12:35:44 +02:00
Alex Macleod
5e335a52bc Check for loops/closures in local_used_after_expr 2022-04-10 14:26:44 +01:00
Jason Newcomb
719a040397 Compare inline constants by their bodies rather than value in SpanlessEq 2022-04-10 00:54:41 -04:00
Jason Newcomb
63f6a79bf8 Don't lint various match lints when expanded by a proc-macro 2022-04-08 16:51:40 -04:00
Peter Jaszkowiak
06cfeb90c1 New lint is_digit_ascii_radix 2022-04-07 14:14:30 -06:00
bors
abc59bb914 Auto merge of #8656 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2022-04-07 15:30:27 +00:00
flip1995
f23a9fb295
Bump Clippy Version -> 0.1.62 2022-04-07 16:24:33 +01:00
flip1995
669fddab37
Merge remote-tracking branch 'upstream/master' into rustup 2022-04-07 15:44:37 +01:00
Paolo Borelli
b0edbca0e6 new lint cast_abs_to_unsigned
Add a lint to detect cast to unsigned for abs() and suggest
unsigned_abs() to avoid panic when called on MIN.
2022-04-07 11:28:14 +02:00
InfRandomness
cebe575aad Add .err().expect() lint 2022-04-06 19:25:58 +02:00
Jason Newcomb
ddd3af2273 Only lint mut_from_ref when unsafe code is used 2022-04-06 10:59:57 -04:00
David Wood
c8b9e85b20 span: move MultiSpan
`MultiSpan` contains labels, which are more complicated with the
introduction of diagnostic translation and will use types from
`rustc_errors` - however, `rustc_errors` depends on `rustc_span` so
`rustc_span` cannot use types like `DiagnosticMessage` without
dependency cycles. Introduce a new `rustc_error_messages` crate that can
contain `DiagnosticMessage` and `MultiSpan`.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05 07:01:00 +01:00
Jason Newcomb
e4fc15e646 Don't lint cast_ptr_alignment when used for unaligned reads and writes 2022-04-04 13:54:52 -04:00
lcnr
104ba478f2 clippy: nameres for primitive type impls 2022-03-30 11:57:53 +02:00
lcnr
148b593954 get clippy to compile again 2022-03-30 11:23:58 +02:00
Oli Scherer
b3535a1549 Remove opaque type obligation and just register opaque types as they are encountered.
This also registers obligations for the hidden type immediately.
2022-03-28 16:57:45 +00:00
Oli Scherer
46e832e1ee Revert "Auto merge of #93893 - oli-obk:sad_revert, r=oli-obk"
This reverts commit 6499c5e7fc173a3f55b7a3bd1e6a50e9edef782d, reversing
changes made to 78450d2d602b06d9b94349aaf8cece1a4acaf3a8.
2022-03-28 16:27:14 +00:00
flip1995
1fa3d66e62 Merge commit 'd0cf3481a84e3aa68c2f185c460e282af36ebc42' into clippyup 2022-03-24 14:50:04 +01:00
J-ZhengLi
5b6295d663 allowing [map_flatten] to split long suggestions
add new function `span_lint_and_sugg_` for edges in `clippy_utils::diagnostics`
2022-03-21 14:11:22 +08:00
xFrednet
fc5540a4d3
Make search_is_somes suggestion MachineApplicable 2022-03-14 22:02:10 +01:00
flip1995
d1b087fdee Merge commit 'dc5423ad448877e33cca28db2f1445c9c4473c75' into clippyup 2022-03-14 12:02:53 +01:00
flip1995
d5ab347d5c
Merge remote-tracking branch 'upstream/master' into rustup 2022-03-14 11:29:18 +01:00
Nicholas Nethercote
e110231260 Improve AdtDef interning.
This commit makes `AdtDef` use `Interned`. Much the commit is tedious
changes to introduce getter functions. The interesting changes are in
`compiler/rustc_middle/src/ty/adt.rs`.
2022-03-11 13:31:24 +11:00
lcnr
a4d6c61bdc add #[rustc_pass_by_value] to more types 2022-03-08 15:39:52 +01:00
Eric Holk
b86620da37 Stabilize const_fn_fn_ptr_basics and const_fn_trait_bound 2022-03-07 08:47:15 -08:00
Nicholas Nethercote
96eb1168d1 Introduce ConstAllocation.
Currently some `Allocation`s are interned, some are not, and it's very
hard to tell at a use point which is which.

This commit introduces `ConstAllocation` for the known-interned ones,
which makes the division much clearer. `ConstAllocation::inner()` is
used to get the underlying `Allocation`.

In some places it's natural to use an `Allocation`, in some it's natural
to use a `ConstAllocation`, and in some places there's no clear choice.
I've tried to make things look as nice as possible, while generally
favouring `ConstAllocation`, which is the type that embodies more
information. This does require quite a few calls to `inner()`.

The commit also tweaks how `PartialOrd` works for `Interned`. The
previous code was too clever by half, building on `T: Ord` to make the
code shorter. That caused problems with deriving `PartialOrd` and `Ord`
for `ConstAllocation`, so I changed it to build on `T: PartialOrd`,
which is slightly more verbose but much more standard and avoided the
problems.
2022-03-07 08:25:50 +11:00
Jack Huey
9bee01eb91 Change syntax for TyAlias where clauses 2022-03-05 13:13:45 -05:00
asquared31415
f932c304bb lint for casting raw pointers to slices with different element sizes 2022-03-04 13:23:06 -05:00
Liu Dingming
6cc2eeaa56 Suggest into_iter() over drain(..)
Add doc

Add description

iter_with_drain dogfood

Disable emiting on struct field.

Fix clippy

Add eq_path for SpanlessEq

Fix tests

Better error message

Fix doc test

Fix version

Apply suggestions
2022-03-03 13:10:19 +08:00
flip1995
bca4ee7971
Implement internal lint for MSRV lints
This internal lint checks if the `extract_msrv_attrs!` macro is used if
a lint has a MSRV. If not, it suggests to add this attribute to the lint
pass implementation.
2022-03-01 09:40:07 +00:00
flip1995
35020280a0 Merge commit 'e329249b6a3a98830d860c74c8234a8dd9407436' into clippyup 2022-02-26 14:26:21 +01:00
Alex Macleod
2955db493e Replace some more paths with diagnostic items 2022-02-25 15:38:06 +00:00
flip1995
5ece8d2bc4
Bump Clippy Version -> 0.1.61 2022-02-24 19:32:47 +01:00
flip1995
fd495a0654
Merge remote-tracking branch 'upstream/master' into rustup 2022-02-24 19:32:17 +01:00
Eduard-Mihai Burtescu
88483bd4b7 Replace &mut DiagnosticBuilder, in signatures, with &mut Diagnostic. 2022-02-23 05:38:19 +00:00
lcnr
e390e6c469 update clippy 2022-02-21 07:09:11 +01:00
Jason Newcomb
447a24588a Allow various type erasure patterns in transmute_undefined_repr 2022-02-18 15:02:25 -05:00
Jason Newcomb
88ecdd0804 Extract some util functions 2022-02-18 09:45:11 -05:00
flip1995
c4944fb60d
Actually lint parking_lot in await_holding_lock
This adapts the paths for the parking_lot mutex guards, so that
parking_lot mutexes and RwLocks actually get linted. This is now also
tested.
2022-02-17 18:02:31 +01:00
Nicholas Nethercote
64ae3ae006 Overhaul Const.
Specifically, rename the `Const` struct as `ConstS` and re-introduce `Const` as
this:
```
pub struct Const<'tcx>(&'tcx Interned<ConstS>);
```
This now matches `Ty` and `Predicate` more closely, including using
pointer-based `eq` and `hash`.

Notable changes:
- `mk_const` now takes a `ConstS`.
- `Const` was copy, despite being 48 bytes. Now `ConstS` is not, so need a
  we need separate arena for it, because we can't use the `Dropless` one any
  more.
- Many `&'tcx Const<'tcx>`/`&Const<'tcx>` to `Const<'tcx>` changes
- Many `ct.ty` to `ct.ty()` and `ct.val` to `ct.val()` changes.
- Lots of tedious sigil fiddling.
2022-02-15 16:19:59 +11:00