]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoBook: Write lint group descriptions
flip1995 [Sun, 17 Apr 2022 13:45:44 +0000 (15:45 +0200)]
Book: Write lint group descriptions

This removes the empty separate files for the different groups and adds
a single file giving short explanations for each group and what to
expect from those groups.

2 years agoBook: Split up and rewrite installation and usage
flip1995 [Fri, 21 Jan 2022 17:24:43 +0000 (18:24 +0100)]
Book: Split up and rewrite installation and usage

2 years agoBook: Update GHA doc and remove GitLab placeholder
flip1995 [Fri, 21 Jan 2022 16:33:01 +0000 (17:33 +0100)]
Book: Update GHA doc and remove GitLab placeholder

2 years agoRemove Edition 2018 tests section from adding lints doc
flip1995 [Fri, 21 Jan 2022 16:29:18 +0000 (17:29 +0100)]
Remove Edition 2018 tests section from adding lints doc

The UI tests now use the latest edition by default. Testing on older
editions should almost never be necessary, so I don't see a need to
document this.

2 years agoReformat internal docs
flip1995 [Fri, 21 Jan 2022 16:27:57 +0000 (17:27 +0100)]
Reformat internal docs

This reformats all the internal docs, so that the md files use at most
80 characters per line. This is the usual formatting of md files. We
allow 120 chars per line in CI though.

2 years agoMove syncing doc to book
flip1995 [Fri, 21 Jan 2022 16:11:00 +0000 (17:11 +0100)]
Move syncing doc to book

2 years agoMove internal documentation to book
flip1995 [Fri, 21 Jan 2022 15:55:26 +0000 (16:55 +0100)]
Move internal documentation to book

2 years agoBook: add a ci chapter
josh rotenberg [Tue, 3 Aug 2021 20:05:20 +0000 (13:05 -0700)]
Book: add a ci chapter

2 years agoInitial commit for the Clippy Book
josh rotenberg [Wed, 16 Jun 2021 05:05:44 +0000 (22:05 -0700)]
Initial commit for the Clippy Book

2 years agoAuto merge of #8933 - DennisOSRM:needless_braces_range_literal, r=dswij
bors [Mon, 6 Jun 2022 10:58:33 +0000 (10:58 +0000)]
Auto merge of #8933 - DennisOSRM:needless_braces_range_literal, r=dswij

Add new lint [`needless_parens_on_range_literals`]

changelog: Adds a new lint [`needless_parens_on_range_literals`] to warn on needless braces on literals in a range statement

For example, the lint would catch

```log
error: needless parenthesis on range literals can be removed
  --> $DIR/needless_parens_on_range_literals.rs:8:13
   |
LL |     let _ = ('a')..=('z');
   |             ^^^^^ help: try: `'a'`
   |
   = note: `-D clippy::needless-parens-on-range-literals` implied by `-D warnings`
```

2 years agoAuto merge of #8951 - mikerite:needless-late-init-20220605, r=giraffate
bors [Mon, 6 Jun 2022 00:25:14 +0000 (00:25 +0000)]
Auto merge of #8951 - mikerite:needless-late-init-20220605, r=giraffate

Some refactoring in `needless_late_init`

changelog: none

2 years agoUpdate CHANGELOG.md
Dennis Luxen [Sun, 5 Jun 2022 20:13:08 +0000 (22:13 +0200)]
Update CHANGELOG.md

2 years agoFix names to use plural
Dennis Luxen [Sun, 5 Jun 2022 20:12:30 +0000 (22:12 +0200)]
Fix names to use plural

2 years agoApply suggestions from code review
Dennis Luxen [Sun, 5 Jun 2022 19:41:00 +0000 (21:41 +0200)]
Apply suggestions from code review

Co-authored-by: dswij <dharmasw@outlook.com>
2 years agoRerun cargo dev update_lints
Dennis Luxen [Sat, 4 Jun 2022 20:12:35 +0000 (22:12 +0200)]
Rerun cargo dev update_lints

2 years agoImplement suggestion generation with snippet_with_applicability(.)
Dennis Luxen [Sat, 4 Jun 2022 20:08:33 +0000 (22:08 +0200)]
Implement suggestion generation with snippet_with_applicability(.)

