]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoAdded a lint as suggested in 6010 which recommends using `contains()`
Ryan Sullivant [Tue, 6 Oct 2020 04:23:36 +0000 (21:23 -0700)]
Added a lint as suggested in 6010 which recommends using `contains()`
instead of `find()` follows by `is_some()` on strings

Update clippy_lints/src/find_is_some_on_strs.rs
Co-authored-by: Takayuki Nakata <f.seasons017@gmail.com>
Update clippy_lints/src/methods/mod.rs
Co-authored-by: Philipp Krones <hello@philkrones.com>
3 years agoAuto merge of #6269 - camsteffen:map-clone-deref, r=ebroto
bors [Wed, 11 Nov 2020 00:48:33 +0000 (00:48 +0000)]
Auto merge of #6269 - camsteffen:map-clone-deref, r=ebroto

Fix map_clone with deref and clone

changelog: Fix map_clone false positive with deref coercion

Fixes #6239

3 years agoFix map_clone with deref and clone
Cameron Steffen [Fri, 30 Oct 2020 14:18:16 +0000 (09:18 -0500)]
Fix map_clone with deref and clone

3 years agoAuto merge of #6303 - ThibsG:OptionOptionSerde, r=ebroto
bors [Tue, 10 Nov 2020 22:39:10 +0000 (22:39 +0000)]
Auto merge of #6303 - ThibsG:OptionOptionSerde, r=ebroto

Remove `allow` in `option_option` lint test

As it is not triggering locally anymore, I propose to remove `#[allow(clippy::option_option)]` from the test.

The goal is also to see what happens on CI.

closes: #4298

changelog: none

3 years agoAuto merge of #6319 - ebroto:rustup, r=ebroto
bors [Tue, 10 Nov 2020 21:36:00 +0000 (21:36 +0000)]
Auto merge of #6319 - ebroto:rustup, r=ebroto

Rustup

changelog: none

r? `@ghost`

3 years agoRun cargo dev fmt
Eduardo Broto [Tue, 10 Nov 2020 21:33:02 +0000 (22:33 +0100)]
Run cargo dev fmt

3 years agoMerge remote-tracking branch 'upstream/master' into rustup
Eduardo Broto [Tue, 10 Nov 2020 21:32:24 +0000 (22:32 +0100)]
Merge remote-tracking branch 'upstream/master' into rustup

3 years agoAuto merge of #6305 - smoelius:master, r=flip1995
bors [Mon, 9 Nov 2020 19:13:26 +0000 (19:13 +0000)]
Auto merge of #6305 - smoelius:master, r=flip1995

Add `let_underscore_drop`

