Commit graph

9834 commits

Author SHA1 Message Date
ThibsG
343bdb3364 Give better suggestion by working on span on deref_addrof lint 2020-11-02 18:08:38 +01:00
ThibsG
158bf9aa44 Fix incorrect suggestion for macro expansion in deref_addrof lint 2020-11-02 18:08:38 +01:00
bors
c45255b145 Auto merge of #6282 - giraffate:sync-from-rust, r=ebroto
Rustup

changelog: none
2020-11-02 07:36:35 +00:00
Takayuki Nakata
4a3a249cb6 Merge remote-tracking branch 'upstream/master' into sync-from-rust 2020-11-02 10:34:49 +09:00
bors
8a18963f28 Auto merge of #75534 - Aaron1011:feature/new-future-breakage, r=pnkfelix
Implement rustc side of report-future-incompat

cc https://github.com/rust-lang/rust/issues/71249

This is an alternative to `@pnkfelix's` initial implementation in https://github.com/pnkfelix/rust/commits/prototype-rustc-side-of-report-future-incompat (mainly because I started working before seeing that branch 😄 ).

My approach outputs the entire original `Diagnostic`, in a way that is compatible with incremental compilation. This is not yet integrated with compiletest, but can be used manually by passing `-Z emit-future-incompat-report` to `rustc`.

Several changes are made to support this feature:
* The `librustc_session/lint` module is moved to a new crate `librustc_lint_defs` (name bikesheddable). This allows accessing lint definitions from `librustc_errors`.
* The `Lint` struct is extended with an `Option<FutureBreakage>`. When present, it indicates that we should display a lint in the future-compat report. `FutureBreakage` contains additional information that we may want to display in the report (currently, a `date` field indicating when the crate will stop compiling).
* A new variant `rustc_error::Level::Allow` is added. This is used when constructing a diagnostic for a future-breakage lint that is marked as allowed (via `#[allow]` or `--cap-lints`). This allows us to capture any future-breakage diagnostics in one place, while still discarding them before they are passed to the `Emitter`.
* `DiagnosticId::Lint` is extended with a `has_future_breakage` field, indicating whether or not the `Lint` has future breakage information (and should therefore show up in the report).
* `Session` is given access to the `LintStore` via a new `SessionLintStore` trait (since `librustc_session` cannot directly reference `LintStore` without a cyclic dependency). We use this to turn a string `DiagnosticId::Lint` back into a `Lint`, to retrieve the `FutureBreakage` data.

Currently, `FutureBreakage.date` is always set to `None`. However, this could potentially be interpreted by Cargo in the future.

I've enabled the future-breakage report for the `ARRAY_INTO_ITER` lint, which can be used to test out this PR. The intent is to use the field to allow Cargo to determine the date of future breakage (as described in [RFC 2834](https://github.com/rust-lang/rfcs/blob/master/text/2834-cargo-report-future-incompat.md)) without needing to parse the diagnostic itself.

cc `@pnkfelix`
2020-11-01 16:52:28 +00:00
bors
e298c830af Auto merge of #6276 - dp304:patch-1, r=llogiq
Fix typo in adding_lints.md

changelog: none
2020-10-31 13:01:11 +00:00
dp304
edfa13da4a Fix typo in adding_lints.md 2020-10-31 13:31:54 +01:00
bors
a6b3a403ac Auto merge of #6277 - ebroto:rustup, r=ebroto
Rustup

changelog: none
2020-10-31 08:52:32 +00:00
Eduardo Broto
2eb248dd16 Fix formatting 2020-10-31 09:34:01 +01:00
Eduardo Broto
9d73371663 Merge remote-tracking branch 'upstream/master' into rustup 2020-10-31 09:33:40 +01:00
Aaron Hill
4bbc7712fc Update Clippy path to Lint 2020-10-30 21:41:16 -04:00
bors
084b203988 Auto merge of #6260 - matthiaskrgr:ices, r=ebroto
add a couple of ICE testcases

Fixes #6250
Fixes #6251
Fixes #6252
Fixes #6255
Fixes #6256

changelog: none
2020-10-30 22:19:11 +00:00
bors
7387b87bb9 Auto merge of #6197 - ThibsG:ImproveFilterNext, r=ebroto
Improve suggestions for several lints

