Commit graph

9975 commits

Author SHA1 Message Date
bors
ad4f82997a Auto merge of #6119 - rsulli55:find_is_some_on_strs, r=flip1995
Add a case to `lint_search_is_some` to handle searching strings

Fixes: #6010

This adds a lint which recommends using `contains()` instead of `find()` followed by `is_some()` on strings as suggested in #6010.

This was added as an additional case to
5af88e3c2d/clippy_lints/src/methods/mod.rs (L3037)

I would really appreciate any comments/suggestions for my code!

changelog: Added case to `lint_search_is_some` to handle searching strings
2020-11-16 08:45:10 +00:00
bors
df3bb5881d Auto merge of #6336 - giraffate:sync-from-rust, r=flip1995
Rustup

changelog: none
2020-11-16 08:23:27 +00:00
Takayuki Nakata
0e803417f9 Add rustfmt::skip as a work around
because comments are checked and removed by rustfmt for some reason
2020-11-16 12:32:16 +09:00
bors
db0464103e Auto merge of #6334 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2020-11-15 13:09:53 +00:00
Jonas Schievink
27a15721c5 Rollup merge of #79016 - fanzier:underscore-expressions, r=petrochenkov
Make `_` an expression, to discard values in destructuring assignments

This is the third and final step towards implementing destructuring assignment (RFC: rust-lang/rfcs#2909, tracking issue: #71126). This PR is the third and final part of #71156, which was split up to allow for easier review.

With this PR, an underscore `_` is parsed as an expression but is allowed *only* on the left-hand side of a destructuring assignment. There it simply discards a value, similarly to the wildcard `_` in patterns. For instance,
```rust
(a, _) = (1, 2)
```
will simply assign 1 to `a` and discard the 2. Note that for consistency,
```
_ = foo
```
is also allowed and equivalent to just `foo`.

Thanks to ````@varkor```` who helped with the implementation, particularly around pre-expansion gating.

r? ````@petrochenkov````
2020-11-15 13:39:48 +01:00
bors
0c7a48c5f0 Auto merge of #78809 - vn-ki:fix-issue-76064, r=oli-obk
add error_occured field to ConstQualifs,

fix #76064

I wasn't sure what `in_return_place` actually did and not sure why it returns `ConstQualifs` while it's sibling functions return `bool`. So I tried to make as minimal changes to the structure as possible. Please point out whether I have to refactor it or not.

r? `@oli-obk`
cc `@RalfJung`
2020-11-14 18:03:17 +00:00
Fabian Zaiser
864e554b9a Add underscore expressions for destructuring assignments
Co-authored-by: varkor <github@varkor.com>
2020-11-14 13:53:12 +00:00
bors
408b615d34 Auto merge of #6320 - giraffate:fix_suggestion_in_manual_range_contains_using_float, r=llogiq
Fix suggestion in `manual_range_contains` when using float

Fix #6315

changelog: Fix suggestion in `manual_range_contains` when using float
2020-11-14 08:06:00 +00:00
Vishnunarayan K I
7987f39ad5 update clippy test ouput 2020-11-13 17:11:13 +05:30
bors
cf7b4b0fe6 Auto merge of #6329 - giraffate:sync-from-rust, r=matthiaskrgr
Rustup

changelog: none
2020-11-13 10:49:21 +00:00
Takayuki Nakata
c6b74df680 Fix dogfood test 2020-11-13 14:47:23 +09:00
Mara Bos
3a648ffc02 Rollup merge of #78836 - fanzier:struct-and-slice-destructuring, r=petrochenkov
Implement destructuring assignment for structs and slices

This is the second step towards implementing destructuring assignment (RFC: rust-lang/rfcs#2909, tracking issue: #71126). This PR is the second part of #71156, which was split up to allow for easier review.

Note that the first PR (#78748) is not merged yet, so it is included as the first commit in this one. I thought this would allow the review to start earlier because I have some time this weekend to respond to reviews. If ``@petrochenkov`` prefers to wait until the first PR is merged, I totally understand, of course.

This PR implements destructuring assignment for (tuple) structs and slices. In order to do this, the following *parser change* was necessary: struct expressions are not required to have a base expression, i.e. `Struct { a: 1, .. }` becomes legal (in order to act like a struct pattern).

Unfortunately, this PR slightly regresses the diagnostics implemented in #77283. However, it is only a missing help message in `src/test/ui/issues/issue-77218.rs`. Other instances of this diagnostic are not affected. Since I don't exactly understand how this help message works and how to fix it yet, I was hoping it's OK to regress this temporarily and fix it in a follow-up PR.

Thanks to ``@varkor`` who helped with the implementation, particularly around the struct rest changes.

r? ``@petrochenkov``
2020-11-12 19:46:09 +01:00
bors
bd13a35856 Auto merge of #6325 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2020-11-12 07:40:33 +00:00
bors
92ece84873 Auto merge of #78782 - petrochenkov:nodoctok, r=Aaron1011
Do not collect tokens for doc comments

Doc comment is a single token and AST has all the information to re-create it precisely.
Doc comments are also responsible for majority of calls to `collect_tokens` (with `num_calls == 1` and `num_calls == 0`, cc https://github.com/rust-lang/rust/pull/78736).

(I also moved token collection into `fn parse_attribute` to deduplicate code a bit.)

r? `@Aaron1011`
2020-11-12 00:33:55 +00:00
Takayuki Nakata
5f64867e1d Fix suggestion in manual_range_contains when using float 2020-11-11 22:44:48 +09:00
Fabian Zaiser
5f310d9b83 Implement destructuring assignment for structs and slices
Co-authored-by: varkor <github@varkor.com>
2020-11-11 12:10:52 +00:00
Ikko Ashimine
f92f8d095d Fix typo in comment
occurences -> occurrences
2020-11-11 20:23:08 +09:00
Ryan Sullivant
5c1c50ee17 Change variable named foo and rerun update-all-references 2020-11-10 23:48:01 -07:00
rsulli55
56d252c53d Update clippy_lints/src/methods/mod.rs
Co-authored-by: Philipp Krones <hello@philkrones.com>
2020-11-10 23:18:48 -07:00
Ryan Sullivant
fd303132a2 Cleaned up message and suggestion for lint_search_is_some 2020-11-10 23:18:48 -07:00
Ryan Sullivant
ee1b959054 Added period back to lint search_is_some and ran
`update-all-references.sh`
2020-11-10 23:18:47 -07:00
rsulli55
fb74b4802e Remove borrow
Co-authored-by: Philipp Krones <hello@philkrones.com>
2020-11-10 23:18:47 -07:00
rsulli55
e9612f3eca Remove to_string on msg
Co-authored-by: Philipp Krones <hello@philkrones.com>
2020-11-10 23:18:47 -07:00
Ryan Sullivant
55dc822062 Ran tests/ui/update-all-references.sh" and cargo dev fmt` 2020-11-10 23:18:47 -07:00
Ryan Sullivant
431fcbcc00 Moved the tests for lint search_is_some to new files
`search_is_some.rs` and `search_is_some_fixable.rs`
2020-11-10 23:18:47 -07:00
Ryan Sullivant
a1cf2d334d 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>
2020-11-10 23:18:47 -07:00
bors
c4fc076e11 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
2020-11-11 00:48:33 +00:00
Cameron Steffen
769094410a Fix map_clone with deref and clone 2020-11-10 18:37:17 -06:00
bors
d0858d0f36 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
2020-11-10 22:39:10 +00:00
bors
467bf95ab7 Auto merge of #6319 - ebroto:rustup, r=ebroto
Rustup

changelog: none

r? `@ghost`
2020-11-10 21:36:00 +00:00
Eduardo Broto
effcb52bbf Run cargo dev fmt 2020-11-10 22:33:02 +01:00
Eduardo Broto
3ea6f77446 Merge remote-tracking branch 'upstream/master' into rustup 2020-11-10 22:32:24 +01:00
bors
dd826b4626 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`]
2020-11-09 19:13:26 +00:00
Dylan DPC
6294300b8e 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.
2020-11-09 19:06:55 +01:00
Samuel E. Moelius III
4852cca61b Allow let_underscore_drop in filter_methods test 2020-11-09 07:49:14 -05:00
bors
d212c382c3 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`
2020-11-09 05:25:04 +00:00
Samuel E. Moelius III
06e81bb493 Update references 2020-11-08 18:32:12 -05:00
Vadim Petrochenkov
8845f10e94 Do not collect tokens for doc comments 2020-11-09 01:47:11 +03:00
Samuel E. Moelius III
40d7af50ed Update lints 2020-11-08 17:33:54 -05:00
Samuel E. Moelius
8211b597ba
Update clippy_lints/src/let_underscore.rs
Co-authored-by: Philipp Krones <hello@philkrones.com>
2020-11-08 17:25:50 -05:00
Samuel E. Moelius
9751cba2c6
Update clippy_lints/src/let_underscore.rs
Co-authored-by: Philipp Krones <hello@philkrones.com>
2020-11-08 17:25:23 -05:00
Samuel E. Moelius
aa6bf1f90d
Update clippy_lints/src/let_underscore.rs
Co-authored-by: Philipp Krones <hello@philkrones.com>
2020-11-08 17:24:55 -05:00
bors
2067a01ff1 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
2020-11-08 22:03:27 +00:00
Cameron Steffen
9cab08465b Fix or_fun_call for index operator 2020-11-08 14:49:42 -06:00
Cameron Steffen
b0994064b0 Make KNOW_TYPES static 2020-11-08 14:34:06 -06:00
bors
040d0ca4da Auto merge of #6288 - flip1995:changelog_internal, r=matthiaskrgr
Require the `changelog:` entry in the PR body to be modified

r? `@matthiaskrgr`

changelog: none
2020-11-08 19:37:25 +00:00
flip1995
7c612c1c50
Force contributors/reviewers to set _some_ changelog entry 2020-11-08 16:18:25 +01:00
bors
7079de9b35 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`
2020-11-08 14:24:58 +00:00
Samuel E. Moelius III
9c6a0b9c34 Update references 2020-11-08 07:07:49 -05:00
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