]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoSplit VarState
rail [Wed, 10 Jun 2020 03:05:51 +0000 (15:05 +1200)]
Split VarState

3 years agoadd concinient methods to Increment/InitializeVisitor
rail [Wed, 10 Jun 2020 02:48:26 +0000 (14:48 +1200)]
add concinient methods to Increment/InitializeVisitor

3 years agoCheck if it's after the loop earlier
rail [Wed, 10 Jun 2020 02:41:09 +0000 (14:41 +1200)]
Check if it's after the loop earlier

3 years agoUse else blocks instead of return statements in Increment/InitializeVisitor
rail [Wed, 10 Jun 2020 02:25:06 +0000 (14:25 +1200)]
Use else blocks instead of return statements in Increment/InitializeVisitor

3 years agoUse if_chain in Increment/InitializeVisitor
rail [Wed, 10 Jun 2020 02:21:58 +0000 (14:21 +1200)]
Use if_chain in Increment/InitializeVisitor

3 years agoAuto merge of #6077 - ebroto:revert_or_fun_call_const, r=matthiaskrgr
bors [Thu, 24 Sep 2020 14:14:53 +0000 (14:14 +0000)]
Auto merge of #6077 - ebroto:revert_or_fun_call_const, r=matthiaskrgr

Revert: or_fun_call should lint calls to `const fn`s with no args

The changes in #5889 and #5984 were done under the incorrect assumption that a `const fn` with no args was guaranteed to be evaluated at compile time.  A `const fn` is only guaranteed to be evaluated at compile time if it's inside a const context (the initializer of a `const` or a `static`).

See this [zulip conversation](https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/Common.20misconception.3A.20.60const.20fn.60.20and.20its.20effect.20on.20codegen/near/208059113) for more details on this common misconception.

Given that none of the linted methods by `or_fun_call` can be called in const contexts, the lint should make no exceptions.

changelog: [`or_fun_call`] lints again calls to `const fn` with no args

3 years agoAuto merge of #6076 - rail-rain:fix_fp_explicit_counter_loop, r=matthiaskrgr
bors [Thu, 24 Sep 2020 13:45:24 +0000 (13:45 +0000)]
Auto merge of #6076 - rail-rain:fix_fp_explicit_counter_loop, r=matthiaskrgr

Fix a FP in `explicit_counter_loop`

Fixes #4677 and #6074

Fix a false positive in `explicit_counter_loop` where the loop counter is used after incremented, adjust the test so that counters are incremented at the end of the loop and add the test for this false positive.

---

changelog: Fix a false positive in `explicit_counter_loop` where the loop counter is used after incremented

3 years agoAuto merge of #6044 - rschoon:rc-buffer, r=yaahc
bors [Wed, 23 Sep 2020 18:35:08 +0000 (18:35 +0000)]
Auto merge of #6044 - rschoon:rc-buffer, r=yaahc

Add `rc_buffer` lint for checking Rc<String> and friends

Fixes #2623

This is a bit different from the original PR attempting to implement this type of lint.   Rather than linting against converting into the unwanted types, this PR lints against declaring the unwanted type in a struct or function definition.

I'm reasonably happy with what I have here, although I used the fully qualified type names for the Path and OsString suggestions, and I'm not sure if I should have just used the short versions instead, even if they might not have been declared via use.

Also, I don't know if "buffer type" is the best way to put it or not.  Alternatively I could call it a "growable type" or "growable buffer type", but I was thinking of PathBuf when I started making the lint.

changelog: Add `rc_buffer` lint

3 years agoSatisfy rc_buffer lint in Constant::Binary byte string by copying data
Robin Schoonover [Wed, 23 Sep 2020 02:34:38 +0000 (20:34 -0600)]
Satisfy rc_buffer lint in Constant::Binary byte string by copying data

We can avoid the data copy again by fixing rustc_ast::ast::LitKind
later.

3 years agoRevert "Avoid or_fun_call for const_fn with no args"
Eduardo Broto [Tue, 22 Sep 2020 22:39:00 +0000 (00:39 +0200)]
Revert "Avoid or_fun_call for const_fn with no args"

