]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoAuto merge of #8232 - Jarcho:match_same_arm_860, r=xFrednet
bors [Mon, 21 Mar 2022 20:42:51 +0000 (20:42 +0000)]
Auto merge of #8232 - Jarcho:match_same_arm_860, r=xFrednet

`match_same_arms` fix

fixes #860
fixes #1140

changelog: Don't lint `match_same_arms` when an interposing arm's pattern would overlap

2 years agoAuto merge of #8561 - FoseFx:use_unwrap_or, r=xFrednet
bors [Mon, 21 Mar 2022 20:08:29 +0000 (20:08 +0000)]
Auto merge of #8561 - FoseFx:use_unwrap_or, r=xFrednet

add `or_then_unwrap`

Closes #8557

changelog: New lint [`or_then_unwrap`]

2 years agoAuto merge of #8520 - J-ZhengLi:issue8506, r=xFrednet
bors [Mon, 21 Mar 2022 19:51:56 +0000 (19:51 +0000)]
Auto merge of #8520 - J-ZhengLi:issue8506, r=xFrednet

fix suggestion on `[map_flatten]` being cropped causing possible information loss

fixes #8506

Multi-line suggestion given by the lint is missing its bottom part, which could potentially contains useful information about the fix.

---

changelog: [`map_flatten`]: Long suggestions will now be splitup into two help messages

2 years agoallowing [`map_flatten`] to split long suggestions
J-ZhengLi [Mon, 21 Mar 2022 06:11:22 +0000 (14:11 +0800)]
allowing [`map_flatten`] to split long suggestions
add new function `span_lint_and_sugg_` for edges in `clippy_utils::diagnostics`

2 years agorefactor: remove need for MethodCall matching
Max Baumann [Sun, 20 Mar 2022 23:04:37 +0000 (00:04 +0100)]
refactor: remove need for MethodCall matching

2 years agorefactor: use is_lang_ctor()
Max Baumann [Sun, 20 Mar 2022 22:54:04 +0000 (23:54 +0100)]
refactor: use is_lang_ctor()

2 years agofeat: change error message
Max Baumann [Sun, 20 Mar 2022 22:43:17 +0000 (23:43 +0100)]
feat: change error message

2 years agoAuto merge of #8559 - pickfire:patch-1, r=xFrednet
bors [Sun, 20 Mar 2022 22:32:12 +0000 (22:32 +0000)]
Auto merge of #8559 - pickfire:patch-1, r=xFrednet

Fix typo in bug report

repoduce -> reproduce

---

changelog: none

2 years agotest: add method chain test
Max Baumann [Sat, 19 Mar 2022 17:17:43 +0000 (18:17 +0100)]
test: add method chain test

2 years agofeat: make fixable
Max Baumann [Fri, 18 Mar 2022 22:18:36 +0000 (23:18 +0100)]
feat: make fixable

2 years agofeat: use span_lint_and_sugg
Max Baumann [Fri, 18 Mar 2022 21:44:56 +0000 (22:44 +0100)]
feat: use span_lint_and_sugg

2 years agorefactor: move into methods module
Max Baumann [Fri, 18 Mar 2022 20:11:54 +0000 (21:11 +0100)]
refactor: move into methods module

2 years agoAuto merge of #8562 - Jarcho:enum_tuple_variant_as_int, r=Manishearth
bors [Fri, 18 Mar 2022 15:54:45 +0000 (15:54 +0000)]
Auto merge of #8562 - Jarcho:enum_tuple_variant_as_int, r=Manishearth

Add lint `cast_enum_constructor`

fixes: #1116

changelog: Add lint `cast_enum_constructor`

2 years agofeat: add comment
Max Baumann [Fri, 18 Mar 2022 13:45:48 +0000 (14:45 +0100)]
feat: add comment

2 years agoAuto merge of #8543 - dswij:8393, r=giraffate
bors [Fri, 18 Mar 2022 00:42:18 +0000 (00:42 +0000)]
Auto merge of #8543 - dswij:8393, r=giraffate

`unnecessary_lazy_eval` show suggestions on multiline lint

Closes #8393

changelog: [`unnecessary_lazy_eval`] now shows suggestions for long-line lints

2 years agofix: ran update_lints
Max Baumann [Fri, 18 Mar 2022 00:12:39 +0000 (01:12 +0100)]
fix: ran update_lints

