Commit graph

4579 commits

Author SHA1 Message Date
rail
d655c0a938 Change the criteria of interior_mutable_const
* stop linting associated types and generic type parameters
* start linting ones in trait impls
  whose corresponding definitions in the traits are generic
* remove the `is_copy` check
  as presumably the only purpose of it is to allow
  generics with `Copy` bounds as `Freeze` is internal
  and generics are no longer linted
* remove the term 'copy' from the tests
  as being `Copy` no longer have meaning
2020-09-17 19:38:37 +12:00
rail
ce06472246 replace walk_ptrs_ty with peel_refs 2020-09-17 10:11:59 +12:00
rail
2ce2d6b40e fix a FP in indexing_slicing
treat refs to arrays the same as arrays
in `indexing_slicing` and `out_of_bounds_indexing`
2020-09-17 10:11:10 +12:00
bors
06f1902878 Auto merge of #5937 - montrivo:option_if_let_else, r=flip1995
option_if_let_else - distinguish pure from impure else expressions

Addresses partially #5821.

changelog: improve the lint `option_if_let_else`. Suggest `map_or` or `map_or_else` based on the else expression purity.
2020-09-16 19:36:49 +00:00
bors
44d6439bfd Auto merge of #6025 - thomcc:compare_exchange_atomics, r=flip1995
Extend invalid_atomic_ordering for compare_exchange{,_weak} and fetch_update

changelog: The invalid_atomic_ordering lint can now detect misuse of `compare_exchange`, `compare_exchange_weak`, and `fetch_update`.

---

I was surprised not to find an issue or existing support here, since these are the functions which are always hardest to get the ordering right on for me (as the allowed orderings for `fail` depend on the `success` parameter).

I believe this lint now covers all atomic methods which care about their ordering now, but I could be wrong.

Hopefully I didn't forget to do anything for the PR!
2020-09-16 18:33:38 +00:00
bors
5e60497fb8 Auto merge of #6038 - mikerite:lint-5734, r=matthiaskrgr
Add `manual-strip` lint

Add `manual-strip` lint.

changelog: Add `manual-strip` lint
2020-09-16 18:13:36 +00:00
bors
b08bbe50ea Auto merge of #6048 - giraffate:add_note_to_shadow_unrelated, r=matthiaskrgr
Add note to `shadow_unrelated`

Fix #5455.

This lint can be disabled at function level.

changelog: none
2020-09-16 17:52:40 +00:00
bors
61dd007536 Auto merge of #6042 - euclio:println-empty, r=flip1995
{print,write}-with-newline: do not suggest empty format string

changelog: do not suggest empty format strings in `print-with-newline` and `write-with-newline`
2020-09-16 17:16:07 +00:00
Andy Russell
0261e341fd
{print,write}-with-newline: do not suggest empty format string 2020-09-16 11:25:53 -04:00
Lzu Tao
ad6f8c6354 bump pulldown-cmark v0.8 2020-09-16 12:09:57 +07:00
Tim Nielens
6ba36bcfd3 option_if_let_else - distinguish pure from impure else expressions 2020-09-16 01:30:50 +02:00
Michael Wright
79a0e5110a manual-strip: Fix formatting 2020-09-15 21:32:27 +02:00
Michael Wright
8b04c2d6e8 Merge branch 'master' into lint-5734 2020-09-15 21:21:35 +02:00
bors
0695f21994 Auto merge of #6043 - HaramanJohal:margin_of_error, r=matthiaskrgr
clarify margin of error in wording of float comparison operator lint messages

fixes #6040

changelog: change wording of float comparison operator to make margin of error less ambiguous
2020-09-15 17:17:31 +00:00
bors
190c6ea369 Auto merge of #6049 - flip1995:rustup, r=flip1995
Fix clippy hard-code slice::Iter path

r? `@ghost`

changelog: none
2020-09-15 16:46:41 +00:00
Haraman Johal
16b6cebaa6 update lint docs 2020-09-15 17:29:41 +01:00
Takayuki Nakata
44eb66d947 Add note to shadow_unrelated
This lint can be disabled at function level.
2020-09-16 01:01:31 +09:00
bors
9f0f035fe0 Auto merge of #6045 - giraffate:remove_extra_blank_line, r=flip1995
Remove an extra blank line in `shadow_same`

It seems to be an extra blank line in doc example.

changelog: none

