Commit graph

14184 commits

Author SHA1 Message Date
flip1995
af385799e0
Move internal documentation to book 2022-06-06 16:15:53 +02:00
josh rotenberg
853d7eeed6
Book: add a ci chapter 2022-06-06 16:15:52 +02:00
josh rotenberg
4e6b55e9b8
Initial commit for the Clippy Book 2022-06-06 16:15:52 +02:00
bors
0f6e50fe1b 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`
```
2022-06-06 10:58:33 +00:00
bors
3e771624e1 Auto merge of #8951 - mikerite:needless-late-init-20220605, r=giraffate
Some refactoring in `needless_late_init`

changelog: none
2022-06-06 00:25:14 +00:00
Dennis Luxen
61d7dd2af0 Update CHANGELOG.md 2022-06-05 22:47:29 +02:00
Dennis Luxen
8ba377a783 Fix names to use plural 2022-06-05 22:47:21 +02:00
Dennis Luxen
bf7a786481 Apply suggestions from code review
Co-authored-by: dswij <dharmasw@outlook.com>
2022-06-05 22:47:15 +02:00
Dennis Luxen
58a605f453 Rerun cargo dev update_lints 2022-06-05 22:47:08 +02:00
Dennis Luxen
c0aa1f78b4 Implement suggestion generation with snippet_with_applicability(.) 2022-06-05 22:47:01 +02:00
Dennis Luxen
0409306bb0 Implement support for implicit start and end 2022-06-05 22:46:53 +02:00
Dennis Luxen
2e6903ccf9 Move description into lint macro 2022-06-05 22:46:41 +02:00
Dennis Luxen
90c8463d7e Rewrite check to account for floating point literals 2022-06-05 22:46:34 +02:00
Dennis Luxen
5948959c7e Fix misnomer braces -> parenthesis 2022-06-05 22:46:23 +02:00
Dennis Luxen
8bc1be17d6 Update clippy_lints/src/needless_braces_on_range_literal.rs
Co-authored-by: Alex <69764315+Serial-ATA@users.noreply.github.com>
2022-06-05 22:46:11 +02:00
Dennis Luxen
3058cb941c Update clippy_lints/src/needless_braces_on_range_literal.rs
Co-authored-by: Alex <69764315+Serial-ATA@users.noreply.github.com>
2022-06-05 22:46:03 +02:00
Dennis Luxen
ba43f0aee9 Add new lint [needless_braces_on_range_literal] 2022-06-05 22:45:57 +02:00
bors
3e52dee646 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()`.
2022-06-05 11:16:37 +00:00
DevAccentor
3737abe802 change based on review 2022-06-05 10:26:29 +02:00
Michael Wright
a2de34720d 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.
2022-06-05 07:30:59 +02:00
Michael Wright
2a1a80d80c 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.
2022-06-05 07:30:59 +02:00
Michael Wright
94e321a6ff needless_late_init refactoring
Remove duplication in creating suggestions by first mapping assignments
to spans and then suggestions.
2022-06-05 07:30:59 +02:00
bors
542d474d38 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`]
2022-06-04 13:05:27 +00:00
kyoto7250
42cf98553a refactor: check copied and cloned 2022-06-04 21:28:14 +09:00
bors
d9ddce8a22 Auto merge of #8942 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2022-06-04 10:55:48 +00:00
Philipp Krones
36b18924a7
Bump nightly version -> 2022-06-04 2022-06-04 12:54:20 +02:00
Philipp Krones
7f402b15c7
Merge remote-tracking branch 'upstream/master' into rustup 2022-06-04 12:53:27 +02:00
bors
8ef490871c 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`
2022-06-04 09:49:27 +00:00
DevAccentor
5a49918f36 improve for_loops_over_fallibles to detect the usage of iter, iter_mut and into_iterator 2022-06-04 11:11:00 +02:00
kyoto7250
990f8bf5a6 refactor: Add some methods 2022-06-04 17:15:55 +09:00
bors
b1a3e7e9c8 Auto merge of #8937 - Jarcho:merge_match_passes, r=llogiq
Merge various passes into `Matches`

changelog: None
2022-06-04 07:41:27 +00:00
Jason Newcomb
68c411ff94 Move ManualMap into Matches lint pass 2022-06-03 19:09:50 -04:00
Jason Newcomb
67cb5ec29f Move TryErr into Matches lint pass 2022-06-03 19:09:49 -04:00
Jason Newcomb
dbc7753fb2 Merge SignificantDropInScrutinee into Matches lint pass 2022-06-03 19:09:49 -04:00
Jason Newcomb
8c8a52eeeb Move MatchStrCaseMismatch into Matches lint pass 2022-06-03 19:09:49 -04:00
Jason Newcomb
3d8d734150 Move MatchOnVecItems into Matches lint pass 2022-06-03 19:09:49 -04:00
Jason Newcomb
b337f9e62e Merge ManualUnwrapOr into Matches lint pass 2022-06-03 19:09:49 -04:00
bors
ebd357e4ab 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
2022-06-03 19:24:53 +00:00
Jason Newcomb
81e44502ac Merge CollapsibleMatch into Matches lint pass 2022-06-03 12:14:24 -04:00
DevAccentor
64fe4e32db add as_underscore lint 2022-06-03 18:11:23 +02:00
Dylan DPC
57304823db 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
2022-06-03 17:10:51 +02:00
bors
7c0d649db2 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
2022-06-03 10:34:57 +00:00
Camille GILLOT
1e86cc5194 Manipulate lifetimes by LocalDefId for region resolution. 2022-06-03 12:03:20 +02:00
Dylan DPC
baacbfda45 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
2022-06-03 11:18:24 +02:00
Ariel Uy
58cd01c2fc Add new lint mismatching_type_param_order
Add new lint for checking if type parameters are consistent between type
definitions and impl blocks.
2022-06-03 00:04:55 -07:00
bors
1194c6369e 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](6396a7a425 (diff-a869168cfafb7e6e5010feb76a16389d6c96d59e98113dee5c2b304a5160e43aR51-R55)) seems to have regressed.

changelog: [`needless_return`] checks for macro exprs in return statements
2022-06-03 00:00:23 +00:00
bors
2a18d124aa 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`
2022-06-02 18:45:29 +00:00
bors
97e5449a70 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.
2022-06-02 17:16:43 +00:00
bors
e32b66c871 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
2022-06-02 16:37:09 +00:00
Ralf Jung
0600de4d12 add cast kind of from_exposed_addr (int-to-ptr casts) 2022-06-02 10:46:13 -04:00