2 years agorefactor: rename lint to or_then_unwrap
Max Baumann [Fri, 18 Mar 2022 00:04:33 +0000 (01:04 +0100)]
refactor: rename lint to or_then_unwrap

2 years agoAdd lint `cast_enum_constructor`
Jason Newcomb [Thu, 17 Mar 2022 20:04:45 +0000 (16:04 -0400)]
Add lint `cast_enum_constructor`

2 years agofeat: add tests and fix existing ones
Max Baumann [Thu, 17 Mar 2022 23:51:26 +0000 (00:51 +0100)]
feat: add tests and fix existing ones

2 years agofeat: rename variable in example
Max Baumann [Thu, 17 Mar 2022 23:34:24 +0000 (00:34 +0100)]
feat: rename variable in example

2 years agorefactor: use pattern matching for MethodCall arguments
Max Baumann [Thu, 17 Mar 2022 23:23:55 +0000 (00:23 +0100)]
refactor: use pattern matching for MethodCall arguments

Co-authored-by: xFrednet <xFrednet@gmail.com>
2 years agofix: fix clippy_lints
Max Baumann [Thu, 17 Mar 2022 18:52:07 +0000 (19:52 +0100)]
fix: fix clippy_lints

2 years agofix: fix broken dogfood tests
Max Baumann [Thu, 17 Mar 2022 18:29:59 +0000 (19:29 +0100)]
fix: fix broken dogfood tests

2 years agofix: fix tests
Max Baumann [Thu, 17 Mar 2022 18:13:44 +0000 (19:13 +0100)]
fix: fix tests

2 years agofeat: add use_unwrap_or
Max Baumann [Thu, 17 Mar 2022 17:57:28 +0000 (18:57 +0100)]
feat: add use_unwrap_or

2 years agoAuto merge of #8552 - Jarcho:ptr_arg_8495, r=xFrednet
bors [Thu, 17 Mar 2022 17:05:26 +0000 (17:05 +0000)]
Auto merge of #8552 - Jarcho:ptr_arg_8495, r=xFrednet

Don't lint `ptr_arg` on `&mut Cow<_>`

fixes: #8495

changelog: Don't lint `ptr_arg` on `&mut Cow<_>`

2 years agoFix typo in bug report
Ivan Tham [Thu, 17 Mar 2022 14:53:27 +0000 (22:53 +0800)]
Fix typo in bug report

repoduce -> reproduce

2 years agoAdd some comments
dswij [Thu, 17 Mar 2022 06:33:09 +0000 (14:33 +0800)]
Add some comments

2 years agoFix mixed enum variant kinds + code cleanup
Jason Newcomb [Thu, 17 Mar 2022 03:55:38 +0000 (23:55 -0400)]
Fix mixed enum variant kinds + code cleanup

2 years agoAuto merge of #8553 - Jarcho:transmute_undefined_8499, r=llogiq
bors [Wed, 16 Mar 2022 19:27:44 +0000 (19:27 +0000)]
Auto merge of #8553 - Jarcho:transmute_undefined_8499, r=llogiq

Don't lint `transmute_undefined_repr` when changing the type of generic params

Partially fixes #8499

changelog: Don't lint `transmute_undefined_repr` when changing the type of generic params

2 years agoImprove message for `match_single_arms`
Jason Newcomb [Sat, 22 Jan 2022 02:30:34 +0000 (21:30 -0500)]
Improve message for `match_single_arms`

2 years agoHandle slice patterns in `match_same_arms`
Jason Newcomb [Thu, 6 Jan 2022 19:54:57 +0000 (14:54 -0500)]
Handle slice patterns in `match_same_arms`

2 years agoUse `DroplessArena` when allocating `ResolvedPat`s
Jason Newcomb [Thu, 6 Jan 2022 18:37:37 +0000 (13:37 -0500)]
Use `DroplessArena` when allocating `ResolvedPat`s
Fix tuple handling in `match_same_arms`

2 years agoCheck if there are any overlapping patterns between equal arm bodies in `match_same_arm`
Jason Newcomb [Thu, 6 Jan 2022 07:54:35 +0000 (02:54 -0500)]
Check if there are any overlapping patterns between equal arm bodies in `match_same_arm`

2 years agoDon't lint `transmute_undefined_repr` when changing the type of generic params
Jason Newcomb [Wed, 16 Mar 2022 16:54:32 +0000 (12:54 -0400)]
Don't lint `transmute_undefined_repr` when changing the type of generic params