2 years agoImplement support for implicit start and end
Dennis Luxen [Sat, 4 Jun 2022 20:01:52 +0000 (22:01 +0200)]
Implement support for implicit start and end

2 years agoMove description into lint macro
Dennis Luxen [Sat, 4 Jun 2022 19:48:44 +0000 (21:48 +0200)]
Move description into lint macro

2 years agoRewrite check to account for floating point literals
Dennis Luxen [Sat, 4 Jun 2022 19:44:37 +0000 (21:44 +0200)]
Rewrite check to account for floating point literals

2 years agoFix misnomer braces -> parenthesis
Dennis Luxen [Sat, 4 Jun 2022 17:37:28 +0000 (19:37 +0200)]
Fix misnomer braces -> parenthesis

2 years agoUpdate clippy_lints/src/needless_braces_on_range_literal.rs
Dennis Luxen [Sat, 4 Jun 2022 19:45:19 +0000 (21:45 +0200)]
Update clippy_lints/src/needless_braces_on_range_literal.rs

Co-authored-by: Alex <69764315+Serial-ATA@users.noreply.github.com>
2 years agoUpdate clippy_lints/src/needless_braces_on_range_literal.rs
Dennis Luxen [Sat, 4 Jun 2022 17:12:32 +0000 (19:12 +0200)]
Update clippy_lints/src/needless_braces_on_range_literal.rs

Co-authored-by: Alex <69764315+Serial-ATA@users.noreply.github.com>
2 years agoAdd new lint [`needless_braces_on_range_literal`]
Dennis Luxen [Fri, 3 Jun 2022 14:12:26 +0000 (16:12 +0200)]
Add new lint [`needless_braces_on_range_literal`]

2 years agoAuto merge of #8941 - DevAccentor:for_loops_over_fallibles, r=llogiq
bors [Sun, 5 Jun 2022 11:16:37 +0000 (11:16 +0000)]
Auto merge of #8941 - DevAccentor:for_loops_over_fallibles, r=llogiq

improve [`for_loops_over_fallibles`] to detect the usage of iter, iter_mut and into_iterator

fix #6762

detects code like
```rust
for _ in option.iter() {
    //..
}
```

changelog: Improve [`for_loops_over_fallibles`] to detect `for _ in option.iter() {}` or using `iter_mut()` or `into_iterator()`.

2 years agochange based on review
DevAccentor [Sun, 5 Jun 2022 08:26:29 +0000 (10:26 +0200)]
change based on review

2 years agoneedless_late_init refactoring
Michael Wright [Sun, 5 Jun 2022 05:28:28 +0000 (07:28 +0200)]
needless_late_init refactoring

Remove the unneeded wrapping and unwrapping in suggestion creation.
Collecting to Option<Vec<_>> only returns None if one of the elements is
None and that is never the case here.

2 years agoneedless_late_init refactoring
Michael Wright [Sun, 5 Jun 2022 05:22:45 +0000 (07:22 +0200)]
needless_late_init refactoring

Simplify the creation of suggestions by using `flat_map` instead of
`chain`. Note that the order of the suggestions is not important.

2 years agoneedless_late_init refactoring
Michael Wright [Sun, 5 Jun 2022 05:14:31 +0000 (07:14 +0200)]
needless_late_init refactoring

Remove duplication in creating suggestions by first mapping assignments
to spans and then suggestions.

2 years agoAuto merge of #8930 - kyoto7250:issue_8920, r=Alexendoo
bors [Sat, 4 Jun 2022 13:05:27 +0000 (13:05 +0000)]
Auto merge of #8930 - kyoto7250:issue_8920, r=Alexendoo

fix(manual_find_map and manual_filter_map): check clone method

close #8920

Added conditional branching when the clone method is used.

Thank you in advance.

---

changelog: check `clone()` and other variant preserving methods in [`manual_find_map`] and [`manual_filter_map`]

2 years agorefactor: check copied and cloned
kyoto7250 [Sat, 4 Jun 2022 12:20:41 +0000 (21:20 +0900)]
refactor: check copied and cloned

2 years agoAuto merge of #8942 - flip1995:rustup, r=flip1995
bors [Sat, 4 Jun 2022 10:55:48 +0000 (10:55 +0000)]
Auto merge of #8942 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: none

2 years agoBump nightly version -> 2022-06-04
Philipp Krones [Sat, 4 Jun 2022 10:54:20 +0000 (12:54 +0200)]
Bump nightly version -> 2022-06-04