<img width="1143" alt="スクリーンショット 2020-09-15 8 50 30" src="https://user-images.githubusercontent.com/17407489/93149409-369df080-f731-11ea-9a39-d8bbc72b61ee.png">
2020-09-15 12:26:25 +00:00
Lzu Tao
78f9ea5431 Fix clippy hard-code slice::Iter path 2020-09-15 10:21:40 +00:00
Eduardo Broto
d0b5663d30 Fix usage of backquotes in suggestion 2020-09-15 10:45:57 +02:00
Eduardo Broto
c86a7e5f38 Misc doc updates 2020-09-15 10:29:53 +02:00
Eduardo Broto
332c2dcb4d Fix dogfood after MatchTypeOnDiagItem 2020-09-15 10:29:53 +02:00
Eduardo Broto
8afa7ed6ae Add internal lint MatchTypeOnDiagItem 2020-09-15 10:29:53 +02:00
Takayuki Nakata
fd151f5135 Remove an extra blank line in shadow_same 2020-09-15 08:51:52 +09:00
Haraman Johal
4d73ccaa94 clarify margin of error in wording of float comparison operator lint messages 2020-09-15 00:20:31 +01:00
bors
f82e84c894 Auto merge of #5998 - deg4uss3r:master, r=yaahc
Add map_err_ignore lint

In a large code base a lot of times errors are ignored by using something like:

```rust
foo.map_err(|_| Some::Enum)?;
```

This drops the original error in favor of a enum that will not have the original error's context. This lint helps catch throwing away the original error in favor of an enum without its context.

---

*Please keep the line below*
changelog: Added map_err_ignore lint
2020-09-14 19:56:47 +00:00
Michael Wright
15244a88df Fix manual-strip dogfood errors 2020-09-14 06:11:35 +02:00
Michael Wright
d1f0f04a48 New lint: manual-strip
Add a new lint, `manual-strip`, that suggests using the `str::strip_prefix`
and `str::strip_suffix` methods introduced in Rust 1.45 when the same
functionality is performed 'manually'.

Closes #5734
2020-09-14 06:11:35 +02:00
bors
231444d989 Auto merge of #6035 - matthiaskrgr:try_into_show_type, r=flip1995
useless_conversion: show type in error message.

changelog: useless_conversion: show type in error message.
2020-09-13 18:57:55 +00:00
Takayuki Nakata
9ff7e5d984 Downgrade verbose_bit_mask to pedantic 2020-09-13 23:23:45 +09:00
Matthias Krüger
7ba1a8fec4 useless_conversion: show type in error message.
changelog: useless_conversion: show type in error message.
2020-09-13 12:50:39 +02:00
bors
21c351867a Auto merge of #6032 - matthiaskrgr:move_consume, r=flip1995
into_iter_on_ref: rephrase lint message: will not move the x -> will not consume the x

imo that's a bit clearer.

changelog: none
2020-09-13 08:10:12 +00:00
bors
c057621527 Auto merge of #6030 - rail-rain:fix_use_snippet_in_types, r=matthiaskrgr
fix some use of `snippet` in `types.rs`

changelog: none
2020-09-13 07:37:40 +00:00
flip1995
4df2069fc4
Merge remote-tracking branch 'upstream/master' into rustup 2020-09-12 15:58:41 +02:00
Matthias Krüger
2487f8f461 into_iter_on_ref: rephrase lint message: will not move the x -> will not consume the x
imo that's a bit clearer.
2020-09-11 16:52:25 +02:00
bors
519799f099 Auto merge of #75800 - Aaron1011:feature/full-nt-tokens, r=petrochenkov
Attach tokens to all AST types used in `Nonterminal`

We perform token capturing when we have outer attributes (for nonterminals that support attributes - e.g. `Stmt`), or when we parse a `Nonterminal` for a `macro_rules!` argument. The full list of `Nonterminals` affected by this PR is:

* `NtBlock`
* `NtStmt`
* `NtTy`
* `NtMeta`
* `NtPath`
* `NtVis`
* `NtLiteral`

Of these nonterminals, only `NtStmt` and `NtLiteral` (which is actually just an `Expr`), support outer attributes - the rest only ever have token capturing perform when they match a `macro_rules!` argument.