2 years agoDon't lint `ptr_arg` on `&mut Cow<_>`
Jason Newcomb [Wed, 16 Mar 2022 16:00:27 +0000 (12:00 -0400)]
Don't lint `ptr_arg` on `&mut Cow<_>`

2 years agoAuto merge of #8544 - nellorocca:dev/5757, r=flip1995
bors [Wed, 16 Mar 2022 09:55:39 +0000 (09:55 +0000)]
Auto merge of #8544 - nellorocca:dev/5757, r=flip1995

Moved ``[try_err]`` to restriction

Fixes #5757

changelog: Moved try_err lint to rescrition for #5757

2 years agoAuto merge of #8547 - Jarcho:transmute_8501, r=flip1995
bors [Wed, 16 Mar 2022 09:39:22 +0000 (09:39 +0000)]
Auto merge of #8547 - Jarcho:transmute_8501, r=flip1995

More `transmute_undefined_repr` fixes

fixes: #8498
fixes: #8501
fixes: #8503

changelog: Allow `transumte_undefined_repr` between fat pointers and `(usize, usize)`
changelog: Allow `transumte_undefined_repr` when one side is a union
changelog: Fix `transumte_undefined_repr` on tuples with one non-zero-sized type.

2 years agoAuto merge of #8546 - KisaragiEffective:patch-1, r=llogiq
bors [Wed, 16 Mar 2022 06:20:45 +0000 (06:20 +0000)]
Auto merge of #8546 - KisaragiEffective:patch-1, r=llogiq

[`collapsible_if`] fix typo in code-block kind specifier

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

changelog: [`collapsible_if`] fix typo in code-block kind specifier

2 years agoFix checking transmutes with adjusted types
Jason Newcomb [Wed, 16 Mar 2022 02:47:18 +0000 (22:47 -0400)]
Fix checking transmutes with adjusted types

2 years agoDon't lint `transmute_undefined_repr` on unions.
Jason Newcomb [Wed, 16 Mar 2022 02:38:15 +0000 (22:38 -0400)]
Don't lint `transmute_undefined_repr` on unions.

2 years agoSmall simplification to `transmute_undefined_repr`
Jason Newcomb [Wed, 16 Mar 2022 02:33:26 +0000 (22:33 -0400)]
Small simplification to `transmute_undefined_repr`

2 years agoDon't lint fat pointer to `(usize, usize)` conversion in `transmute_undefined_repr`
Jason Newcomb [Wed, 16 Mar 2022 02:31:07 +0000 (22:31 -0400)]
Don't lint fat pointer to `(usize, usize)` conversion in `transmute_undefined_repr`

2 years agoFix `transmute_undefined_repr` for single element tuples
Jason Newcomb [Wed, 16 Mar 2022 01:51:07 +0000 (21:51 -0400)]
Fix `transmute_undefined_repr` for single element tuples

2 years agofix typo in code-block kind specifier
Kisaragi [Wed, 16 Mar 2022 01:19:19 +0000 (10:19 +0900)]
fix typo in code-block kind specifier

2 years agofix typo in code-block kind specifier
Kisaragi [Tue, 15 Mar 2022 23:50:30 +0000 (08:50 +0900)]
fix typo in code-block kind specifier

2 years agoLint list updated
Paolo Gentili [Tue, 15 Mar 2022 18:38:40 +0000 (19:38 +0100)]
Lint list updated

2 years agoMoved lint to `restriction`
Paolo Gentili [Tue, 15 Mar 2022 13:24:07 +0000 (14:24 +0100)]
Moved lint to `restriction`

2 years ago`unnecessary_lazy_eval` show suggestions on multiline lint
dswij [Tue, 15 Mar 2022 13:29:17 +0000 (21:29 +0800)]
`unnecessary_lazy_eval` show suggestions on multiline lint

2 years agoAuto merge of #8541 - flip1995:iter_with_drain_ambulance, r=giraffate
bors [Tue, 15 Mar 2022 09:02:38 +0000 (09:02 +0000)]
Auto merge of #8541 - flip1995:iter_with_drain_ambulance, r=giraffate

Move iter_with_drain to nursery

cc #8538 #8539

r? `@giraffate`

changelog: Move [`iter_with_drain`] to nursery

