Commit graph

13795 commits

Author SHA1 Message Date
Kisaragi
9f95e7622d
fix typo in code-block kind specifier 2022-03-16 10:19:19 +09:00
Kisaragi
fc5cbba1a4
fix typo in code-block kind specifier 2022-03-16 08:50:30 +09:00
Jason Newcomb
30b333645d Don't lint undocumented_unsafe_blocks on bad proc-macro spans. 2022-03-15 16:52:28 -04:00
Paolo Gentili
a39d649733 Lint list updated 2022-03-15 19:38:40 +01:00
Jason Newcomb
65f96e2b53 Rework undocumented_unsafe_blocks 2022-03-15 14:18:05 -04:00
Paolo Gentili
5c1843dbce Moved lint to restriction 2022-03-15 18:45:01 +01:00
dswij
6a3dbe4798 unnecessary_lazy_eval show suggestions on multiline lint 2022-03-15 23:59:26 +08:00
bors
b83c6323c7 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
2022-03-15 09:02:38 +00:00
flip1995
b981748036
Move iter_with_drain to nursery 2022-03-15 09:46:49 +01:00
bors
71ecbc42f9 Auto merge of #8509 - smoelius:fix-8507, r=giraffate
Fix `unncessary_to_owned` false positive

Fix #8507

changelog: none
2022-03-15 01:08:47 +00:00
Dylan DPC
5ed40229ac fix typos 2022-03-15 02:00:08 +01:00
bors
9a1f6a9795 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
2022-03-14 23:39:50 +00:00
bors
0e1311b70f 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`
2022-03-14 22:12:25 +00:00
xFrednet
2ee5372389
Allow single_component_path_imports for all macros 2022-03-14 22:45:00 +01: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
bors
dc5423ad44 Auto merge of #8534 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2022-03-14 10:34:17 +00:00
flip1995
2ebd0b20b0
Bump nightly version -> 2022-03-14 2022-03-14 11:29:39 +01:00
flip1995
d5ab347d5c
Merge remote-tracking branch 'upstream/master' into rustup 2022-03-14 11:29:18 +01:00
bors
e2e492c10e 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`]
2022-03-13 16:11:25 +00:00
Jaeyong Sung
800f66de2b
add clearing return vars 2022-03-14 00:13:57 +09:00
bors
75b616e92f 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
2022-03-13 14:49:56 +00:00
Tianyi Song
a944ccb677 Check if lhs < rhs in modulos and emit 2022-03-11 16:02:49 +08: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
Eric Holk
05008fe127 Remove is_autoref parameter 2022-03-10 17:24:08 -08:00
Jaeyong Sung
1ad7e7097a
remove parameters that are only used in recursion 2022-03-10 16:06:35 +09:00
Jaeyong Sung
52d35dca6a
fix build error 2022-03-10 15:53:53 +09:00
J-ZhengLi
086b045822 add checking for x -> x and ref x -> x and related test cases. 2022-03-10 14:46:58 +08:00
Jaeyong Sung
69161c6327
fix to lint Self::function 2022-03-10 15:46:40 +09:00
bors
8ae74da63b 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
2022-03-10 03:08:34 +00:00
J-ZhengLi
ec9116412a rename lint to needless_match
and change its lint group to "complexity"
2022-03-10 09:44:25 +08:00
lcnr
a4d6c61bdc add #[rustc_pass_by_value] to more types 2022-03-08 15:39:52 +01:00
J-ZhengLi
750204e3e3 fix a bug that caused internal test fail 2022-03-08 18:15:11 +08:00
J-ZhengLi
6bfc1120cf add nop if-let expression check.
re-design test cases as some of them are not worth the effort to check.
2022-03-08 17:37:53 +08:00
bors
d3bc1297db 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
2022-03-07 18:06:31 +00:00
Eric Holk
840dc10471 Update clippy to new ExprUseVisitor delegate 2022-03-07 09:43:27 -08:00
Eric Holk
43ce0a94af Update and fix clippy tests 2022-03-07 08:47:18 -08:00
Eric Holk
b86620da37 Stabilize const_fn_fn_ptr_basics and const_fn_trait_bound 2022-03-07 08:47:15 -08:00
J-ZhengLi
db3fcf8df7 add basic code to check nop match blocks
modify `manual_map_option` uitest because one test case has confliction.
2022-03-07 18:12:35 +08:00
Jaeyong Sung
e4766776d2
add test for trait recursion 2022-03-07 12:15:00 +09:00
Nicholas Nethercote
b36924b4ac 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.
2022-03-07 13:41:47 +11: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
Matthias Krüger
dcc6ecf6ab Rollup merge of #94617 - pierwill:update-itertools, r=Mark-Simulacrum
Update `itertools`

Update to 0.10.1
2022-03-06 15:41:26 +01:00
bors
0c483f69db 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.
2022-03-06 07:46:56 +00:00
Samuel E. Moelius III
1a95590faf Fix #8507 2022-03-05 21:18:44 -05:00
Samuel E. Moelius III
ce841fe73b Format with rustfmt_if_chain 2022-03-05 18:35:58 -05:00
Jack Huey
9bee01eb91 Change syntax for TyAlias where clauses 2022-03-05 13:13:45 -05:00
Jaeyong Sung
c4a3ccde78
fix lint errors 2022-03-05 21:49:36 +09:00
Jaeyong Sung
2b0f9aba64
don't lint when implementing trait 2022-03-05 21:39:00 +09:00
Esteban Kuber
90da7cdd41 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.
2022-03-05 02:42:55 +00:00