This makes progress towards solving https://github.com/rust-lang/rust/issues/43081 - we now collect tokens for everything that might need them. However, we still need to handle `#[cfg]`, inner attributes, and misc pretty-printing issues (e.g. #75734)

I've separated the changes into (mostly) independent commits, which could be split into individual PRs for each `Nonterminal` variant. The purpose of having them all in one PR is to do a single Crater run for all of them.

Most of the changes in this PR are trivial (adding `tokens: None` everywhere we construct the various AST structs). The significant changes are:

* `ast::Visibility` is changed from `type Visibility = Spanned<VisibilityKind>` to a `struct Visibility { kind, span, tokens }`.
* `maybe_collect_tokens` is made generic, and used for both `ast::Expr` and `ast::Stmt`.
* Some of the statement-parsing functions are refactored so that we can capture the trailing semicolon.
* `Nonterminal` and `Expr` both grew by 8 bytes, as some of the structs which are stored inline (rather than behind a `P`) now have an `Option<TokenStream>` field. Hopefully the performance impact of doing this is negligible.
2020-09-11 02:35:01 +00:00
Aaron Hill
8808dc6abf Fully integrate token collection for additional AST structs
This commit contains miscellaneous changes that don't fit into any of
the other commits in this PR
2020-09-10 17:58:14 -04:00
Thom Chiovoloni
09f7a377a6 Add comments to the invalid_atomic_ordering example 2020-09-10 14:50:10 -07:00
bors
0ab75c37b6 Auto merge of #5977 - xvschneider:AddLintPanicInResult, r=matthiaskrgr
Add lint panic in result

### Change
Adding a new "restriction" lint that will emit a warning when using "panic", "unimplemented" or "unreachable" in a function of type option/result.

### Motivation
Some codebases must avoid crashes at all costs, and hence functions of type option/result must return an error instead of crashing.

### Test plan
Running:
TESTNAME=panic_in_result cargo uitest ---

changelog: none
2020-09-10 16:22:20 +00:00
flip1995
a12828a80a Merge commit '5034d47f721ff4c3a3ff2aca9ef2ef3e1d067f9f' into clippyup 2020-09-10 17:47:07 +02:00
bors
df6d7bfbef Auto merge of #6028 - giraffate:fix_typo, r=flip1995
Fix typo

changelog: none
2020-09-10 15:41:29 +00:00
bors
99374ae136 Auto merge of #6019 - rail-rain:improve_known_probs_mut_key, r=flip1995
Improve the "known problems" section of `interior_mutable_key`

* Remove the mention to `Rc` and `Arc` as these are `Freeze` (despite my intuition) so the lint correctly handles already.
* Instead, explain what could cause a false positive, and mention `bytes` as an example.

---

changelog: Improved the "known problems" section of `interior_mutable_key`
2020-09-10 15:17:09 +00:00
Philipp Krones
36a864854f
Fix spelling of "Known problems section" of interior_mutable_key 2020-09-10 17:08:10 +02:00
bors
5034d47f72 Auto merge of #5980 - matsujika:create-dir, r=flip1995
Add a lint to prevent `create_dir` from being used

This closes #5950
changelog: none
2020-09-10 14:34:22 +00:00
bors
55efa96659 Auto merge of #5931 - montrivo:unit-arg, r=flip1995
improve the suggestion of the lint `unit-arg`

Fixes #5823
Fixes #6015

Changes
```
help: move the expression in front of the call...
  |
3 |     g();
  |
help: ...and use a unit literal instead
  |
3 |     o.map_or((), |i| f(i))
  |
```
into
```
help: move the expression in front of the call and replace it with the unit literal `()`
  |
3 |     g();
  |     o.map_or((), |i| f(i))
  |
```
changelog: improve the suggestion of the lint `unit-arg`
2020-09-10 14:11:27 +00:00
bors
0e9769e787 Auto merge of #6023 - matthiaskrgr:box, r=flip1995
link to the Box docs in related lint documentation.

changelog: link to the box docs in lint docs
2020-09-10 13:49:50 +00:00
Takayuki Nakata
f1775f05b7 Fix typo 2020-09-10 22:41:08 +09:00
bors
87a4495b5d Auto merge of #6027 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2020-09-10 13:25:39 +00:00
flip1995
2d56512580
Cleanup of rustup 2020-09-10 15:23:38 +02:00
rail
f3489d4a5e fix some use of snippet in types.rs 2020-09-10 19:31:43 +12:00