2 years agoMove iter_with_drain to nursery
flip1995 [Tue, 15 Mar 2022 08:46:49 +0000 (09:46 +0100)]
Move iter_with_drain to nursery

2 years agoAuto merge of #8509 - smoelius:fix-8507, r=giraffate
bors [Tue, 15 Mar 2022 01:08:47 +0000 (01:08 +0000)]
Auto merge of #8509 - smoelius:fix-8507, r=giraffate

Fix `unncessary_to_owned` false positive

Fix #8507

changelog: none

2 years agoAuto merge of #8537 - xFrednet:7923-single-component-path-imports-for-macros, r=llogiq
bors [Mon, 14 Mar 2022 23:39:50 +0000 (23:39 +0000)]
Auto merge of #8537 - xFrednet:7923-single-component-path-imports-for-macros, r=llogiq

Allow `single_component_path_imports` for all macros

Closes: https://github.com/rust-lang/rust-clippy/issues/7923
It can be useful to have `use macro_name` regardless of the visibility. This removes the visibility filter.

changelog: [`single_component_path_imports`]: no longer triggers on macros

2 years agoAuto merge of #8536 - xFrednet:8062-applicability-search-is-some, r=camsteffen
bors [Mon, 14 Mar 2022 22:12:25 +0000 (22:12 +0000)]
Auto merge of #8536 - xFrednet:8062-applicability-search-is-some, r=camsteffen

Make `search_is_some`s suggestion `MachineApplicable`

My biggest PR to date, about 0.3 Lines have been changed!

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

The suggestion seems to work well, as we've received no error reports since the implementation in December. This PR therefore promotes the suggestion to `MachineApplicable`. The tests already include `.fixed` files :)

changelog: [`search_is_some`]: Make more suggestions `MachineApplicable`

2 years agoAllow `single_component_path_imports` for all macros
xFrednet [Mon, 14 Mar 2022 21:39:36 +0000 (22:39 +0100)]
Allow `single_component_path_imports` for all macros

2 years agoMake `search_is_some`s suggestion `MachineApplicable`
xFrednet [Mon, 14 Mar 2022 21:02:10 +0000 (22:02 +0100)]
Make `search_is_some`s suggestion `MachineApplicable`

2 years agoAuto merge of #8534 - flip1995:rustup, r=flip1995
bors [Mon, 14 Mar 2022 10:34:17 +0000 (10:34 +0000)]
Auto merge of #8534 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: none

2 years agoBump nightly version -> 2022-03-14
flip1995 [Mon, 14 Mar 2022 10:29:39 +0000 (11:29 +0100)]
Bump nightly version -> 2022-03-14

2 years agoMerge remote-tracking branch 'upstream/master' into rustup
flip1995 [Mon, 14 Mar 2022 10:29:18 +0000 (11:29 +0100)]
Merge remote-tracking branch 'upstream/master' into rustup

2 years agoAuto merge of #8422 - buttercrab:only_used_in_recursion, r=llogiq
bors [Sun, 13 Mar 2022 16:11:25 +0000 (16:11 +0000)]
Auto merge of #8422 - buttercrab:only_used_in_recursion, r=llogiq

new lint: `only_used_in_recursion`

changed:
- added `only_used_in_recursion`.
- fixed code that variables are only used in recursion.
- this would not lint when `unused_variable`

This fixes: #8390

-----

changelog: add lint [`only_used_in_recursion`]

2 years agoadd clearing return vars
Jaeyong Sung [Sun, 13 Mar 2022 15:13:57 +0000 (00:13 +0900)]
add clearing return vars

2 years agoAuto merge of #8471 - J-ZhengLi:master-issue7040, r=llogiq
bors [Sun, 13 Mar 2022 14:49:56 +0000 (14:49 +0000)]
Auto merge of #8471 - J-ZhengLi:master-issue7040, r=llogiq

new lint that detects useless match expression

fixes #7040

changelog: Add new  lint [`needless_match`] under complexity lint group

