Commit graph

9882 commits

Author SHA1 Message Date
Eduardo Broto
f5166e81b1 Run cargo dev fmt 2020-11-04 22:41:15 +01:00
Eduardo Broto
834ad5c516 Merge remote-tracking branch 'upstream/master' into rustup 2020-11-04 22:37:11 +01:00
oli
83edb2f4e4 s/Scalar::Raw/Scalar::Int 2020-11-04 10:11:31 +00:00
Oliver Scherer
6fdbde5f46 Split the "raw integer bytes" part out of Scalar 2020-11-04 09:58:59 +00:00
bors
c2cf40cdcd Auto merge of #6284 - camsteffen:rustc-sym, r=flip1995
Use const sym where possible

I ran a regex search and replace to use const `sym` values where possible. This should give some performance boost by avoiding string interning at runtime.

Con: It is not as consistent as always using `sym!`.

I also changed an internal lint to suggest using `sym::{}`, making an assumption that this will always work for diagnostic items.

changelog: none
2020-11-04 09:22:54 +00:00
bors
3a34bc017d Auto merge of #6270 - ClashTheBunny:clarify_allow_deny_enable_disable, r=flip1995
Clarify allow/warn/deny documentation.  Remove enable/disable.

Disable and enable when not specifically explained were not clear to me
as an English language speaker, but I was able to figure it out fairly
easily due to the examples having A/W, which I assumed meant `allow` and
`warn`.  I removed both words to be sure it was clear as well as
extending the note on what deny means.  It now includes a statement on
exactly what each word means.

Documentation only update.

*Please keep the line below*
changelog: none
2020-11-04 08:49:10 +00:00
Randall Mason
cf2043d4a2 Update wording to avoid code having "lint" metaphor 2020-11-03 15:59:24 -06:00
bors
225ce5ff58 Auto merge of #6233 - montrivo:manual_ok_or, r=flip1995
add manual_ok_or lint

Implements partially #5923

changelog: add lint manual_ok_or
2020-11-03 16:42:59 +00:00
bors
2fe87a89c9 Auto merge of #6165 - dvermd:ref_option_ref, r=flip1995
Add lint 'ref_option_ref' #1377

This lint checks for usage of `&Option<&T>` which can be simplified as `Option<&T>` as suggested in #1377.

This WIP PR is here to get feedback on the lint as there's more cases to be handled:
* statics/consts,
* associated types,
* type alias,
* function/method parameter/return,
* ADT definitions (struct/tuple struct fields, enum variants)

changelog: Add 'ref_option_ref' lint
2020-11-03 16:21:51 +00:00
bors
a2bf404d34 Auto merge of #6101 - pitiK3U:from_iter_instead_of_collect, r=flip1995
Add lint: from_iter_instead_of_collect

Fixes #5679

This implements lint for `::from_iter()` from #5679 not the general issue (`std::ops::Add::add`, etc.).
This lint checks if expression is function call with `from_iter` name and if it's implementation of the `std::iter::FromIterator` trait.

changelog: Introduce  from_iter_instead_of_collect lint
2020-11-03 15:59:16 +00:00
Piti the little Light
ddf23d649a
Fix: Use .collect() instead of ::fromIterator() 2020-11-03 16:44:24 +01:00
Piti the little Light
52d1ea3c9a
Fix: Don't show lint for types that doesn't implement Iterator 2020-11-03 16:44:24 +01:00
Piti the little Light
f359fb872b
Improve error message 2020-11-03 16:44:24 +01:00
Piti the little Light
abdb7aeb55
Remove backticks 2020-11-03 16:44:24 +01:00
Piti the little Light
854f2cef06
Run cargo dev fmt 2020-11-03 16:44:24 +01:00
Piti the little Light
e320dd3042
Improve: error message 2020-11-03 16:44:23 +01:00
Piti the little Light
0ab96ba2c0
Allow lint 2020-11-03 16:44:23 +01:00
Piti the little Light
8906040445
Improvements from PR feedback 2020-11-03 16:44:21 +01:00
Piti the little Light
a85670652a
Update: stderr message format 2020-11-03 16:42:30 +01:00
Piti the little Light
8a5d78b71a
Fix from_iter_instead_of_collect lint crashing on exprs without path segment 2020-11-03 16:42:30 +01:00
Piti the little Light
1b117f4629
Add tests for from_iter_instead_of_collect 2020-11-03 16:42:30 +01:00
Piti the little Light
9d6eedf5f2
Run cargo dev update_lints 2020-11-03 16:42:30 +01:00
Piti the little Light
315bab0ea1
Add from_iter_instead_of_collect lint implementation 2020-11-03 16:42:28 +01:00
bors
3ee9c2e1a0 Auto merge of #6037 - matthiaskrgr:single_char_insert, r=flip1995
single_char_insert_str: lint using insert_str() on single-char literals and suggest insert()

Fixes #6026

changelog: add single_char_insert_str lint which lints using string.insert_str() with single char literals and suggests string.insert() with a char
2020-11-03 15:36:33 +00:00
Cameron Steffen
b2332a7357 Change lint to use const sym 2020-11-02 11:52:17 -06:00
Cameron Steffen
22cc77a232 Use const rustc sym where possible 2020-11-02 11:46:37 -06: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
Eduardo Broto
f8ac1f99ef Address suggestions in PR review 2020-10-30 23:47:22 +01:00
Eduardo Broto
d958269fe5 Rename single_char_push_str to single_char_add_str 2020-10-30 23:29:44 +01:00
Matthias Krüger
c1eb8ceede get_hint_if_single_char_arg: fix bug where multi-char letters are not detected properly 2020-10-30 23:29:44 +01:00
Matthias Krüger
c6412aeebc handle macros returning Strings in single_char_push_str and single_char_insert_str 2020-10-30 23:29:38 +01:00
Matthias Krüger
2350ee75b2 single_char_push_str lint using insert_str() on single-char literals and suggest insert()
changelog: single_char_push_str: lint using string.insert_str() with single char literals and suggests string.insert() with a char

Fixes #6026
2020-10-30 23:28:17 +01: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
Randall Mason
9f402c991b Clarify allow/warn/deny. Remove enable/disable.
Disable and enable when not specifically explained were not clear to me
as an English language speaker, but I was able to figure it out fairly
easily due to the examples having A/W, which I assumed meant `allow` and
`warn`.  I removed both words to be sure it was clear as well as
extending the note on what deny means.  It now includes a statement on
exactly what each word means.
2020-10-30 12:16:11 -05: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
Tim Nielens
d780f61d7b add manual_ok_or / pr remarks 2020-10-29 19:08:54 +01:00