2 years agoMerge remote-tracking branch 'upstream/master' into rustup
Philipp Krones [Sat, 4 Jun 2022 10:53:27 +0000 (12:53 +0200)]
Merge remote-tracking branch 'upstream/master' into rustup

2 years agoAuto merge of #8843 - Serial-ATA:collect-renamed, r=xFrednet
bors [Sat, 4 Jun 2022 09:49:27 +0000 (09:49 +0000)]
Auto merge of #8843 - Serial-ATA:collect-renamed, r=xFrednet

Collect renamed lints

changelog: Display past names of renamed lints on Clippy's lint list

cc #7172

r? `@xFrednet`

2 years agoimprove for_loops_over_fallibles to detect the usage of iter, iter_mut and into_iterator
DevAccentor [Sat, 4 Jun 2022 09:03:11 +0000 (11:03 +0200)]
improve for_loops_over_fallibles to detect the usage of iter, iter_mut and into_iterator

2 years agorefactor: Add some methods
kyoto7250 [Sat, 4 Jun 2022 07:55:33 +0000 (16:55 +0900)]
refactor: Add some methods

2 years agoAuto merge of #8937 - Jarcho:merge_match_passes, r=llogiq
bors [Sat, 4 Jun 2022 07:41:27 +0000 (07:41 +0000)]
Auto merge of #8937 - Jarcho:merge_match_passes, r=llogiq

Merge various passes into `Matches`

changelog: None

2 years agoMove `ManualMap` into `Matches` lint pass
Jason Newcomb [Fri, 3 Jun 2022 23:01:44 +0000 (19:01 -0400)]
Move `ManualMap` into `Matches` lint pass

2 years agoMove `TryErr` into `Matches` lint pass
Jason Newcomb [Fri, 3 Jun 2022 18:31:36 +0000 (14:31 -0400)]
Move `TryErr` into `Matches` lint pass

2 years agoMerge `SignificantDropInScrutinee` into `Matches` lint pass
Jason Newcomb [Fri, 3 Jun 2022 17:35:10 +0000 (13:35 -0400)]
Merge `SignificantDropInScrutinee` into `Matches` lint pass

2 years agoMove `MatchStrCaseMismatch` into `Matches` lint pass
Jason Newcomb [Fri, 3 Jun 2022 17:16:02 +0000 (13:16 -0400)]
Move `MatchStrCaseMismatch` into `Matches` lint pass

2 years agoMove `MatchOnVecItems` into `Matches` lint pass
Jason Newcomb [Fri, 3 Jun 2022 17:10:57 +0000 (13:10 -0400)]
Move `MatchOnVecItems` into `Matches` lint pass

2 years agoMerge `ManualUnwrapOr` into `Matches` lint pass
Jason Newcomb [Fri, 3 Jun 2022 16:29:54 +0000 (12:29 -0400)]
Merge `ManualUnwrapOr` into `Matches` lint pass

2 years agoAuto merge of #8934 - DevAccentor:as_underscore, r=Manishearth
bors [Fri, 3 Jun 2022 19:24:53 +0000 (19:24 +0000)]
Auto merge of #8934 - DevAccentor:as_underscore, r=Manishearth

add [`as_underscore`] lint

closes #8847

detect usage of `as _` and enforce the usage of explicit type like
```rust
fn foo(n: usize) {}
let n: u16 = 256;
foo(n as _);
```
will suggest to change to
```rust
fn foo(n: usize) {}
let n: u16 = 256;
foo(n as usize);
```

changelog: add [`as_underscore`] lint

2 years agoMerge `CollapsibleMatch` into `Matches` lint pass
Jason Newcomb [Fri, 3 Jun 2022 16:14:24 +0000 (12:14 -0400)]
Merge `CollapsibleMatch` into `Matches` lint pass

2 years agoadd as_underscore lint
DevAccentor [Fri, 3 Jun 2022 13:59:26 +0000 (15:59 +0200)]
add as_underscore lint

2 years agoRollup merge of #97415 - cjgillot:is-late-bound-solo, r=estebank
Dylan DPC [Fri, 3 Jun 2022 15:10:51 +0000 (17:10 +0200)]
Rollup merge of #97415 - cjgillot:is-late-bound-solo, r=estebank