2 years agoImprove `AdtDef` interning.
Nicholas Nethercote [Fri, 4 Mar 2022 20:28:41 +0000 (07:28 +1100)]
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`.

2 years agoremove parameters that are only used in recursion
Jaeyong Sung [Thu, 10 Mar 2022 07:06:35 +0000 (16:06 +0900)]
remove parameters that are only used in recursion

2 years agofix build error
Jaeyong Sung [Thu, 10 Mar 2022 06:53:53 +0000 (15:53 +0900)]
fix build error

2 years agoadd checking for `x -> x` and `ref x -> x` and related test cases.
J-ZhengLi [Thu, 10 Mar 2022 06:46:58 +0000 (14:46 +0800)]
add checking for `x -> x` and `ref x -> x` and related test cases.

2 years agofix to lint Self::function
Jaeyong Sung [Thu, 10 Mar 2022 06:46:40 +0000 (15:46 +0900)]
fix to lint Self::function

2 years agoAuto merge of #8070 - CrazyRoka:update-gh-pages-checkbox-styles, r=camsteffen
bors [Thu, 10 Mar 2022 03:08:34 +0000 (03:08 +0000)]
Auto merge of #8070 - CrazyRoka:update-gh-pages-checkbox-styles, r=camsteffen

Improve styles of filtering options for Clippy's lint list

Partially solves #7958

Updated styles for filtering options. It now uses dropdown menus.

![image](https://user-images.githubusercontent.com/19844144/144608479-cdd9de0b-f101-4d49-a135-0969efb01a11.png)

changelog: none

2 years agorename lint to `needless_match`
J-ZhengLi [Thu, 10 Mar 2022 01:44:25 +0000 (09:44 +0800)]
rename lint to `needless_match`
and change its lint group to "complexity"

2 years agoadd `#[rustc_pass_by_value]` to more types
lcnr [Tue, 8 Mar 2022 14:39:52 +0000 (15:39 +0100)]
add `#[rustc_pass_by_value]` to more types

2 years agofix a bug that caused internal test fail
J-ZhengLi [Tue, 8 Mar 2022 10:15:11 +0000 (18:15 +0800)]
fix a bug that caused internal test fail

2 years agoadd nop if-let expression check.
J-ZhengLi [Tue, 8 Mar 2022 09:37:53 +0000 (17:37 +0800)]
add nop if-let expression check.
re-design test cases as some of them are not worth the effort to check.

2 years agoAuto merge of #94706 - matthiaskrgr:rollup-l5erynr, r=matthiaskrgr
bors [Mon, 7 Mar 2022 18:06:31 +0000 (18:06 +0000)]
Auto merge of #94706 - matthiaskrgr:rollup-l5erynr, r=matthiaskrgr

Rollup of 4 pull requests

Successful merges:

 - #93350 (libunwind: readd link attrs to _Unwind_Backtrace)
 - #93827 (Stabilize const_fn_fn_ptr_basics, const_fn_trait_bound, and const_impl_trait)
 - #94696 (Remove whitespaces and use CSS to align line numbers to the right instead)
 - #94700 (rustdoc: Update minifier version)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoUpdate and fix clippy tests
Eric Holk [Fri, 11 Feb 2022 03:23:43 +0000 (19:23 -0800)]
Update and fix clippy tests

2 years agoStabilize const_fn_fn_ptr_basics and const_fn_trait_bound
Eric Holk [Wed, 9 Feb 2022 00:33:15 +0000 (16:33 -0800)]
Stabilize const_fn_fn_ptr_basics and const_fn_trait_bound

2 years agoadd basic code to check nop match blocks
J-ZhengLi [Mon, 7 Mar 2022 10:12:35 +0000 (18:12 +0800)]
add basic code to check nop match blocks
modify `manual_map_option` uitest because one test case has confliction.

2 years agoadd test for trait recursion
Jaeyong Sung [Mon, 7 Mar 2022 03:15:00 +0000 (12:15 +0900)]
add test for trait recursion

2 years agoClarify `Layout` interning.
Nicholas Nethercote [Fri, 4 Mar 2022 02:46:56 +0000 (13:46 +1100)]
Clarify `Layout` interning.

`Layout` is another type that is sometimes interned, sometimes not, and
we always use references to refer to it so we can't take any advantage
of the uniqueness properties for hashing or equality checks.

This commit renames `Layout` as `LayoutS`, and then introduces a new
`Layout` that is a newtype around an `Interned<LayoutS>`. It also
interns more layouts than before. Previously layouts within layouts
(via the `variants` field) were never interned, but now they are. Hence
the lifetime on the new `Layout` type.

