Commit graph

9394 commits

Author SHA1 Message Date
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
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
bors
12ce312bb2 Auto merge of #6013 - ebroto:diagnostic_item_restriction, r=flip1995
Internal lint: suggest `is_type_diagnostic_item` over `match_type` where applicable

changelog: none
2020-09-15 09:30:54 +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
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
Manish Goregaokar
f96c47effa
Merge pull request #6036 from giraffate/update_verbose_bit_mask_to_pedantic
Downgrade `verbose_bit_mask` to pedantic
2020-09-13 09:24:23 -07: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
bors
f2ecf39828 Auto merge of #6033 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2020-09-13 06:01:21 +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
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
fd42ab4dab Auto merge of #6020 - matthiaskrgr:ra_dev_setup_update, r=flip1995
update cargo dev ra-setup to changed rustc source paths

changelog: none
2020-09-10 14:55:17 +00: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
bors
e0f46a19bc Auto merge of #6024 - matthiaskrgr:unit_type, r=phansch
print the unit type `()` in related lint messages.

changelog: print the unit type `()` in related lint messages
2020-09-10 07:49:07 +00:00
rail
f3489d4a5e fix some use of snippet in types.rs 2020-09-10 19:31:43 +12:00
bors
961f18317d Auto merge of #75573 - Aaron1011:feature/const-mutation-lint, r=oli-obk
Add CONST_ITEM_MUTATION lint

Fixes #74053
Fixes #55721

This PR adds a new lint `CONST_ITEM_MUTATION`.
Given an item `const FOO: SomeType = ..`, this lint fires on:

* Attempting to write directly to a field (`FOO.field = some_val`) or
  array entry (`FOO.array_field[0] = val`)
* Taking a mutable reference to the `const` item (`&mut FOO`), including
  through an autoderef `FOO.some_mut_self_method()`

The lint message explains that since each use of a constant creates a
new temporary, the original `const` item will not be modified.
2020-09-10 05:54:26 +00:00
Vali Schneider
f90b1fc063 cargo dev update-lints 2020-09-09 14:06:11 -07:00
Vali Schneider
3550568a54 removing if chain and renaming lint 2020-09-09 14:02:34 -07:00
Matthias Krüger
de195f2d3d print the unit type () in related lint messages. 2020-09-09 17:59:13 +02:00
Matthias Krüger
4db10297c1 link to the Box docs in related lint documentation. 2020-09-09 16:54:24 +02:00
Matthias Krüger
46b1643132 update cargo dev ra-setup to changed rustc source paths 2020-09-09 11:57:30 +02:00
rail
d712d7f700 Improve "known problems" of interior_mutable_key
* Remove the mention to `Rc` and `Arc` as these are `Freeze`
  so the lint correctly handles already.

* Instead, explain what could cause a false positive,
  and mention `bytes` as an example.
2020-09-09 14:18:19 +12:00
Ricky
d719b48543 Move map_err_ignore from style to pedantic 2020-09-08 19:37:14 -04:00
Aaron Hill
f23670ed68 Adjust Clippy for CONST_ITEM_MUTATION lint
We no longer lint assignments to const item fields in the
`temporary_assignment` lint, since this is now covered by the
`CONST_ITEM_MUTATION` lint.

Additionally, we `#![allow(const_item_mutation)]` in the
`borrow_interior_mutable_const.rs` test. Clippy UI tests are run with
`-D warnings`, which seems to cause builtin lints to prevent Clippy
lints from running.
2020-09-08 17:59:56 -04:00
bors
8b54f1e2d9 Auto merge of #6016 - giraffate:restrict_same_item_push, r=ebroto
Restrict `same_item_push` to suppress false positives

It only emits a lint when the pushed item is a literal, a constant and an immutable binding that are initialized with those, as discussed in https://github.com/rust-lang/rust-clippy/pull/5997#pullrequestreview-483005186.

Fix https://github.com/rust-lang/rust-clippy/issues/5985

changelog: Restrict `same_item_push` to literals, constants and immutable bindings that are initialized with those.

r? `@ebroto`
2020-09-08 21:34:55 +00:00
bors
8d6cf3a824 Auto merge of #6018 - ebroto:rustup, r=ebroto
Rustup

r? `@ghost`

changelog: none
2020-09-08 20:43:02 +00:00
Eduardo Broto
e83190bdd4 Merge remote-tracking branch 'upstream/master' into rustup 2020-09-08 22:26:31 +02:00