Commit Graph

9915 Commits

Author SHA1 Message Date
bors
b1faa7f002 Auto merge of #6271 - camsteffen:vec-box-import, r=flip1995
Fix vec_box scope error

changelog: Fix vec_box suggestion with wrong type scope

Fixes #6236
2020-11-08 12:02:30 +00:00
bors
abfa331f26 Auto merge of #6205 - josephlr:empty-loop2, r=flip1995
Enable empty_loop lint for no_std crates

Depends on #6162. Fixes #6161

We skip the lint if the `loop {}` is in the `#[panic_handler]` as the
main recommendation we give is to panic, which obviously isn't
possible in a panic handler.

changelog: Enable empty_loop lint for no_std crates
2020-11-08 11:41:22 +00:00
flip1995
00dee9d916
Update reference files 2020-11-08 12:40:41 +01:00
Joseph Richey
3579b7de24
Update clippy_lints/src/loops.rs
Fix NITs

Co-authored-by: Philipp Krones <hello@philkrones.com>
2020-11-08 12:38:10 +01:00
Joe Richey
c6a91df838
Enable empty_loop lint for no_std crates
We skip the lint if the `loop {}` is in the `#[panic_handler]` as the
main recommendation we give is to panic, which obviously isn't
possible in a panic handler.

Signed-off-by: Joe Richey <joerichey@google.com>
2020-11-08 12:38:10 +01:00
bors
96d5f45ade Auto merge of #6301 - alex-700:fix-map-clone, r=matthiaskrgr
do not trigger map_clone in the case of &mut

fixes #6299
changelog: do not trigger map_clone in the case of &mut
2020-11-08 01:28:27 +00:00
bors
c015622568 Auto merge of #6304 - matthiaskrgr:crash_6302, r=llogiq
FROM_ITER_INSTEAD_OF_COLLECT: avoid unwrapping unconditionally

Fixes #6302

changelog: fix unwrap of None when checking libcore with clippy
2020-11-07 18:10:35 +00:00
bors
5effc99812 Auto merge of #6298 - JohnTitor:fix-example, r=llogiq
Fix `await_holding_refcell_ref` examples for clarify

- Remove redundant `()`
- Fix variable name

changelog: none
2020-11-07 17:48:46 +00:00
bors
4aca13f56b Auto merge of #6287 - camsteffen:readme, r=llogiq
Readme improvements

~Moved the table of contents up, added an Overview heading.~

~Made the "All the Clippy Lints" link clearer.~

Formatted the lint categories as a table with the default lint level (instead of saying on/off by default). Tweaked the descriptions.

changelog: Improve Readme
2020-11-07 17:26:58 +00:00
bors
92ba07582e Auto merge of #6134 - patrickelectric:as_utf8, r=llogiq
Check when `from_utf8` is called from sliced byte array from string

---

*Please keep the line below*
changelog: Fix #5487: Add linter to check when `from_utf8` is called from sliced byte array from string.
2020-11-07 17:06:27 +00:00
bors
694cec12be Auto merge of #6110 - rail-rain:care_enums_non_copy_const, r=llogiq
"Respect" enums in `interior_mutable_const`

fixes #3962
fixes #3825

Hello,

It might not be a good idea to submit another relatively large PR while I have an opened PR; but, I've finished this anyway. This may be able to wait for months.

Note: the code uses the MIR interpreter, which the author of #3962 thought unlikely to be a solution. This might be over-engineering; but, I think it's important to be able to work with the 'http' crate (#3825). (And, I don't want to write a MIR visitor)

---

changelog: fix a false positive in two `interior_mutable_const` lints where a constant with enums gets linted
even if it uses a clearly unfrozen variant
2020-11-07 15:51:13 +00:00
bors
4bbef42c48 Auto merge of #6272 - camsteffen:unnecesary-lazy-eval-type, r=llogiq
Fix unnecessary_lazy_eval suggestion applicability

changelog: Fix unnecessary_lazy_eval suggestion applicability when breaking type inference