Unlike other interned types, these ones are in `rustc_target` instead of
`rustc_middle`. This reflects the existing structure of the code, which
does layout-specific stuff in `rustc_target` while `TyAndLayout` is
generic over the `Ty`, allowing the type-specific stuff to occur in
`rustc_middle`.

The commit also adds a `HashStable` impl for `Interned`, which was
needed. It hashes the contents, unlike the `Hash` impl which hashes the
pointer.

2 years agoIntroduce `ConstAllocation`.
Nicholas Nethercote [Tue, 1 Mar 2022 20:15:04 +0000 (07:15 +1100)]
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.

2 years agoRollup merge of #94617 - pierwill:update-itertools, r=Mark-Simulacrum
Matthias Krüger [Sun, 6 Mar 2022 14:41:26 +0000 (15:41 +0100)]
Rollup merge of #94617 - pierwill:update-itertools, r=Mark-Simulacrum

Update `itertools`

Update to 0.10.1

2 years agoAuto merge of #8445 - asquared31415:slice_ptr_cast, r=llogiq
bors [Sun, 6 Mar 2022 07:46:56 +0000 (07:46 +0000)]
Auto merge of #8445 - asquared31415:slice_ptr_cast, r=llogiq

Llint for casting between raw slice pointers with different element sizes

This lint disallows using `as` to convert from a raw pointer to a slice (e.g. `*const [i32]`, `*mut [Foo]`) to any other raw pointer to a slice if the element types have different sizes.  When a raw slice pointer is cast, the data pointer and count metadata are preserved.  This means that when the size of the inner slice's element type changes, the total number of bytes pointed to by the count changes.  For example a `*const [i32]` with length 4 (four `i32` elements) is cast `as *const [u8]` the resulting pointer points to four `u8` elements at the same address, losing most of the data.  When the size *increases* the resulting pointer will point to *more* data, and accessing that data will be UB.

On its own, *producing* the pointer isn't actually a problem, but because any use of the pointer as a slice will either produce surprising behavior or cause UB I believe this is a correctness lint.  If the pointer is not intended to be used as a slice, the user should instead use any of a number of methods to produce just a data pointer including an `as` cast to a thin pointer (e.g. `p as *const i32`) or if the pointer is being created from a slice, the `as_ptr` method on slices.  Detecting the intended use of the pointer is outside the scope of this lint, but I believe this lint will also lead users to realize that a slice pointer is only for slices.

There is an exception to this lint when either of the slice element types are zero sized (e.g `*mut [()]`).  The total number of bytes pointed to by the slice with a zero sized element is zero.  In that case preserving the length metadata is likely intended as a workaround to get the length metadata of a slice pointer though a zero sized slice.

The lint does not forbid casting pointers to slices with the *same* element size as the cast was likely intended to reinterpret the data in the slice as some equivalently sized data and the resulting pointer will behave as intended.

---

changelog: Added ``[`cast_slice_different_sizes`]``, a lint that disallows using `as`-casts to convert between raw pointers to slices when the elements have different sizes.

2 years agoFix #8507
Samuel E. Moelius III [Sun, 6 Mar 2022 02:18:44 +0000 (21:18 -0500)]
Fix #8507

2 years agoFormat with `rustfmt_if_chain`
Samuel E. Moelius III [Sat, 5 Mar 2022 23:35:58 +0000 (18:35 -0500)]
Format with `rustfmt_if_chain`

2 years agoChange syntax for TyAlias where clauses
Jack Huey [Tue, 19 Oct 2021 22:45:48 +0000 (18:45 -0400)]
Change syntax for TyAlias where clauses

2 years agofix lint errors
Jaeyong Sung [Sat, 5 Mar 2022 12:49:36 +0000 (21:49 +0900)]
fix lint errors

2 years agodon't lint when implementing trait
Jaeyong Sung [Sat, 5 Mar 2022 12:39:00 +0000 (21:39 +0900)]
don't lint when implementing trait

2 years agoDo not point at whole file missing `fn main`
Esteban Kuber [Fri, 21 Jan 2022 00:15:39 +0000 (00:15 +0000)]
Do not point at whole file missing `fn main`

Only point at the end of the crate. We could try making it point at the
beginning of the crate, but that is confused with `DUMMY_SP`, causing
the output to be *worse*.

This change will make it so that VSCode will *not* underline the whole
file when `main` is missing, so other errors will be visible.