Compute `is_late_bound_map` query separately from lifetime resolution

This query is actually very simple, and is only useful for functions and method.  It can be computed directly by fetching the HIR, with no need to embed it within the lifetime resolution visitor.

Based on https://github.com/rust-lang/rust/pull/96296

2 years agoAuto merge of #8831 - arieluy:type_params, r=dswij
bors [Fri, 3 Jun 2022 10:34:57 +0000 (10:34 +0000)]
Auto merge of #8831 - arieluy:type_params, r=dswij

Add new lint `mismatching_type_param_order`

changelog: Add new lint [`mismatching_type_param_order`] for checking if type parameters are consistent between type definitions and impl blocks.

fixes #7147

2 years agoManipulate lifetimes by LocalDefId for region resolution.
Camille GILLOT [Wed, 27 Apr 2022 20:15:58 +0000 (22:15 +0200)]
Manipulate lifetimes by LocalDefId for region resolution.

2 years agoRollup merge of #97653 - RalfJung:int-to-ptr, r=oli-obk
Dylan DPC [Fri, 3 Jun 2022 09:18:24 +0000 (11:18 +0200)]
Rollup merge of #97653 - RalfJung:int-to-ptr, r=oli-obk

add cast kind of from_exposed_addr (int-to-ptr casts)

This is basically the dual to https://github.com/rust-lang/rust/pull/97582, for int2ptr casts.

Cc `@tmiasko` https://github.com/rust-lang/rust/issues/97649

2 years agoAdd new lint mismatching_type_param_order
Ariel Uy [Sat, 14 May 2022 06:48:52 +0000 (23:48 -0700)]
Add new lint mismatching_type_param_order

Add new lint for checking if type parameters are consistent between type
definitions and impl blocks.

2 years agoAuto merge of #8932 - dswij:pr-8879, r=giraffate
bors [Fri, 3 Jun 2022 00:00:23 +0000 (00:00 +0000)]
Auto merge of #8932 - dswij:pr-8879, r=giraffate

`needless_return` checks for macro expr in return stmts

closes #8879