This reverts commit 5d66bd7bb3fd701d70ec11217e3f89fabe5cb0a7.

3 years agoRevert "or_fn_call: ignore nullary associated const fns"
Eduardo Broto [Tue, 22 Sep 2020 22:34:56 +0000 (00:34 +0200)]
Revert "or_fn_call: ignore nullary associated const fns"

This reverts commit 7a66e6502dc3c7085b3f4078c01d4957d96175ed.

3 years agoFix a FP in `explicit_counter_loop`
rail [Wed, 10 Jun 2020 02:05:32 +0000 (14:05 +1200)]
Fix a FP in `explicit_counter_loop`

Fix a false positive in `explicit_counter_loop` where the loop counter is used after incremented,
adjust the test so that counters are incremented at the end of the loop
and add the test for this false positive.

3 years agoAuto merge of #6069 - alex-700:redundant-pattern-matching-in-macro, r=Manishearth
bors [Tue, 22 Sep 2020 16:01:39 +0000 (16:01 +0000)]
Auto merge of #6069 - alex-700:redundant-pattern-matching-in-macro, r=Manishearth

Forbid redundant_pattern_matching triggering in macros

fixes #6065

changelog: forbid redundant_pattern_matching triggering in macros

3 years agoForbid redundant_pattern_matching triggering in macros
Aleksei Latyshev [Sun, 20 Sep 2020 09:38:23 +0000 (12:38 +0300)]
Forbid redundant_pattern_matching triggering in macros

- remove ice-2636 test

3 years agoAuto merge of #6071 - ebroto:rustup, r=ebroto
bors [Mon, 21 Sep 2020 13:43:01 +0000 (13:43 +0000)]
Auto merge of #6071 - ebroto:rustup, r=ebroto

Rustup

r? `@ghost`

changelog: none

3 years agoSplit redundant_pattern_matching tests
Eduardo Broto [Mon, 21 Sep 2020 13:32:26 +0000 (15:32 +0200)]
Split redundant_pattern_matching tests

This is to avoid the 200 lines stderr file limit

3 years agoMerge remote-tracking branch 'upstream/master' into rustup
Eduardo Broto [Mon, 21 Sep 2020 13:11:24 +0000 (15:11 +0200)]
Merge remote-tracking branch 'upstream/master' into rustup

3 years agoRemove `can_suggest` from Clippy.
Christiaan Dirkx [Sun, 20 Sep 2020 22:00:33 +0000 (00:00 +0200)]
Remove `can_suggest` from Clippy.

Removes `can_suggest` from as it is no longer used.
Reverts rust-clippy#5724.

3 years agoUpdate Clippy testcases
Christiaan Dirkx [Sun, 20 Sep 2020 21:59:34 +0000 (23:59 +0200)]
Update Clippy testcases

Update the test `redundant_pattern_matching`: check if `is_some` and `is_none` are suggested within const contexts.

3 years agoAuto merge of #76136 - CDirkx:const-result, r=dtolnay
bors [Sun, 20 Sep 2020 13:07:11 +0000 (13:07 +0000)]
Auto merge of #76136 - CDirkx:const-result, r=dtolnay

Stabilize some Result methods as const

Stabilize the following methods of Result as const:
 - `is_ok`
 - `is_err`
 - `as_ref`

A test is also included, analogous to the test for `const_option`.