2 years agoAuto merge of #8504 - xFrednet:8502-allow-lint-without-reason, r=flip1995
bors [Fri, 4 Mar 2022 19:23:39 +0000 (19:23 +0000)]
Auto merge of #8504 - xFrednet:8502-allow-lint-without-reason, r=flip1995

Add lint to detect `allow` attributes without reason

I was considering putting this lint into the pedantic group. However, that would result in countless warnings for existing projects. Having it in restriction also seems good to me :upside_down_face: (And now I need sleep :zzz: )

---

changelog: New lint [`allow_lint_without_reason`] (Requires the `lint_reasons` feature)

Closes: rust-lang/rust-clippy#8502
2 years agolint for casting raw pointers to slices with different element sizes
asquared31415 [Fri, 18 Feb 2022 10:17:07 +0000 (05:17 -0500)]
lint for casting raw pointers to slices with different element sizes

2 years agoUpdate `itertools`
pierwill [Fri, 4 Mar 2022 17:54:28 +0000 (11:54 -0600)]
Update `itertools`

Update to 0.10.1

2 years agoAdd lint to detect `allow` attributes without reason
xFrednet [Thu, 3 Mar 2022 22:57:35 +0000 (23:57 +0100)]
Add lint to detect `allow` attributes without reason

2 years agoAuto merge of #8500 - rust-lang:testless-dbg-macro, r=Manishearth
bors [Thu, 3 Mar 2022 18:32:07 +0000 (18:32 +0000)]
Auto merge of #8500 - rust-lang:testless-dbg-macro, r=Manishearth

Omit dbg_macro in test code

This fixes #8481.

---

changelog: none

2 years agoOmit dbg_macro in test code
Andre Bogus [Thu, 3 Mar 2022 18:28:05 +0000 (19:28 +0100)]
Omit dbg_macro in test code

2 years agoAuto merge of #8414 - MiSawa:fix/optimize-redundant-clone, r=oli-obk
bors [Thu, 3 Mar 2022 14:47:49 +0000 (14:47 +0000)]
Auto merge of #8414 - MiSawa:fix/optimize-redundant-clone, r=oli-obk

Optimize `redundant_clone`

Fixes #8412

changelog: none

2 years agoAuto merge of #8483 - ldm0:iter_with_drain_simple, r=flip1995,giraffate
bors [Thu, 3 Mar 2022 13:36:49 +0000 (13:36 +0000)]
Auto merge of #8483 - ldm0:iter_with_drain_simple, r=flip1995,giraffate

Use `.into_iter()` rather than `.drain(..)`

Replacing `.drain(..)` with `.into_iter()` makes my project's binary size smaller.

Fixes #1908

Applicability of this suggestion is `MaybeIncorrect` rather than `MachineApplicable` due to the complexity of "checking otherwise usage" X-|

changelog: Add new lint [`iter_with_drain`]

2 years agoAuto merge of #94512 - RalfJung:sdiv-ub, r=oli-obk
bors [Thu, 3 Mar 2022 12:56:24 +0000 (12:56 +0000)]
Auto merge of #94512 - RalfJung:sdiv-ub, r=oli-obk

Miri/CTFE: properly treat overflow in (signed) division/rem as UB

To my surprise, it looks like LLVM treats overflow of signed div/rem as UB. From what I can tell, MIR `Div`/`Rem` directly lowers to the corresponding LLVM operation, so to make that correct we also have to consider these overflows UB in the CTFE/Miri interpreter engine.

r? `@oli-obk`

2 years agoAuto merge of #8497 - Manishearth:transmute-undefined-repr-note, r=flip1995
bors [Thu, 3 Mar 2022 09:05:21 +0000 (09:05 +0000)]
Auto merge of #8497 - Manishearth:transmute-undefined-repr-note, r=flip1995

comment about transmute_undefined_repr in nursery

See discussion in https://github.com/rust-lang/rust-clippy/pull/8432

changelog: none

2 years agocomment about transmute_undefined_repr in nursery
Manish Goregaokar [Wed, 2 Mar 2022 17:54:50 +0000 (09:54 -0800)]
comment about transmute_undefined_repr in nursery

2 years agoSuggest `into_iter()` over `drain(..)`
Liu Dingming [Sat, 12 Feb 2022 19:14:04 +0000 (03:14 +0800)]
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

2 years agobless clippy
Ralf Jung [Thu, 3 Mar 2022 00:20:27 +0000 (19:20 -0500)]
bless clippy