Macro expressions in returns were not checked by `needless_return`. The test added in [this commit](https://github.com/rust-lang/rust-clippy/commit/6396a7a425293745b1810566851c17cf08d36985#diff-a869168cfafb7e6e5010feb76a16389d6c96d59e98113dee5c2b304a5160e43aR51-R55) seems to have regressed.

changelog: [`needless_return`] checks for macro exprs in return statements

2 years agoAuto merge of #97575 - nnethercote:lazify-SourceFile-lines, r=Mark-Simulacrum
bors [Thu, 2 Jun 2022 18:45:29 +0000 (18:45 +0000)]
Auto merge of #97575 - nnethercote:lazify-SourceFile-lines, r=Mark-Simulacrum

Lazify `SourceFile::lines`.

`SourceFile::lines` is a big part of metadata. It's stored in a compressed form
(a difference list) to save disk space. Decoding it is a big fraction of
compile time for very small crates/programs.

This commit introduces a new type `SourceFileLines` which has a `Lines`
form and a `Diffs` form. The latter is used when the metadata is first
read, and it is only decoded into the `Lines` form when line data is
actually needed. This avoids the decoding cost for many files,
especially in `std`. It's a performance win of up to 15% for tiny
crates/programs where metadata decoding is a high part of compilation
costs.

A `RefCell` is needed because the methods that access lines data (which can
trigger decoding) take `&self` rather than `&mut self`. To allow for this,
`SourceFile::lines` now takes a `FnMut` that operates on the lines slice rather
than returning the lines slice.

r? `@Mark-Simulacrum`

2 years agoAuto merge of #8902 - PrestonFrom:add_suggestion_for_move_and_clone_when_not_ref...
bors [Thu, 2 Jun 2022 17:16:43 +0000 (17:16 +0000)]
Auto merge of #8902 - PrestonFrom:add_suggestion_for_move_and_clone_when_not_ref, r=flip1995

When setting suggestion for significant_drop_in_scrutinee, add suggestion for MoveAndClone for non-ref

When trying to set the current suggestion, if the type of the expression
is not a reference and it is not trivially pure clone copy, we should still
trigger and emit a lint message. Since this fix may require cloning an
expensive-to-clone type, do not attempt to offer a suggested fix.

This change means that matches generated from TryDesugar and AwaitDesugar
would normally trigger a lint, but they are out of scope for this lint,
so we will explicitly ignore matches with sources of TryDesugar or
AwaitDesugar.

changelog: Update for ``[`significant_drop_in_scrutinee`]`` to correctly
emit lint messages for cases where the type is not a reference *and*
not trivially pure clone copy.
changelog: [`significant_drop_in_scrutinee`]: No longer lint on Try `?`
and `await` desugared expressions.

2 years agoAuto merge of #8906 - rust-lang:copy-large-enum-variants, r=Jarcho
bors [Thu, 2 Jun 2022 16:37:09 +0000 (16:37 +0000)]
Auto merge of #8906 - rust-lang:copy-large-enum-variants, r=Jarcho

remove `large_enum_variant` suggestion for `Copy` types

Replaces the (erroneous) suggestion on `large_enum_variant` for `Copy` types by a note. This fixes #8894.

---

changelog: none

2 years agoadd cast kind of from_exposed_addr (int-to-ptr casts)
Ralf Jung [Thu, 2 Jun 2022 13:05:37 +0000 (09:05 -0400)]
add cast kind of from_exposed_addr (int-to-ptr casts)

2 years agoApply `needless_return` suggestions
dswij [Thu, 2 Jun 2022 12:17:00 +0000 (20:17 +0800)]
Apply `needless_return` suggestions

2 years ago`needless_return` checks for macro expr in return stmts
dswij [Thu, 2 Jun 2022 12:16:46 +0000 (20:16 +0800)]
`needless_return` checks for macro expr in return stmts

2 years agoAuto merge of #8905 - c410-f3r:arith, r=llogiq
bors [Thu, 2 Jun 2022 12:05:27 +0000 (12:05 +0000)]
Auto merge of #8905 - c410-f3r:arith, r=llogiq

[1/N] Implement Arithmetic lint

Assuming that https://github.com/rust-lang/rust-clippy/issues/8903 is OK, this PR starts the creation of the `Arithmetic` lint with configurable types.

My current struggle to get a rustc review inspired me to create smaller PRs in order to easy review and make merges as fast as possible. So the first step here only moves the `arithmetic.rs` file to `numeric_arithmetic.rs` to make room for the new lint.

--
changelog: none

2 years agoaccount for generics
Andre Bogus [Tue, 31 May 2022 07:23:17 +0000 (09:23 +0200)]
account for generics

2 years agoLint message correctly identifies match vs for loop
Preston From [Thu, 2 Jun 2022 08:23:42 +0000 (02:23 -0600)]
Lint message correctly identifies match vs for loop

2 years agoAuto merge of #8908 - Serial-ATA:doc-comment-issues, r=xFrednet
bors [Thu, 2 Jun 2022 07:38:01 +0000 (07:38 +0000)]
Auto merge of #8908 - Serial-ATA:doc-comment-issues, r=xFrednet

Make docs more consistent

changelog: none

This just fixes some docs to make them more consistent. I mostly just changed `// Good`, `// Bad`, etc to `Use instead:`.

2 years agofix(manual_find_map and manual_filter_map): check clone method
kyoto7250 [Wed, 1 Jun 2022 15:57:08 +0000 (00:57 +0900)]
fix(manual_find_map and manual_filter_map): check clone method

2 years agoCombine doc examples
Serial [Wed, 1 Jun 2022 22:36:02 +0000 (18:36 -0400)]
Combine doc examples

2 years agoAuto merge of #8869 - Jarcho:derive_partial_eq_without_eq, r=flip1995
bors [Wed, 1 Jun 2022 19:27:54 +0000 (19:27 +0000)]
Auto merge of #8869 - Jarcho:derive_partial_eq_without_eq, r=flip1995

Set correct `ParamEnv` for `derive_partial_eq_without_eq`

fixes #8867

changelog: Handle differing predicates applied by `#[derive(PartialEq)]` and `#[derive(Eq)]` in `derive_partial_eq_without_eq`

2 years agorename PointerAddress → PointerExposeAddress
Ralf Jung [Wed, 1 Jun 2022 17:24:44 +0000 (13:24 -0400)]
rename PointerAddress → PointerExposeAddress

2 years agoAuto merge of #7930 - lengyijun:needless_deref_new, r=Jarcho
bors [Wed, 1 Jun 2022 16:43:14 +0000 (16:43 +0000)]
Auto merge of #7930 - lengyijun:needless_deref_new, r=Jarcho

new lint: `borrow_deref_ref`

changelog: ``[`borrow_deref_ref`]``

Related pr: #6837 #7577
`@Jarcho` Could you please give a review?

`cargo lintcheck` gives no false negative (but tested crates are out-of-date).

TODO:
1. Not sure the name. `deref_on_immutable_ref` or some others?

2 years agosplit into borrow_deref_ref.rs and borrow_deref_ref_unfixable.rs
lengyijun [Wed, 1 Jun 2022 15:32:26 +0000 (15:32 +0000)]
split into borrow_deref_ref.rs and borrow_deref_ref_unfixable.rs

2 years agoLazify `SourceFile::lines`.
Nicholas Nethercote [Mon, 30 May 2022 05:59:45 +0000 (15:59 +1000)]
Lazify `SourceFile::lines`.

`SourceFile::lines` is a big part of metadata. It's stored in a compressed form
(a difference list) to save disk space. Decoding it is a big fraction of
compile time for very small crates/programs.

This commit introduces a new type `SourceFileLines` which has a `Lines`
form and a `Diffs` form. The latter is used when the metadata is first
read, and it is only decoded into the `Lines` form when line data is
actually needed. This avoids the decoding cost for many files,
especially in `std`. It's a performance win of up to 15% for tiny
crates/programs where metadata decoding is a high part of compilation
costs.

A `Lock` is needed because the methods that access lines data (which can
trigger decoding) take `&self` rather than `&mut self`. To allow for this,
`SourceFile::lines` now takes a `FnMut` that operates on the lines slice rather
than returning the lines slice.

2 years agoAuto merge of #8916 - Jarcho:swap_ptr_to_ref, r=Manishearth
bors [Tue, 31 May 2022 17:47:01 +0000 (17:47 +0000)]
Auto merge of #8916 - Jarcho:swap_ptr_to_ref, r=Manishearth

New lint `swap_ptr_to_ref`

fixes: #7381

changelog: New lint `swap_ptr_to_ref`

2 years agoAdd lint `swap_ptr_to_ref`
Jason Newcomb [Mon, 30 May 2022 16:36:05 +0000 (12:36 -0400)]
Add lint `swap_ptr_to_ref`

2 years agoAuto merge of #8884 - evantypanski:manual_range_contains_multiple, r=Manishearth
bors [Tue, 31 May 2022 16:17:12 +0000 (16:17 +0000)]
Auto merge of #8884 - evantypanski:manual_range_contains_multiple, r=Manishearth

Fix `manual_range_contains` false negative with chains of `&&` and `||`

Fixes #8745

Since the precedence for `&&` is the same as itself the HIR for a chain of `&&` ends up with a right skewed tree like:

```
     &&
    /  \
  &&   c2
 /  \
... c1
```

So only the leftmost `&&` was actually "fully" checked, the top level was just `c2` and `&&` so the `manual_range_contains` lint won't apply. This change makes it also check `c2` with `c1`.

There's a bit of a hacky solution in the [second commit](https://github.com/rust-lang/rust-clippy/commit/257f09776a9c68ac903d1f23b80c414b70de1185) to check if the number of open/closing parens in the snippet match. This is to prevent a case like `((x % 2 == 0) || (x < 0)) || (x >= 10)` from offering a suggestion like `((x % 2 == 0) || !(0..10).contains(&x)` which now won't compile.

Any suggestions for that paren hack welcome, kinda new to working on this so not too sure about possible solutions :) it's weird because I don't know how else to check for parens in HIR considering they're removed when lowering AST.