This line generalizes `let_underscore_lock` (#5101) to warn about any initializer expression that implements `Drop`.

So, for example, the following would generate a warning:
```rust
struct Droppable;
impl Drop for Droppable {
    fn drop(&mut self) {}
}
let _ = Droppable;
```

I tried to preserve the original `let_underscore_lock` functionality in the sense that the warning generated for
```rust
let _ = mutex.lock();
```
should be unchanged.

*Please keep the line below*
changelog: Add lint [`let_underscore_drop`]

3 years agoRollup merge of #78710 - petrochenkov:macvisit, r=davidtwco
Dylan DPC [Mon, 9 Nov 2020 18:06:55 +0000 (19:06 +0100)]
Rollup merge of #78710 - petrochenkov:macvisit, r=davidtwco

rustc_ast: Do not panic by default when visiting macro calls

Panicking by default made sense when we didn't have HIR or MIR and everything worked on AST, but now all AST visitors run early and majority of them have to deal with macro calls, often by ignoring them.

The second commit renames `visit_mac` to `visit_mac_call`, the corresponding structures were renamed earlier in https://github.com/rust-lang/rust/pull/69589.

3 years agoAllow `let_underscore_drop` in `filter_methods` test
Samuel E. Moelius III [Mon, 9 Nov 2020 12:49:14 +0000 (07:49 -0500)]
Allow `let_underscore_drop` in `filter_methods` test

3 years agoAuto merge of #6278 - ThibsG:DerefAddrOf, r=llogiq
bors [Mon, 9 Nov 2020 05:25:04 +0000 (05:25 +0000)]
Auto merge of #6278 - ThibsG:DerefAddrOf, r=llogiq

Fix bad suggestions for `deref_addrof` and `try_err` lints

Fix bad suggestions when in macro expansion for `deref_addrof` and `try_err` lints.

Fixes: #6234
Fixes: #6242
Fixes: #6237
changelog: none

r? `@llogiq`

3 years agoUpdate references
Samuel E. Moelius III [Sun, 8 Nov 2020 23:32:12 +0000 (18:32 -0500)]
Update references

3 years agoUpdate lints
Samuel E. Moelius III [Sun, 8 Nov 2020 22:33:54 +0000 (17:33 -0500)]
Update lints

3 years agoUpdate clippy_lints/src/let_underscore.rs
Samuel E. Moelius [Sun, 8 Nov 2020 22:25:50 +0000 (17:25 -0500)]
Update clippy_lints/src/let_underscore.rs

Co-authored-by: Philipp Krones <hello@philkrones.com>
3 years agoUpdate clippy_lints/src/let_underscore.rs
Samuel E. Moelius [Sun, 8 Nov 2020 22:25:23 +0000 (17:25 -0500)]
Update clippy_lints/src/let_underscore.rs

Co-authored-by: Philipp Krones <hello@philkrones.com>
3 years agoUpdate clippy_lints/src/let_underscore.rs
Samuel E. Moelius [Sun, 8 Nov 2020 22:24:55 +0000 (17:24 -0500)]
Update clippy_lints/src/let_underscore.rs

Co-authored-by: Philipp Krones <hello@philkrones.com>
3 years agoAuto merge of #6267 - camsteffen:or-fun-idx, r=flip1995
bors [Sun, 8 Nov 2020 22:03:27 +0000 (22:03 +0000)]
Auto merge of #6267 - camsteffen:or-fun-idx, r=flip1995

Fix or_fun_call for index operator

changelog: Fix or_fun_call for index operator

Fixes #6266

3 years agoFix or_fun_call for index operator
Cameron Steffen [Thu, 29 Oct 2020 20:30:20 +0000 (15:30 -0500)]
Fix or_fun_call for index operator

3 years agoMake KNOW_TYPES static
Cameron Steffen [Thu, 29 Oct 2020 21:21:01 +0000 (16:21 -0500)]
Make KNOW_TYPES static

3 years agoAuto merge of #6288 - flip1995:changelog_internal, r=matthiaskrgr
bors [Sun, 8 Nov 2020 19:37:25 +0000 (19:37 +0000)]
Auto merge of #6288 - flip1995:changelog_internal, r=matthiaskrgr

Require the `changelog:` entry in the PR body to be modified

r? `@matthiaskrgr`

changelog: none

3 years agoForce contributors/reviewers to set _some_ changelog entry
flip1995 [Sun, 8 Nov 2020 15:14:38 +0000 (16:14 +0100)]
Force contributors/reviewers to set _some_ changelog entry

3 years agoAuto merge of #6293 - Urcra:lint-example-fix, r=flip1995
bors [Sun, 8 Nov 2020 14:24:58 +0000 (14:24 +0000)]
Auto merge of #6293 - Urcra:lint-example-fix, r=flip1995

Fix example used in cargo_common_metadata

The previous example used in `cargo_common_metadata`  included an authors field, even though the comment says it doesn't. And thus doesn't actually demonstrate an example of how the lint fails.

This removes that authors field from the _bad_ example and suggest to fix the _bad_ example by adding the authors field

changelog: Fix example used in `cargo_common_metadata`

3 years agoUpdate references
Samuel E. Moelius III [Sun, 8 Nov 2020 12:07:49 +0000 (07:07 -0500)]
Update references

3 years agoAuto merge of #6271 - camsteffen:vec-box-import, r=flip1995
bors [Sun, 8 Nov 2020 12:02:30 +0000 (12:02 +0000)]
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

3 years agoAdd let_underscore_drop
Samuel E. Moelius III [Sat, 7 Nov 2020 23:26:14 +0000 (18:26 -0500)]
Add let_underscore_drop

3 years agoAuto merge of #6205 - josephlr:empty-loop2, r=flip1995
bors [Sun, 8 Nov 2020 11:41:22 +0000 (11:41 +0000)]
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

3 years agoUpdate reference files
flip1995 [Sun, 8 Nov 2020 11:40:41 +0000 (12:40 +0100)]
Update reference files

3 years agoUpdate clippy_lints/src/loops.rs
Joseph Richey [Wed, 4 Nov 2020 11:27:30 +0000 (03:27 -0800)]
Update clippy_lints/src/loops.rs

Fix NITs

Co-authored-by: Philipp Krones <hello@philkrones.com>
3 years agoEnable empty_loop lint for no_std crates
Joe Richey [Fri, 23 Oct 2020 06:39:25 +0000 (23:39 -0700)]
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>
3 years agoAuto merge of #6301 - alex-700:fix-map-clone, r=matthiaskrgr
bors [Sun, 8 Nov 2020 01:28:27 +0000 (01:28 +0000)]
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

3 years agoAuto merge of #6304 - matthiaskrgr:crash_6302, r=llogiq
bors [Sat, 7 Nov 2020 18:10:35 +0000 (18:10 +0000)]
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

3 years agoAuto merge of #6298 - JohnTitor:fix-example, r=llogiq
bors [Sat, 7 Nov 2020 17:48:46 +0000 (17:48 +0000)]
Auto merge of #6298 - JohnTitor:fix-example, r=llogiq

Fix `await_holding_refcell_ref` examples for clarify

- Remove redundant `()`
- Fix variable name

changelog: none

3 years agoAuto merge of #6287 - camsteffen:readme, r=llogiq
bors [Sat, 7 Nov 2020 17:26:58 +0000 (17:26 +0000)]
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

3 years agoAuto merge of #6134 - patrickelectric:as_utf8, r=llogiq
bors [Sat, 7 Nov 2020 17:06:27 +0000 (17:06 +0000)]
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.

3 years agoAuto merge of #6110 - rail-rain:care_enums_non_copy_const, r=llogiq
bors [Sat, 7 Nov 2020 15:51:13 +0000 (15:51 +0000)]
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

3 years agoAuto merge of #6272 - camsteffen:unnecesary-lazy-eval-type, r=llogiq
bors [Sat, 7 Nov 2020 10:01:46 +0000 (10:01 +0000)]
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

3 years agoFROM_ITER_INSTEAD_OF_COLLECT: avoid unwrapping unconditionally
Matthias Krüger [Fri, 6 Nov 2020 18:34:34 +0000 (19:34 +0100)]
FROM_ITER_INSTEAD_OF_COLLECT: avoid unwrapping unconditionally

Fixes #6302

3 years agoAuto merge of #6294 - giraffate:fix_suggestion_to_add_space_in_manual_async, r=Manish...
bors [Fri, 6 Nov 2020 18:10:43 +0000 (18:10 +0000)]
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`

3 years agoRemove needless allow
ThibsG [Fri, 30 Oct 2020 17:43:27 +0000 (18:43 +0100)]
Remove needless allow

3 years agoRefactor to make getting position just before RArrow a common function
Takayuki Nakata [Fri, 6 Nov 2020 13:54:38 +0000 (22:54 +0900)]
Refactor to make getting position just before RArrow a common function

3 years agodo not trigger map_clone in the case of &mut
Aleksei Latyshev [Fri, 6 Nov 2020 11:38:46 +0000 (14:38 +0300)]
do not trigger map_clone in the case of &mut

3 years agoFix suggestion to add unneeded space in `manual_async`
Takayuki Nakata [Thu, 5 Nov 2020 04:56:57 +0000 (13:56 +0900)]
Fix suggestion to add unneeded space in `manual_async`

3 years agoFix `await_holding_refcell_ref` examples for clarify
Yuki Okushi [Thu, 5 Nov 2020 19:02:41 +0000 (04:02 +0900)]
Fix `await_holding_refcell_ref` examples for clarify

3 years agoFix incorrect suggestion for `try_err` lint when `Err` arg is itself a macro
ThibsG [Thu, 5 Nov 2020 17:00:34 +0000 (18:00 +0100)]
Fix incorrect suggestion for `try_err` lint when `Err` arg is itself a macro

3 years agoMerge commit 'b20d4c155d2fe3a8391f86dcf9a8c49e17188703' into clippyup
flip1995 [Thu, 5 Nov 2020 13:29:48 +0000 (14:29 +0100)]
Merge commit 'b20d4c155d2fe3a8391f86dcf9a8c49e17188703' into clippyup

3 years agoAuto merge of #6296 - flip1995:rustup, r=flip1995
bors [Thu, 5 Nov 2020 13:14:26 +0000 (13:14 +0000)]
Auto merge of #6296 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: none

3 years agoSkip rustfmt as it is wanted for this test
ThibsG [Mon, 2 Nov 2020 17:03:16 +0000 (18:03 +0100)]
Skip rustfmt as it is wanted for this test

3 years agoAdd string_from_utf8_as_bytes linter
Patrick José Pereira [Thu, 8 Oct 2020 03:19:56 +0000 (00:19 -0300)]
Add string_from_utf8_as_bytes linter

Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
3 years agoReadme improvements
Cameron Steffen [Tue, 3 Nov 2020 17:44:26 +0000 (11:44 -0600)]
Readme improvements

Format lint categories as a table with the default lint level.

3 years agoAuto merge of #78662 - sexxi-goose:add_expr_id_to_delegate, r=nikomatsakis
bors [Wed, 4 Nov 2020 22:45:15 +0000 (22:45 +0000)]
Auto merge of #78662 - sexxi-goose:add_expr_id_to_delegate, r=nikomatsakis

Provide diagnostic suggestion in ExprUseVisitor Delegate

The [Delegate trait](https://github.com/rust-lang/rust/blob/981346fc07dd5ef414c5b1b21999f7604cece006/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`

3 years agoAuto merge of #6247 - giraffate:fix_suggestion_to_add_space_in_unused_unit, r=ebroto
bors [Wed, 4 Nov 2020 22:42:10 +0000 (22:42 +0000)]
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`

3 years agoFix example for cargo common data
Urcra [Wed, 4 Nov 2020 22:39:52 +0000 (23:39 +0100)]
Fix example for cargo common data

3 years agoAuto merge of #5911 - hegza:issue-568, r=ebroto
bors [Wed, 4 Nov 2020 22:21:44 +0000 (22:21 +0000)]
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

3 years agoAuto merge of #6292 - ebroto:rustup, r=ebroto
bors [Wed, 4 Nov 2020 21:53:32 +0000 (21:53 +0000)]
Auto merge of #6292 - ebroto:rustup, r=ebroto

Rustup

changelog: none

r? `@ghost`

3 years agoRun cargo dev fmt
Eduardo Broto [Wed, 4 Nov 2020 21:41:15 +0000 (22:41 +0100)]
Run cargo dev fmt

3 years agoMerge remote-tracking branch 'upstream/master' into rustup
Eduardo Broto [Wed, 4 Nov 2020 21:37:11 +0000 (22:37 +0100)]
Merge remote-tracking branch 'upstream/master' into rustup

3 years agos/Scalar::Raw/Scalar::Int
oli [Sun, 1 Nov 2020 16:57:03 +0000 (16:57 +0000)]
s/Scalar::Raw/Scalar::Int

3 years agoSplit the "raw integer bytes" part out of `Scalar`
Oliver Scherer [Sat, 26 Sep 2020 13:15:35 +0000 (15:15 +0200)]
Split the "raw integer bytes" part out of `Scalar`

3 years agoAuto merge of #6284 - camsteffen:rustc-sym, r=flip1995
bors [Wed, 4 Nov 2020 09:22:54 +0000 (09:22 +0000)]
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

3 years agoAuto merge of #6270 - ClashTheBunny:clarify_allow_deny_enable_disable, r=flip1995
bors [Wed, 4 Nov 2020 08:49:10 +0000 (08:49 +0000)]
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

3 years agoUpdate wording to avoid code having "lint" metaphor
Randall Mason [Tue, 3 Nov 2020 21:59:24 +0000 (15:59 -0600)]
Update wording to avoid code having "lint" metaphor

3 years agorustc_ast: `visit_mac` -> `visit_mac_call`
Vadim Petrochenkov [Tue, 3 Nov 2020 17:34:57 +0000 (20:34 +0300)]
rustc_ast: `visit_mac` -> `visit_mac_call`

3 years agorustc_ast: Do not panic by default when visiting macro calls
Vadim Petrochenkov [Tue, 3 Nov 2020 17:26:17 +0000 (20:26 +0300)]
rustc_ast: Do not panic by default when visiting macro calls

3 years agoAuto merge of #6233 - montrivo:manual_ok_or, r=flip1995
bors [Tue, 3 Nov 2020 16:42:59 +0000 (16:42 +0000)]
Auto merge of #6233 - montrivo:manual_ok_or, r=flip1995

add manual_ok_or lint

Implements partially #5923

changelog: add lint manual_ok_or

3 years agoAuto merge of #6165 - dvermd:ref_option_ref, r=flip1995
bors [Tue, 3 Nov 2020 16:21:51 +0000 (16:21 +0000)]
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

3 years agoAuto merge of #6101 - pitiK3U:from_iter_instead_of_collect, r=flip1995
bors [Tue, 3 Nov 2020 15:59:16 +0000 (15:59 +0000)]
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

3 years agoFix: Use `.collect()` instead of `::fromIterator()`
Piti the little Light [Sat, 24 Oct 2020 11:53:09 +0000 (13:53 +0200)]
Fix: Use `.collect()` instead of `::fromIterator()`

3 years agoFix: Don't show lint for types that doesn't implement Iterator
Piti the little Light [Mon, 12 Oct 2020 15:27:50 +0000 (17:27 +0200)]
Fix: Don't show lint for types that doesn't implement Iterator

3 years agoImprove error message
Piti the little Light [Thu, 1 Oct 2020 17:04:19 +0000 (19:04 +0200)]
Improve error message

3 years agoRemove backticks
Piti the little Light [Thu, 1 Oct 2020 16:44:12 +0000 (18:44 +0200)]
Remove backticks

3 years agoRun `cargo dev fmt`
Piti the little Light [Thu, 1 Oct 2020 16:36:49 +0000 (18:36 +0200)]
Run `cargo dev fmt`

3 years agoImprove: error message
Piti the little Light [Thu, 1 Oct 2020 16:34:36 +0000 (18:34 +0200)]
Improve: error message

3 years agoAllow lint
Piti the little Light [Thu, 1 Oct 2020 16:17:50 +0000 (18:17 +0200)]
Allow  lint

3 years agoImprovements from PR feedback
Piti the little Light [Thu, 1 Oct 2020 16:04:05 +0000 (18:04 +0200)]
Improvements from PR feedback

3 years agoUpdate: stderr message format
Piti the little Light [Thu, 1 Oct 2020 10:36:17 +0000 (12:36 +0200)]
Update: stderr message format

3 years agoFix `from_iter_instead_of_collect` lint crashing on exprs without path segment
Piti the little Light [Fri, 11 Sep 2020 11:29:52 +0000 (13:29 +0200)]
Fix `from_iter_instead_of_collect` lint crashing on exprs without path segment

3 years agoAdd tests for `from_iter_instead_of_collect`
Piti the little Light [Thu, 10 Sep 2020 18:18:23 +0000 (20:18 +0200)]
Add tests for `from_iter_instead_of_collect`

3 years agoRun `cargo dev update_lints`
Piti the little Light [Thu, 10 Sep 2020 18:16:28 +0000 (20:16 +0200)]
Run `cargo dev update_lints`

3 years agoAdd `from_iter_instead_of_collect` lint implementation
Piti the little Light [Thu, 10 Sep 2020 18:14:23 +0000 (20:14 +0200)]
Add `from_iter_instead_of_collect` lint implementation

3 years agoAuto merge of #6037 - matthiaskrgr:single_char_insert, r=flip1995
bors [Tue, 3 Nov 2020 15:36:33 +0000 (15:36 +0000)]
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

3 years agoInclude bindings as machine applicable
Cameron Steffen [Mon, 2 Nov 2020 18:55:05 +0000 (12:55 -0600)]
Include bindings as machine applicable

3 years agoChange lint to use const sym
Cameron Steffen [Mon, 2 Nov 2020 17:47:17 +0000 (11:47 -0600)]
Change lint to use const sym

3 years agoUse const rustc sym where possible
Cameron Steffen [Mon, 2 Nov 2020 16:32:55 +0000 (10:32 -0600)]
Use const rustc sym where possible

3 years agoFix incorrect suggestion when from expansion in `try_err` lint
ThibsG [Mon, 2 Nov 2020 16:59:47 +0000 (17:59 +0100)]
Fix incorrect suggestion when from expansion in `try_err` lint

3 years agoGive better suggestion by working on span on `deref_addrof` lint
ThibsG [Mon, 2 Nov 2020 16:56:54 +0000 (17:56 +0100)]
Give better suggestion by working on span on `deref_addrof` lint

3 years agoFix incorrect suggestion for macro expansion in `deref_addrof` lint
ThibsG [Sat, 31 Oct 2020 18:56:51 +0000 (19:56 +0100)]
Fix incorrect suggestion for macro expansion in `deref_addrof` lint

3 years agoAuto merge of #6282 - giraffate:sync-from-rust, r=ebroto
bors [Mon, 2 Nov 2020 07:36:35 +0000 (07:36 +0000)]
Auto merge of #6282 - giraffate:sync-from-rust, r=ebroto

Rustup

changelog: none

3 years agoProvide diagnostic suggestion in ExprUseVisitor Delegate
Dhruv Jauhar [Sun, 1 Nov 2020 07:15:22 +0000 (02:15 -0500)]
Provide diagnostic suggestion in ExprUseVisitor Delegate

The [Delegate
trait](https://github.com/rust-lang/rust/blob/981346fc07dd5ef414c5b1b21999f7604cece006/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
3 years agoMerge remote-tracking branch 'upstream/master' into sync-from-rust
Takayuki Nakata [Mon, 2 Nov 2020 01:34:49 +0000 (10:34 +0900)]
Merge remote-tracking branch 'upstream/master' into sync-from-rust

3 years agoAuto merge of #75534 - Aaron1011:feature/new-future-breakage, r=pnkfelix
bors [Sun, 1 Nov 2020 16:52:28 +0000 (16:52 +0000)]
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 :smile: ).

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`

3 years agoImplement field_reassign_with_default
Henri Lunnikivi [Thu, 31 Oct 2019 16:02:02 +0000 (18:02 +0200)]
Implement field_reassign_with_default

- Implement `field_reassign_with_default` as a `LateLintPass`
- Avoid triggering `default_trait_access` on a span already linted by
`field_reassigned_with_default`
- Merge `default_trait_access` and `field_reassign_with_default` into
`Default`
- Co-authored-by: Eduardo Broto <ebroto@tutanota.com>
- Fixes #568

3 years agoAuto merge of #6276 - dp304:patch-1, r=llogiq
bors [Sat, 31 Oct 2020 13:01:11 +0000 (13:01 +0000)]
Auto merge of #6276 - dp304:patch-1, r=llogiq

Fix typo in adding_lints.md

changelog: none

3 years agoFix typo in adding_lints.md
dp304 [Sat, 31 Oct 2020 02:11:03 +0000 (03:11 +0100)]
Fix typo in adding_lints.md

3 years agoAuto merge of #6277 - ebroto:rustup, r=ebroto
bors [Sat, 31 Oct 2020 08:52:32 +0000 (08:52 +0000)]
Auto merge of #6277 - ebroto:rustup, r=ebroto

Rustup

changelog: none

3 years agoFix formatting
Eduardo Broto [Sat, 31 Oct 2020 08:34:01 +0000 (09:34 +0100)]
Fix formatting

3 years agoMerge remote-tracking branch 'upstream/master' into rustup
Eduardo Broto [Sat, 31 Oct 2020 08:33:40 +0000 (09:33 +0100)]
Merge remote-tracking branch 'upstream/master' into rustup

3 years agoUpdate Clippy path to `Lint`
Aaron Hill [Sat, 31 Oct 2020 01:41:16 +0000 (21:41 -0400)]
Update Clippy path to `Lint`

3 years agoAddress suggestions in PR review
Eduardo Broto [Fri, 30 Oct 2020 22:47:22 +0000 (23:47 +0100)]
Address suggestions in PR review

3 years agoRename single_char_push_str to single_char_add_str
Eduardo Broto [Wed, 7 Oct 2020 22:03:26 +0000 (00:03 +0200)]
Rename single_char_push_str to single_char_add_str

3 years agoget_hint_if_single_char_arg: fix bug where multi-char letters are not detected properly
Matthias Krüger [Thu, 24 Sep 2020 14:36:29 +0000 (16:36 +0200)]
get_hint_if_single_char_arg: fix bug where multi-char letters are not detected properly