These methods are currently const under the unstable feature `const_result` (tracking issue: #67520).
I believe these methods to be eligible for stabilization because of the stabilization of #49146 (Allow if and match in constants) and the trivial implementations, see also: [PR#75463](https://github.com/rust-lang/rust/pull/75463) and [PR#76135](https://github.com/rust-lang/rust/pull/76135).

Note: these methods are the only methods currently under the `const_result` feature, thus this PR results in the removal of the feature.

Related: #76225

3 years agoUpdate src/tools/clippy/clippy_lints/src/matches.rs
CDirkx [Sun, 20 Sep 2020 10:21:23 +0000 (12:21 +0200)]
Update src/tools/clippy/clippy_lints/src/matches.rs

Co-authored-by: Ralf Jung <post@ralfj.de>
3 years agoRemove `can_suggest` check for `is_ok` and `is_err`.
Christiaan Dirkx [Sun, 20 Sep 2020 08:46:30 +0000 (10:46 +0200)]
Remove `can_suggest` check for `is_ok` and `is_err`.

`is_ok` and `is_err` are stabilized as const and can thus always be suggested.

3 years agoUpdate Clippy testcases
Christiaan Dirkx [Sun, 20 Sep 2020 01:32:36 +0000 (03:32 +0200)]
Update Clippy testcases

Update the test `redundant_pattern_matching`: check if `is_ok` and `is_err` are suggested within const contexts.
Also removes the `redundant_pattern_matching_const_result` test, as it is no longer needed.

3 years agoAuto merge of #6046 - rail-rain:change_criteria_non_copy_const, r=flip1995
bors [Fri, 18 Sep 2020 14:34:04 +0000 (14:34 +0000)]
Auto merge of #6046 - rail-rain:change_criteria_non_copy_const, r=flip1995

Change the criteria of `interior_mutable_const`

This implements my suggestion [here](https://github.com/rust-lang/rust-clippy/issues/5050#issuecomment-680310889), and so hopefully fixes #5050.

* 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

---

changelog: Change the criteria of `declare_interior_mutable_const` and `borrow_interior_mutable_const` to narrow the lints to only lint things that defenitly is a interior mutable type, not potentially.

3 years agoadd `WRAPPED_SELF: Option<Self>` in the test
rail [Thu, 17 Sep 2020 09:14:14 +0000 (21:14 +1200)]
add `WRAPPED_SELF: Option<Self>` in the test

3 years agorewrite the test and fix a minor fp
rail [Thu, 17 Sep 2020 07:37:42 +0000 (19:37 +1200)]
rewrite the test and fix a minor fp

* rewrite the test for `declare_interior_mutable_const from scratch`

* fix a minor false positive where `Cell<"const T>` gets linted twice

3 years agoChange the criteria of `interior_mutable_const`
rail [Tue, 25 Aug 2020 03:13:40 +0000 (15:13 +1200)]
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

3 years agoMove rc_buffer lint into perf category
Robin Schoonover [Wed, 16 Sep 2020 23:19:35 +0000 (17:19 -0600)]
Move rc_buffer lint into perf category

3 years agoAuto merge of #6034 - rail-rain:fix_fp_in_indexing_slicing, r=flip1995
bors [Wed, 16 Sep 2020 22:45:36 +0000 (22:45 +0000)]
Auto merge of #6034 - rail-rain:fix_fp_in_indexing_slicing, r=flip1995

Treat refs to arrays the same as owned arrays in `indexing_slicing` and `out_of_bounds_indexing`

Fixes #6021

...and remove `walk_ptrs_ty` in favour of `peel_refs`, which came in 2019.

---

changelog: Fix a false positive in `indexing_slicing` and `out_of_bounds_indexing` where references to arrays weren't treated as arrays.

3 years agoreplace `walk_ptrs_ty` with `peel_refs`
rail [Fri, 11 Sep 2020 03:06:49 +0000 (15:06 +1200)]
replace `walk_ptrs_ty` with `peel_refs`

3 years agofix a FP in `indexing_slicing`
rail [Fri, 11 Sep 2020 02:41:54 +0000 (14:41 +1200)]
fix a FP in `indexing_slicing`

treat refs to arrays the same as arrays
in `indexing_slicing` and `out_of_bounds_indexing`

3 years agoAuto merge of #5937 - montrivo:option_if_let_else, r=flip1995
bors [Wed, 16 Sep 2020 19:36:49 +0000 (19:36 +0000)]
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.

3 years agoAuto merge of #6025 - thomcc:compare_exchange_atomics, r=flip1995
bors [Wed, 16 Sep 2020 18:33:38 +0000 (18:33 +0000)]
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!

3 years agoAuto merge of #6038 - mikerite:lint-5734, r=matthiaskrgr
bors [Wed, 16 Sep 2020 18:13:36 +0000 (18:13 +0000)]
Auto merge of #6038 - mikerite:lint-5734, r=matthiaskrgr

Add `manual-strip` lint

Add `manual-strip` lint.

changelog: Add `manual-strip` lint

3 years agooption_if_let_else - change misleading test file section
Tim Nielens [Wed, 16 Sep 2020 17:59:51 +0000 (19:59 +0200)]
option_if_let_else - change misleading test file section

3 years agoAuto merge of #6048 - giraffate:add_note_to_shadow_unrelated, r=matthiaskrgr
bors [Wed, 16 Sep 2020 17:52:40 +0000 (17:52 +0000)]
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

3 years agoAuto merge of #6042 - euclio:println-empty, r=flip1995
bors [Wed, 16 Sep 2020 17:16:07 +0000 (17:16 +0000)]
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`

3 years agoAuto merge of #6057 - giraffate:update_doc_about_moving_to_zulip, r=flip1995
bors [Wed, 16 Sep 2020 15:39:39 +0000 (15:39 +0000)]
Auto merge of #6057 - giraffate:update_doc_about_moving_to_zulip, r=flip1995

Update documentation about moving from Discord to Zulip

Moving from Discord to Zulip was discussed at https://github.com/rust-lang/rust-clippy/issues/5943 and new stream in Zulip was created at https://github.com/rust-lang/rust-clippy/issues/5943#issuecomment-691984366.

changelog: none

3 years ago{print,write}-with-newline: do not suggest empty format string
Andy Russell [Mon, 14 Sep 2020 18:58:39 +0000 (14:58 -0400)]
{print,write}-with-newline: do not suggest empty format string

3 years agoUpdate documentation about moving from Discord to Zulip
Takayuki Nakata [Wed, 16 Sep 2020 15:06:43 +0000 (00:06 +0900)]
Update documentation about moving from Discord to Zulip

3 years agoAuto merge of #6056 - rust-lang:flip1995/triagebot, r=flip1995
bors [Wed, 16 Sep 2020 14:40:43 +0000 (14:40 +0000)]
Auto merge of #6056 - rust-lang:flip1995/triagebot, r=flip1995

Add S-* label modifier to triagebot

changelog: none

3 years agoAdd S-* label modifier to triagebot
Philipp Krones [Wed, 16 Sep 2020 14:38:58 +0000 (16:38 +0200)]
Add S-* label modifier to triagebot

3 years agoAuto merge of #6055 - lzutao:bump-cmark, r=phansch
bors [Wed, 16 Sep 2020 05:26:30 +0000 (05:26 +0000)]
Auto merge of #6055 - lzutao:bump-cmark, r=phansch

Bump pulldown-cmark v0.8

Closes  #6054

changelog: none

3 years agobump pulldown-cmark v0.8
Lzu Tao [Wed, 16 Sep 2020 05:09:57 +0000 (12:09 +0700)]
bump pulldown-cmark v0.8

3 years agoExtend testing of rc_buffer lint
Robin Schoonover [Wed, 16 Sep 2020 03:10:50 +0000 (21:10 -0600)]
Extend testing of rc_buffer lint

3 years agooption_if_let_else - distinguish pure from impure else expressions
Tim Nielens [Fri, 21 Aug 2020 22:43:04 +0000 (00:43 +0200)]
option_if_let_else - distinguish pure from impure else expressions

3 years agomanual-strip: Fix formatting
Michael Wright [Tue, 15 Sep 2020 19:25:03 +0000 (21:25 +0200)]
manual-strip: Fix formatting

3 years agomanual-strip: Add additional test
Michael Wright [Tue, 15 Sep 2020 19:30:01 +0000 (21:30 +0200)]
manual-strip: Add additional test

3 years agoMerge branch 'master' into lint-5734
Michael Wright [Tue, 15 Sep 2020 19:21:35 +0000 (21:21 +0200)]
Merge branch 'master' into lint-5734

3 years agoAuto merge of #6043 - HaramanJohal:margin_of_error, r=matthiaskrgr
bors [Tue, 15 Sep 2020 17:17:31 +0000 (17:17 +0000)]
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

3 years agoAuto merge of #6049 - flip1995:rustup, r=flip1995
bors [Tue, 15 Sep 2020 16:46:41 +0000 (16:46 +0000)]
Auto merge of #6049 - flip1995:rustup, r=flip1995

Fix clippy hard-code slice::Iter path

r? `@ghost`

changelog: none

3 years agoupdate lint docs
Haraman Johal [Tue, 15 Sep 2020 16:29:41 +0000 (17:29 +0100)]
update lint docs

3 years agoAdd note to `shadow_unrelated`
Takayuki Nakata [Tue, 15 Sep 2020 15:25:00 +0000 (00:25 +0900)]
Add note to `shadow_unrelated`

This lint can be disabled at function level.

3 years agoAuto merge of #6045 - giraffate:remove_extra_blank_line, r=flip1995
bors [Tue, 15 Sep 2020 12:26:25 +0000 (12:26 +0000)]
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">

3 years agoFix clippy hard-code slice::Iter path
Lzu Tao [Tue, 15 Sep 2020 10:21:40 +0000 (10:21 +0000)]
Fix clippy hard-code slice::Iter path

3 years agoAuto merge of #6013 - ebroto:diagnostic_item_restriction, r=flip1995
bors [Tue, 15 Sep 2020 09:30:54 +0000 (09:30 +0000)]
Auto merge of #6013 - ebroto:diagnostic_item_restriction, r=flip1995

Internal lint: suggest `is_type_diagnostic_item` over `match_type` where applicable

changelog: none

3 years agoFix usage of backquotes in suggestion
Eduardo Broto [Tue, 15 Sep 2020 08:31:50 +0000 (10:31 +0200)]
Fix usage of backquotes in suggestion

3 years agoMisc doc updates
Eduardo Broto [Sun, 6 Sep 2020 21:57:24 +0000 (23:57 +0200)]
Misc doc updates

3 years agoFix dogfood after MatchTypeOnDiagItem
Eduardo Broto [Sun, 6 Sep 2020 21:48:04 +0000 (23:48 +0200)]
Fix dogfood after MatchTypeOnDiagItem

3 years agoAdd internal lint MatchTypeOnDiagItem
Eduardo Broto [Sun, 6 Sep 2020 21:32:48 +0000 (23:32 +0200)]
Add internal lint MatchTypeOnDiagItem

3 years agoRemove an extra blank line in `shadow_same`
Takayuki Nakata [Mon, 14 Sep 2020 23:51:52 +0000 (08:51 +0900)]
Remove an extra blank line in `shadow_same`

3 years agoclarify margin of error in wording of float comparison operator lint messages
Haraman Johal [Mon, 14 Sep 2020 23:20:31 +0000 (00:20 +0100)]
clarify margin of error in wording of float comparison operator lint messages

3 years agoApply rc_buffer lint to Arc<T>
Robin Schoonover [Mon, 14 Sep 2020 04:17:10 +0000 (22:17 -0600)]
Apply rc_buffer lint to Arc<T>

3 years agoAdd rc_buffer lint for Rc<String> and other buffer types
Robin Schoonover [Mon, 14 Sep 2020 03:52:25 +0000 (21:52 -0600)]
Add rc_buffer lint for Rc<String> and other buffer types

3 years agoAuto merge of #5998 - deg4uss3r:master, r=yaahc
bors [Mon, 14 Sep 2020 19:56:47 +0000 (19:56 +0000)]
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

3 years agoFix `manual-strip` dogfood errors
Michael Wright [Mon, 14 Sep 2020 04:11:35 +0000 (06:11 +0200)]
Fix `manual-strip` dogfood errors

3 years agoNew lint: `manual-strip`
Michael Wright [Mon, 14 Sep 2020 04:11:35 +0000 (06:11 +0200)]
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

3 years agoAuto merge of #6035 - matthiaskrgr:try_into_show_type, r=flip1995
bors [Sun, 13 Sep 2020 18:57:55 +0000 (18:57 +0000)]
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.

3 years agoMerge pull request #6036 from giraffate/update_verbose_bit_mask_to_pedantic
Manish Goregaokar [Sun, 13 Sep 2020 16:24:23 +0000 (09:24 -0700)]
Merge pull request #6036 from giraffate/update_verbose_bit_mask_to_pedantic

Downgrade `verbose_bit_mask` to pedantic

3 years agoDowngrade `verbose_bit_mask` to pedantic
Takayuki Nakata [Sun, 13 Sep 2020 14:23:16 +0000 (23:23 +0900)]
Downgrade `verbose_bit_mask` to pedantic

3 years agouseless_conversion: show type in error message.
Matthias Krüger [Sun, 13 Sep 2020 10:42:14 +0000 (12:42 +0200)]
useless_conversion: show type in error message.

changelog: useless_conversion: show type in error message.

3 years agoAuto merge of #6032 - matthiaskrgr:move_consume, r=flip1995
bors [Sun, 13 Sep 2020 08:10:12 +0000 (08:10 +0000)]
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

3 years agoAuto merge of #6030 - rail-rain:fix_use_snippet_in_types, r=matthiaskrgr
bors [Sun, 13 Sep 2020 07:37:40 +0000 (07:37 +0000)]
Auto merge of #6030 - rail-rain:fix_use_snippet_in_types, r=matthiaskrgr

fix some use of `snippet` in `types.rs`

changelog: none

3 years agoAuto merge of #6033 - flip1995:rustup, r=flip1995
bors [Sun, 13 Sep 2020 06:01:21 +0000 (06:01 +0000)]
Auto merge of #6033 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: none

3 years agoMerge remote-tracking branch 'upstream/master' into rustup
flip1995 [Sat, 12 Sep 2020 13:58:41 +0000 (15:58 +0200)]
Merge remote-tracking branch 'upstream/master' into rustup

3 years agointo_iter_on_ref: rephrase lint message: will not move the x -> will not consume...
Matthias Krüger [Fri, 11 Sep 2020 14:52:25 +0000 (16:52 +0200)]
into_iter_on_ref: rephrase lint message: will not move the x -> will not consume the x

imo that's a bit clearer.

3 years agoAuto merge of #75800 - Aaron1011:feature/full-nt-tokens, r=petrochenkov
bors [Fri, 11 Sep 2020 02:35:01 +0000 (02:35 +0000)]
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.

3 years agoFully integrate token collection for additional AST structs
Aaron Hill [Sat, 22 Aug 2020 02:11:41 +0000 (22:11 -0400)]
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

3 years agoAdd comments to the invalid_atomic_ordering example
Thom Chiovoloni [Thu, 10 Sep 2020 21:50:10 +0000 (14:50 -0700)]
Add comments to the invalid_atomic_ordering example

3 years agoAuto merge of #5977 - xvschneider:AddLintPanicInResult, r=matthiaskrgr
bors [Thu, 10 Sep 2020 16:22:20 +0000 (16:22 +0000)]
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

3 years agoMerge commit '5034d47f721ff4c3a3ff2aca9ef2ef3e1d067f9f' into clippyup
flip1995 [Thu, 10 Sep 2020 15:47:07 +0000 (17:47 +0200)]
Merge commit '5034d47f721ff4c3a3ff2aca9ef2ef3e1d067f9f' into clippyup

3 years agoAuto merge of #6028 - giraffate:fix_typo, r=flip1995
bors [Thu, 10 Sep 2020 15:41:29 +0000 (15:41 +0000)]
Auto merge of #6028 - giraffate:fix_typo, r=flip1995

Fix typo

changelog: none

3 years agoAuto merge of #6019 - rail-rain:improve_known_probs_mut_key, r=flip1995
bors [Thu, 10 Sep 2020 15:17:09 +0000 (15:17 +0000)]
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`

3 years agoFix spelling of "Known problems section" of `interior_mutable_key`
Philipp Krones [Thu, 10 Sep 2020 15:08:10 +0000 (17:08 +0200)]
Fix spelling of "Known problems section" of `interior_mutable_key`

3 years agoAuto merge of #6020 - matthiaskrgr:ra_dev_setup_update, r=flip1995
bors [Thu, 10 Sep 2020 14:55:17 +0000 (14:55 +0000)]
Auto merge of #6020 - matthiaskrgr:ra_dev_setup_update, r=flip1995

update cargo dev ra-setup to changed rustc source paths

changelog: none

3 years agoAuto merge of #5980 - matsujika:create-dir, r=flip1995
bors [Thu, 10 Sep 2020 14:34:22 +0000 (14:34 +0000)]
Auto merge of #5980 - matsujika:create-dir, r=flip1995

Add a lint to prevent `create_dir` from being used

This closes #5950
changelog: none

3 years agoAuto merge of #5931 - montrivo:unit-arg, r=flip1995
bors [Thu, 10 Sep 2020 14:11:27 +0000 (14:11 +0000)]
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`

3 years agoAuto merge of #6023 - matthiaskrgr:box, r=flip1995
bors [Thu, 10 Sep 2020 13:49:50 +0000 (13:49 +0000)]
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

3 years agoFix typo
Takayuki Nakata [Thu, 10 Sep 2020 13:39:08 +0000 (22:39 +0900)]
Fix typo

3 years agoAuto merge of #6027 - flip1995:rustup, r=flip1995
bors [Thu, 10 Sep 2020 13:25:39 +0000 (13:25 +0000)]
Auto merge of #6027 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: none

3 years agoCleanup of rustup
flip1995 [Thu, 10 Sep 2020 12:18:05 +0000 (14:18 +0200)]
Cleanup of rustup

3 years agoAuto merge of #6024 - matthiaskrgr:unit_type, r=phansch
bors [Thu, 10 Sep 2020 07:49:07 +0000 (07:49 +0000)]
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

3 years agofix some use of `snippet` in `types.rs`
rail [Tue, 8 Sep 2020 23:04:29 +0000 (11:04 +1200)]
fix some use of `snippet` in `types.rs`

3 years agoAh, right, rerun the scripts
Thom Chiovoloni [Thu, 10 Sep 2020 06:22:01 +0000 (23:22 -0700)]
Ah, right, rerun the scripts

3 years agoAddress small review comments
Thom Chiovoloni [Thu, 10 Sep 2020 06:12:57 +0000 (23:12 -0700)]
Address small review comments

3 years agoAuto merge of #75573 - Aaron1011:feature/const-mutation-lint, r=oli-obk
bors [Thu, 10 Sep 2020 05:54:26 +0000 (05:54 +0000)]
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.

3 years agoUse AtomicU8 in ordering example so all operations can be demonstrated
Thom Chiovoloni [Wed, 9 Sep 2020 21:40:43 +0000 (14:40 -0700)]
Use AtomicU8 in ordering example so all operations can be demonstrated

3 years agoSeparate compare_exchange and compare_exchange_weak uitests
Thom Chiovoloni [Wed, 9 Sep 2020 21:32:38 +0000 (14:32 -0700)]
Separate compare_exchange and compare_exchange_weak uitests

3 years agoDetect fetch_update misuse in invalid_atomic_ordering too
Thom Chiovoloni [Wed, 9 Sep 2020 21:12:14 +0000 (14:12 -0700)]
Detect fetch_update misuse in invalid_atomic_ordering too

3 years agoExtend invalid_atomic_ordering to detect misuse of compare_exchange{,_weak}
Thom Chiovoloni [Wed, 9 Sep 2020 21:00:31 +0000 (14:00 -0700)]
Extend invalid_atomic_ordering to detect misuse of compare_exchange{,_weak}