changelog: Fix [`manual_range_contains`] false negative with chains of `&&` and `||`

2 years agoAuto merge of #8564 - Jarcho:transmute_erase_regions, r=Alexendoo
bors [Tue, 31 May 2022 15:57:27 +0000 (15:57 +0000)]
Auto merge of #8564 - Jarcho:transmute_erase_regions, r=Alexendoo

Don't lint `useless_transmute` on types with erased regions

fixes #6356
fixes #3340
fixes #2906

This should get a proper fix at some point, but this at least gets the lint running on some types.

cc #5343

changelog: Don't lint `useless_transmute` on types with erased regions

2 years agoAuto merge of #8876 - Alexendoo:cast-abs-to-different-uint, r=dswij,xFrednet
bors [Tue, 31 May 2022 15:40:03 +0000 (15:40 +0000)]
Auto merge of #8876 - Alexendoo:cast-abs-to-different-uint, r=dswij,xFrednet

`cast_abs_to_unsigned`: do not remove cast if it's required

Fixes #8873

If `iX` is not cast to `uX` then keep the cast rather than removing it

changelog: [`cast_abs_to_unsigned`]: do not remove cast if it's required

2 years agoMove `useless_transmute` back to `complexity`
Jason Newcomb [Fri, 18 Mar 2022 04:59:48 +0000 (00:59 -0400)]
Move `useless_transmute` back to `complexity`