Fixes #6240
2020-11-07 10:01:46 +00:00
Matthias Krüger
5253595b3b FROM_ITER_INSTEAD_OF_COLLECT: avoid unwrapping unconditionally
Fixes #6302
2020-11-06 19:34:34 +01:00
bors
2ea08e1c53 Auto merge of #6294 - giraffate:fix_suggestion_to_add_space_in_manual_async, r=Manishearth
Fix suggestion to add unneeded space in `manual_async`

Fix a same case as https://github.com/rust-lang/rust-clippy/pull/6247

changelog: Fix suggestion to add unneeded space in `manual_async`
2020-11-06 18:10:43 +00:00
Takayuki Nakata
b7892c6a26 Refactor to make getting position just before RArrow a common function 2020-11-06 22:54:38 +09:00
Aleksei Latyshev
5f57608604
do not trigger map_clone in the case of &mut 2020-11-06 14:38:46 +03:00
Takayuki Nakata
1624b00bde Fix suggestion to add unneeded space in manual_async 2020-11-06 08:40:43 +09:00
Yuki Okushi
1e4ce0fcaa Fix await_holding_refcell_ref examples for clarify 2020-11-06 04:02:41 +09:00
bors
b20d4c155d Auto merge of #6296 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2020-11-05 13:14:26 +00:00
Patrick José Pereira
bc27d1492d Add string_from_utf8_as_bytes linter
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
2020-11-04 21:17:46 -03:00
Cameron Steffen
fd8decee6a Readme improvements
Format lint categories as a table with the default lint level.
2020-11-04 17:29:19 -06:00
bors
0c1531a5c4 Auto merge of #78662 - sexxi-goose:add_expr_id_to_delegate, r=nikomatsakis
Provide diagnostic suggestion in ExprUseVisitor Delegate

The [Delegate trait](981346fc07/compiler/rustc_typeck/src/expr_use_visitor.rs (L28-L38)) currently use `PlaceWithHirId` which is composed of Hir `Place` and the
corresponding expression id.

Even though this is an accurate way of expressing how a Place is used,
it can cause confusion during diagnostics.

Eg:

```
let arr : [String; 5];

let [a, ...]     =   arr;
 ^^^ E1 ^^^      =  ^^E2^^
 ```

 Here `arr` is moved because of the binding created E1. However, when we
 point to E1 in diagnostics with the message `arr` was moved, it can be
 confusing.  Rather we would like to report E2 to the user.

 Closes: https://github.com/rust-lang/project-rfc-2229/issues/20

r? `@ghost`
2020-11-04 22:45:15 +00:00
bors
0d2f1aef02 Auto merge of #6247 - giraffate:fix_suggestion_to_add_space_in_unused_unit, r=ebroto
Fix suggestion to add unneeded space in `unused_unit`

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

changelog: Fix suggestion to add unneeded space in `unused_unit`
2020-11-04 22:42:10 +00:00
bors
5b52474ae6 Auto merge of #5911 - hegza:issue-568, r=ebroto
Add lint for 'field_reassign_with_default` #568

changelog: Add lint for field_reassign_with_default that checks if mutable object + field modification is used to edit a binding initialized with Default::default() instead of struct constructor.

Fixes #568

Notes:
- Checks for reassignment of one or more fields of a binding initialized with Default::default().
- Implemented using EarlyLintPass, might be future proofed better with LateLintPass.
- Does not trigger if Default::default() is used via another type implementing Default.
- This is a re-open of [PR#4761](https://github.com/rust-lang/rust-clippy/pull/4761), but I couldn't figure out how to re-open that one so here's a new one with the requested changes :S
2020-11-04 22:21:44 +00:00
bors
62c0d29f17 Auto merge of #6292 - ebroto:rustup, r=ebroto
Rustup

changelog: none

r? `@ghost`
2020-11-04 21:53:32 +00:00
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
a6611de75a Include bindings as machine applicable 2020-11-02 12:57:37 -06:00