This PR is a follow-up of this [Zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/filter_next.20lint).

It unifies placeholders for `methods` module and improves several suggestions for `filter_next`, `filter_map_next` and `map_unwrap_or` lints.

changelog: none
2020-10-30 21:58:09 +00:00
bors
0be654482c Auto merge of #6229 - henil:improve-integer-division-lint, r=phansch
Update the existing arithmetic lint

re: #6209

Updates the lint to not the error message if RHS of binary operation `/` of `%` is a literal/constant that is not `0` or `-1`, as suggested [here](https://github.com/rust-lang/rust-clippy/issues/6209#issuecomment-715624354)

changelog: Expand [`integer_arithmetic`] to work with RHS literals and constants
2020-10-30 12:37:46 +00:00
henil
fa0a78b130 removed lint for division/modulo for literal 0 2020-10-30 17:31:10 +05:30
LeSeulArtichaut
1c8c3d14ef Remove implicit Continue type 2020-10-30 12:27:47 +01:00
LeSeulArtichaut
4a06145ced Use ControlFlow::is{break,continue} 2020-10-30 12:27:46 +01:00
LeSeulArtichaut
fa79cc4f6f TypeVisitor: use ControlFlow in clippy 2020-10-30 12:27:45 +01:00
bors
74d8fbb7a4 Auto merge of #6200 - rail-rain:borrowed_box_invalid_sugg, r=phansch
fix the error-causing suggestion of 'borrowed_box'

Fixes #3128

Fix the suggestion of 'borrowed_box', which causes a syntax error because it misses necessary parentheses.

---

changelog: Fix the error-causing suggestion of 'borrowed_box'
2020-10-30 10:40:44 +00:00
bors
e01d4875e9 Auto merge of #6248 - giraffate:replace_e_easy_with_good_first_issue, r=flip1995
Replace `E-easy` with `good first issue` in `CONTRIBUTING.md`

`E-easy` isn't used, so `good first issue` is more appropriate.

changelog: none
2020-10-29 15:54:38 +00:00
bors
c57d8ae515 Auto merge of #6227 - HMPerson1:collect_map, r=phansch
Add lint for replacing `.map().collect()` with `.try_for_each()`

Fixes #6208

changelog: Add `map_collect_result_unit`
2020-10-29 15:34:15 +00:00
Takayuki Nakata
38ec920fb0
Update CONTRIBUTING.md to describe E-medium in detail
Co-authored-by: Philipp Krones <hello@philkrones.com>
2020-10-30 00:24:29 +09:00
bors
e1a2845558 Auto merge of #6226 - Urcra:master, r=flip1995
Add lint for comparing to empty slices instead of using .is_empty()

Hey first time making a clippy lint

I added the implementation of the lint the `len_zero` since it shared a lot of the code, I would otherwise have to rewrite. Just tell me if the lint should use it's own file instead

changelog: Add lint for comparing to empty slices

Fixes #6217
2020-10-29 15:12:24 +00:00
bors
ee9da9a194 Auto merge of #6176 - achris:issues/578, r=phansch
Lint items after statements in local macro expansions

The items_after_statements lint was skipping all expansions.  Instead
we should still lint local macros.

Fixes #578

---

*Please keep the line below*
changelog: The items_after_statements now applies to local macro expansions
2020-10-29 14:51:41 +00:00
Christian Nielsen
e3de544c22
Remove empty lines in doc comment
Co-authored-by: Philipp Krones <hello@philkrones.com>
2020-10-29 15:49:42 +01:00
bors
e8de57c20d Auto merge of #6212 - ThibsG:MacroTopLevelRefArg, r=flip1995
No lint in macro for `toplevel_ref_arg`

Do not lint when the span is from a macro.

Question: shouldn't we extend this for external macros also ?

Fixes: #5849

changelog: none
2020-10-29 14:29:30 +00:00
henil
e97602e482 Update existing arithmetic lint and add new tests related to it. 2020-10-29 19:08:52 +05:30
bors
6d5cd6eb8d Auto merge of #6264 - matthiaskrgr:ra_setup_no_twice, r=llogiq
cargo dev ra-setup: don't inject deps multiple times if we have already done so

Fixes #6220

changelog: none
2020-10-29 07:49:27 +00:00
Matthias Krüger
7f3462aa89 cargo dev ra-setup: don't inject deps multiple times if we have already done so
Fixes #6220
2020-10-29 03:22:02 +01:00
Eduardo Broto
50419118b4 Merge commit '645ef505da378b6f810b1567806d1bcc2856395f' into clippyup 2020-10-28 23:36:07 +01:00
Matthias Krüger
abd64d7c05 add a couple of ICE testcases
Fixes #6250
Fixes #6251
Fixes #6252
Fixes #6255
Fixes #6256
2020-10-28 23:35:11 +01:00
bors
4f1240fd94 Auto merge of #6263 - matthiaskrgr:diff_u, r=ebroto
use diff -u in driver.sh test

this changs the add/delete indication from
>
>
<
to
+
+
-
(same as git diff)

changelog: none
2020-10-28 22:33:01 +00:00
Matthias Krüger
0d6eed1b1f use diff -u in driver.sh test
this changs the add/delete indication from
>
>
<
to
+
+
-
(same as git diff)
2020-10-28 23:19:04 +01:00
bors
645ef505da Auto merge of #6257 - giraffate:sync-from-rust, r=ebroto
Rustup

changelog: none
2020-10-28 21:53:23 +00:00
Eduardo Broto
e83e79f1c2 Reinstate link to temporary_cstr_as_ptr 2020-10-28 22:36:22 +01:00
Eduardo Broto
a50d9e7af6 Deprecate temporary_cstr_as_ptr 2020-10-28 22:34:45 +01:00
Takayuki Nakata
c42a22d2dc Use double_neg.stderr 2020-10-29 01:02:09 +09:00
Takayuki Nakata
ffc2e66671 Fix reference 2020-10-28 14:36:29 +09:00
Takayuki Nakata
dace756c6f cargo dev update_lints 2020-10-28 14:25:41 +09:00
Takayuki Nakata
8e988e1c66 Merge remote-tracking branch 'upstream/master' into sync-from-rust 2020-10-28 14:14:09 +09:00
bors
de83f09be8 Auto merge of #6216 - alex-700:improve-match-like-matches-lint, r=ebroto
Improve match like matches lint

fixes #6186

changelog: improve MATCH_LIKE_MATCHES_MACRO lint
2020-10-27 23:01:35 +00:00
Aleksei Latyshev
2b7dd31368
improve MATCH_LIKE_MATCHES_MACRO lint
- add tests
- refactor match_same_arms lint
- prioritize match_expr_like_matches_macro over match_same_arms
2020-10-27 23:45:58 +03:00
Aleksei Latyshev
09e7053607
simplify SpanlessEq::eq_path_segment 2020-10-27 20:44:41 +03:00
Takayuki Nakata
8bd1e23167 Replace E-easy with good first issue in CONTRIBUTING.md
`E-easy` isn't used, so `good first issue` is more appropriate.
2020-10-27 23:34:50 +09:00
bors
8823684197 Auto merge of #6244 - mikerite:invalid_paths_20201027, r=flip1995
New internal lint: Invalid paths

Add a new internal lint that detects invalid paths in the `util::paths` and fix some invalid paths found.

This commit partially addresses #6047 but the lint would have to be run before running tests to close that issue.

changelog: none
2020-10-27 11:16:21 +00:00
Michael Wright
f79c4afd3a Fix invalid paths 2020-10-27 07:43:38 +02:00
Michael Wright
66d56fefc5 Add invalid_paths internal lint 2020-10-27 07:42:13 +02:00
rail
e568a328f9 fix the error-causing suggestion of 'borrowed_box'
fix the error-causing suggestion of 'borrowed_box',
which missed parentheses and was ambiguous.
2020-10-27 12:11:09 +13:00
Nathan Whitaker
a1bb10e9b8 Remove lint from clippy 2020-10-26 18:19:48 -04:00
ThibsG
c0dd1f9f76 Fix tests for map_unwrap_or* 2020-10-26 11:15:01 +01:00