2 years agoDon't lint `useless_transmute` on types with erased regions
Jason Newcomb [Fri, 18 Mar 2022 04:58:03 +0000 (00:58 -0400)]
Don't lint `useless_transmute` on types with erased regions

2 years agoAuto merge of #8918 - Jarcho:almost_complete_letter_range, r=llogiq
bors [Tue, 31 May 2022 05:10:42 +0000 (05:10 +0000)]
Auto merge of #8918 - Jarcho:almost_complete_letter_range, r=llogiq

Add lint `almost_complete_letter_range`

fixes #7269

changelog: Add lint `almost_complete_letter_range`

2 years agoAdd lint `almost_complete_letter_range`
Jason Newcomb [Tue, 31 May 2022 02:07:49 +0000 (22:07 -0400)]
Add lint `almost_complete_letter_range`

2 years agoAuto merge of #8912 - Alexendoo:needless-late-init-ice, r=giraffate
bors [Tue, 31 May 2022 00:46:52 +0000 (00:46 +0000)]
Auto merge of #8912 - Alexendoo:needless-late-init-ice, r=giraffate

needless_late_init: fix ICE when all branches return the never type

Fixes #8911

When the assignment is done in a match guard or the if condition and all of the branches return the never type `assignment_suggestions` would return an empty `Vec` which caused the ICE. It now returns `None` in that scenario

Also moves some tests to the top of the file

changelog: ICE Fixes: [`needless_late_init`] #8911

2 years agoAuto merge of #8913 - InfRandomness:ICE-#8748, r=giraffate
bors [Tue, 31 May 2022 00:17:52 +0000 (00:17 +0000)]
Auto merge of #8913 - InfRandomness:ICE-#8748, r=giraffate

Fix #8748

Thank you for making Clippy better!

changelog: Fix ICE #8748 in shadow.rs

2 years agoAdd a pointer to address cast kind
Tomasz Miąsko [Tue, 31 May 2022 00:00:00 +0000 (00:00 +0000)]
Add a pointer to address cast kind

A pointer to address cast are often special-cased.
Introduce a dedicated cast kind to make them easy distinguishable.

2 years agoAuto merge of #8899 - botahamec:use-self-tuple-struct-variants, r=Alexendoo
bors [Mon, 30 May 2022 22:05:13 +0000 (22:05 +0000)]
Auto merge of #8899 - botahamec:use-self-tuple-struct-variants, r=Alexendoo

Fix `[use_self]` false negative with on struct and tuple struct patterns

fixes #8845

changelog: Triggered the warning for ``[`use_self`]`` on `TupleStruct` and `Struct` patterns, whereas currently it's only triggered for `Path` patterns

2 years agoFix #8748
InfRandomness [Sun, 29 May 2022 20:00:11 +0000 (20:00 +0000)]
Fix #8748

2 years agoTriggered the lint on tuple struct and struct patterns
Micha White [Thu, 26 May 2022 16:52:43 +0000 (12:52 -0400)]
Triggered the lint on tuple struct and struct patterns

2 years agorun-rustfix
lengyijun [Mon, 30 May 2022 01:49:46 +0000 (01:49 +0000)]
run-rustfix

2 years agoneedless_deref
lyj [Sun, 29 May 2022 01:57:15 +0000 (09:57 +0800)]
needless_deref

2 years agoneedless_late_init: fix ICE when all branches return the never type
Alex Macleod [Sun, 29 May 2022 18:28:34 +0000 (18:28 +0000)]
needless_late_init: fix ICE when all branches return the never type

2 years agoAuto merge of #8385 - cameron1024:doc_link_with_quotes, r=llogiq
bors [Sat, 28 May 2022 14:27:51 +0000 (14:27 +0000)]
Auto merge of #8385 - cameron1024:doc_link_with_quotes, r=llogiq

add doc_link_with_quotes lint

I'm not sure about wording, it seems OK to me but happy to change if other people have better ideas

closes #8383

---
changelog: add [`doc_link_with_quotes`] lint

2 years agoUpdate lint creation docs
Serial [Sat, 28 May 2022 13:50:14 +0000 (09:50 -0400)]
Update lint creation docs

2 years agoMake docs more consistent
Serial [Sat, 28 May 2022 13:22:59 +0000 (09:22 -0400)]
Make docs more consistent

2 years agoAuto merge of #8844 - smoelius:fixed-paths, r=Alexendoo
bors [Sat, 28 May 2022 11:28:04 +0000 (11:28 +0000)]
Auto merge of #8844 - smoelius:fixed-paths, r=Alexendoo

Check `.fixed` paths' existence in `run_ui`

This PR adds a test to check that there exists a `.fixed` file for every `.stderr` file in `tests/ui` that mentions a `MachineApplicable` lint. The test leverages `compiletest-rs`'s `rustfix_coverage` option.

I tried to add `.fixed` files where they appeared to be missing. However, 38 exceptional `.rs` files remain. Several of those include comments indicating that they are exceptions, though not all do. Apologies, as I have not tried to associate the 38 files with GH issues. (I think that would be a lot of work, and I worry about linking the wrong issue.)

changelog: none

2 years agoMerge branch 'master' into doc_link_with_quotes
llogiq [Sat, 28 May 2022 08:55:25 +0000 (10:55 +0200)]
Merge branch 'master' into doc_link_with_quotes

2 years agoremove `large_enum_variant` suggestion for `Copy` types
Andre Bogus [Fri, 27 May 2022 23:36:05 +0000 (01:36 +0200)]
remove `large_enum_variant` suggestion for `Copy` types

2 years ago[1/N] Implement Arithmetic lint
Caio [Fri, 27 May 2022 21:53:02 +0000 (18:53 -0300)]
[1/N] Implement Arithmetic lint

2 years agoIgnore `crashes` dir
Samuel E. Moelius III [Fri, 27 May 2022 20:38:28 +0000 (16:38 -0400)]
Ignore `crashes` dir

2 years agoAuto merge of #8892 - smoelius:fix-empty-line-false-positive, r=Manishearth
bors [Fri, 27 May 2022 20:34:06 +0000 (20:34 +0000)]
Auto merge of #8892 - smoelius:fix-empty-line-false-positive, r=Manishearth

Fix `empty_line_after_outer_attribute` false positive

This PR fixes a false positive in `empty_line_after_outer_attribute`.

Here is a minimal example that trigger the FP:
```rust
#[derive(clap::Parser)]
#[clap(after_help = "This ia a help message.

You're welcome.
")]
pub struct Args;
```

changelog: PF: [`empty_line_after_outer_attribute`]: No longer lints empty lines in inner string values.

2 years agoAuto merge of #8897 - tamaroning:improve_dbg, r=Alexendoo
bors [Fri, 27 May 2022 19:41:39 +0000 (19:41 +0000)]
Auto merge of #8897 - tamaroning:improve_dbg, r=Alexendoo

Introduce `allow-dbg-in-tests` config value

related to: Issue #8758,  PR https://github.com/rust-lang/rust-clippy/pull/8838

changelog: Introduced `allow-dbg-in-tests` config value. [dbg_macro] does not allow `dbg!` in test code by default.

2 years agoFix `assert!` message
Samuel E. Moelius III [Wed, 25 May 2022 11:22:04 +0000 (07:22 -0400)]
Fix `assert!` message

2 years agoAddress review comments
Samuel E. Moelius III [Tue, 24 May 2022 23:01:18 +0000 (19:01 -0400)]
Address review comments

2 years agoCheck `.fixed` paths' existence in `run_ui`
Samuel E. Moelius III [Thu, 19 May 2022 13:03:38 +0000 (09:03 -0400)]
Check `.fixed` paths' existence in `run_ui`