Commit graph

11843 commits

Author SHA1 Message Date
bors
404bd1a49a Auto merge of #7382 - matthiaskrgr:config_name, r=flip1995
Fix wrong config option being suggested for deprecated wrong_pub_self_convention lint

Problem:
for code like
````rust
#![warn(clippy::wrong_pub_self_convention)]
fn main() {
    println!("Hello, world!");
}
````
clippy will issue a warning to use a clippy.toml option instead:

````
warning: lint `clippy::wrong_pub_self_convention` has been removed: set the `avoid_breaking_exported_api` config option to `false` to enable the `wrong_self_convention` lint for public items
 --> src/main.rs:2:9
  |
2 | #![warn(clippy::wrong_pub_self_convention)]
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(renamed_and_removed_lints)]` on by default
````

But using the lint name as seen in the warning message
`echo "avoid_breaking_exported_api = true\n" > clippy.toml`

Will cause an error:
````
error: error reading Clippy's configuration file `/tmp/clippytest/clippy.toml`: unknown field `avoid_breaking_exported_api`, expected one of `avoid-breaking-exported-api`, ...
````

Replace the underscores with dashes in the deprecation message.

changelog: avoid_breaking_exported_api: suggest correct clippy config toml option in the deprecation message
2021-06-21 08:41:25 +00:00
bors
d3327bd837 Auto merge of #7380 - popzxc:compile-test-helper, r=flip1995
Improve panic message on "Found multiple rlibs" error in compile-test

Related to #7343

When I first met this error I was pretty much confused, so I thought it may be a good idea to:

- Give a hint on what to do to users that don't want to dig into specifics and just want to quickly resolve the issue.
- Give a link for those who are interested in details.

## Old appearance:

<img width="1121" alt="Screenshot 2021-06-20 at 08 30 34" src="https://user-images.githubusercontent.com/12111581/122663361-df8ae780-d1aa-11eb-9236-775b4fd754d5.png">

## New appearance:

<img width="1121" alt="Screenshot 2021-06-20 at 08 32 18" src="https://user-images.githubusercontent.com/12111581/122663363-e4e83200-d1aa-11eb-9c46-f62d83eb79e2.png">

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: none
2021-06-21 08:27:14 +00:00
Igor Aleksanov
310a204306 Provide different message for bootstrapped compiler 2021-06-21 06:57:57 +03:00
Matthias Krüger
8276f26a4d Fix wrong config option being suggested for deprecated wrong_pub_self_convention lint
Problem:
for code like
````
fn main() {
    println!("Hello, world!");
}
````
clippy will issue a warning to use a clippy.toml option instead:

````
warning: lint `clippy::wrong_pub_self_convention` has been removed: set the `avoid_breaking_exported_api` config option to `false` to enable the `wrong_self_convention` lint for public items
 --> src/main.rs:2:9
  |
2 | #![warn(clippy::wrong_pub_self_convention)]
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(renamed_and_removed_lints)]` on by default
````

But using the lint name as seen in the warning message
echo "avoid_breaking_exported_api = true\n" > clippy.toml

Will cause an error:
````
error: error reading Clippy's configuration file `/tmp/clippytest/clippy.toml`: unknown field `avoid_breaking_exported_api`, expected one of `avoid-breaking-exported-api`, ...
````

Replace the underscores with dashes in the deprecation message.

changelog: avoid_breaking_exported_api: suggest correct clippy config toml option in the deprecation message
2021-06-20 15:54:41 +02:00
Igor Aleksanov
faa2fa7490 Improve appearance 2021-06-20 08:32:43 +03:00
Igor Aleksanov
d4c9fe7549 Improve visibility&helpfulness of the 'found multiple rlibs' error 2021-06-20 08:25:30 +03:00
bors
3120b09151 Auto merge of #7299 - DevinR528:macro-brace, r=llogiq
Add macro_braces lint to check for irregular brace use in certain macros

The name is a bit long but this sounds good as `#[allow(unconventional_macro_braces)]` and it seems more clear that we are talking about the macro call not macro definitions, any feedback let me know. Thanks!
fixes #7278

changelog: Add ``[`unconventional_macro_braces`]`` lint that checks for uncommon brace usage with macros.
2021-06-19 17:56:56 +00:00
bors
7869e62557 Auto merge of #7375 - djc:from-iter-pedantic, r=Manishearth
Move from-iter-instead-of-collect to pedantic

Since FromIterator will become part of the prelude, this lint being
warn by default is incongruous with the libs team position on the topic.

Fixes #7213.

---

changelog: moved [`from_iter_instead_of_collect`] to `pedantic` group
2021-06-19 08:01:58 +00:00
Dirkjan Ochtman
a40fd6da7e Move from-iter-instead-of-collect to pedantic
Since FromIterator will become part of the prelude, this lint being
warn by default is incongruous with the libs team position on the topic.
2021-06-18 22:23:25 +02:00
bors
d184413833 Auto merge of #7371 - flip1995:changelog, r=flip1995
Fix link in changelog

r? `@ghost`

changelog: none
2021-06-17 19:09:12 +00:00
flip1995
40fee52e49
Fix link in changelog 2021-06-17 21:06:50 +02:00
bors
6bf8772702 Auto merge of #7366 - flip1995:changelog, r=Manishearth
Update changelog

[Rendered](https://github.com/flip1995/rust-clippy/blob/changelog/CHANGELOG.md)

Way fewer new lints than usual. Also now "Documentation" or "Others" updates this time.

changelog: none
2021-06-17 17:38:25 +00:00
bors
d4f908ac2e Auto merge of #7367 - flip1995:backport_remerge, r=flip1995
Remerge Beta backport changes

We do this to keep the Clippy commits that are in rust-lang/rust also in Clippy.

r? `@ghost`

changelog: none
2021-06-17 16:07:48 +00:00
flip1995
485747ead1
Merge remote-tracking branch 'upstream/beta' into backport_remerge 2021-06-17 18:04:58 +02:00
flip1995
218a609f3c
Update changelog 2021-06-17 17:59:08 +02:00
Devin Ragotzy
723f515b60 Add macro_braces lint to check for irregular brace use in certain macros
Rename unconventional -> nonstandard, add config field

Add standard_macro_braces fields so users can specify macro names and
brace combinations to lint for in the clippy.toml file.

Fix errors caused by nonstandard_macro_braces in other lint tests

Fix users ability to override the default nonstandard macro braces

Add type position macros impl `check_ty`
2021-06-17 07:02:36 -04:00
bors
f49f1b1574 Auto merge of #7364 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2021-06-17 08:25:26 +00:00
flip1995
8302eefacd
Bump Clippy version -> 0.1.55 2021-06-17 10:23:08 +02:00
flip1995
a8fd708be7
Bump nightly version -> 2021-06-17 2021-06-17 10:22:31 +02:00
flip1995
e3eede7b90
Merge remote-tracking branch 'upstream/master' into rustup 2021-06-17 10:21:47 +02:00
bors
7c9da3c1e4 Auto merge of #7352 - camsteffen:metadata-syntax, r=xFrednet
Fix metadata code block syntax highlighting

changelog: none

Fixes code fence block in the metadata collector to change ` ``` ` or ` ```ignore` or ` ```rust,ignore` to ` ```rust`. This makes syntax highlighting work more consistently on the website.
2021-06-15 21:44:00 +00:00
Cameron Steffen
a557f37bb4 Improve metadata code block parsing 2021-06-15 16:39:52 -05:00
bors
1ee99d9bf5 Auto merge of #7355 - Pyther99:common-tools-link, r=camsteffen
Fix link in docs

The [docs](https://github.com/rust-lang/rust-clippy/blob/master/doc/common_tools_writing_lints.md) had an incorrect link for "Checking if a type defines a specific method".

changelog: none
2021-06-15 15:44:40 +00:00
Pyther99
fd0ea64990 Fix link 2021-06-15 17:38:16 +02:00
bors
2d1e9ab980 Auto merge of #7345 - DevinR528:disallowed-fix, r=Manishearth
Remove requirement of fully qualified path for disallowed_method/type

changelog: Remove the need for fully qualified paths in disallowed_method and disallowed_type

After fixing this issue in [import_rename](https://github.com/rust-lang/rust-clippy/pull/7300#discussion_r650127720) I figured I'd fix it for these two.

If this does in fact fix the **Known problems:** section I was planning to remove them from both lints after confirmation.
2021-06-14 14:57:56 +00:00
bors
a36a7c808c Auto merge of #7270 - Valentine-Mario:vec_extend_to_append, r=flip1995
Vec extend to append

This PR adds a check to suggest changes of vector from

```
vec.extend(other_vec.drain(..))
```

could be written as

```
vec![].append(&mut vec![]);
```

changelog: Add vec_extend_to_append lint
issue: #7209
2021-06-14 06:58:12 +00:00
bors
6379d260e7 Auto merge of #7288 - camsteffen:use-self2, r=phansch
Fix use_self FPs on type params

changelog: Fix [`use_self`] false positives on type parameters

Fixes #4140
Fixes #7139
2021-06-14 05:49:29 +00:00
Devin Ragotzy
d4eff81282 fixup! Remove requirement of fully qualified path for disallowed_method/type 2021-06-13 15:52:54 -04:00
Devin Ragotzy
70ce0c2c55 Remove requirement of fully qualified path for disallowed_method/type 2021-06-11 17:25:32 -04:00
bors
f1f5ccd63a Auto merge of #7160 - flip1995:field_reassign_macros, r=xFrednet,camsteffen
Don't trigger `field_reassign_with_default` in macros

Fixes #7155

Producing a good suggestion for this lint is already hard when no macros
are involved. With macros the lint message and the suggestion are just
confusing. Since both, producing a good suggestion and figuring out if
this pattern can be re-written inside a macro is nearly impossible, just
bail out.

changelog: [`field_reassign_with_default`] No longer triggers in macros

---

No that our reviewing queue is under control, I want to start hacking on Clippy myself again. Starting with an easy issue to get back in :)
2021-06-11 15:58:58 +00:00
Ryan Levick
611b74e1fe Add support for using qualified paths with structs in expression and pattern
position.
2021-06-10 13:18:41 +02:00
valentine-mario
44608b1857 added lint to check for full range of vector and suggest append 2021-06-10 09:12:06 +01:00
bors
f7d09b45e9 Auto merge of #7333 - camsteffen:match-var, r=llogiq
Factor out match_var and get_pat_name utils

...because checking vars by name is bad, because of shadowing.

changelog: none
2021-06-10 05:20:56 +00:00
bors
ce7b872341 Auto merge of #7332 - lengyijun:redundant_clone_fix, r=giraffate
redundant_clone: fix comment

changelog: none
2021-06-10 00:54:25 +00:00
bors
c4636abe72 Auto merge of #7315 - DevinR528:disallowed-ty, r=giraffate
Add disallowed_type lint, this adds a field to the conf struct

Fixes #7277

changelog: Add ``[`disallowed_type`]`` a lint that can enforce banning types specified in the config.
2021-06-10 00:30:36 +00:00
bors
626dc5945b Auto merge of #86003 - pnkfelix:issue-84297-revert-81238, r=Mark-Simulacrum
Make copy/copy_nonoverlapping fn's again

Make copy/copy_nonoverlapping fn's again, rather than intrinsics.

This a short-term change to address issue #84297.

It effectively reverts PRs #81167 #81238 (and part of #82967), #83091, and parts of #79684.
2021-06-09 16:47:05 +00:00
bors
2464ee9284 Auto merge of #7334 - Thomasdezeeuw:freebsd-no-ticks, r=flip1995
Add FreeBSD as identifier not needing ticks

For the doc-markdown lint.

changelog: Add FreeBSD as identifier not needing ticks for ``[`doc-markdown`]`` lint.
2021-06-09 15:30:28 +00:00
Thomas de Zeeuw
0d3f289b66 Add FreeBSD as identifier not needing ticks
For the doc-markdown lint.
2021-06-09 17:16:10 +02:00
Cameron Steffen
b792bb301c Factor out match_var 2021-06-09 09:47:42 -05:00
Devin Ragotzy
ea45e2a9cf Add disallowed_types lint, this adds a field to the Conf struct
Replace use of node_type -> node_type_opt, fix clippy warnings

Don't walk the hir unnecessarily let the visitor do it
2021-06-09 07:21:16 -04:00
bors
dd0246813f Auto merge of #7326 - 1c3t3a:1c3t3a-issue-7324, r=flip1995
Fix false positive on `semicolon_if_nothing_returned`

Currently the [`semicolon_if_nothing_returned`](https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned) lint fires in unwanted situations where a block only spans one line. An example of this was given in #7324. This code:

```rust
use std::mem::MaybeUninit;
use std::ptr;

fn main() {
    let mut s = MaybeUninit::<String>::uninit();
    let _d = || unsafe { ptr::drop_in_place(s.as_mut_ptr()) };
}
```

yields the following clippy error:
```
error: consider adding a `;` to the last statement for consistent formatting
 --> src/main.rs:6:26
  |
6 |     let _d = || unsafe { ptr::drop_in_place(s.as_mut_ptr()) };
  |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add a `;` here: `ptr::drop_in_place(s.as_mut_ptr());`
  |
  = note: `-D clippy::semicolon-if-nothing-returned` implied by `-D clippy::pedantic`
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned
```

I updated the lint to check if the statement is inside an `unsafe` block, a closure or a normal block and if the block only spans one line, in that case the lint is not emitted.

This closes #7324.

changelog: enhanced semicolon if nothing returned according to  #7324.
2021-06-09 08:39:56 +00:00
bors
da0538eaca Auto merge of #7330 - xFrednet:0000-refactor-map-identity, r=flip1995
Refactoring identity function lints

I've noticed that we have several lints that all check for identity functions and each used their own check implementation. I moved the `is_expr_identity_function` function to `clippy_utils` and adapted all lints to reuse that one function. This should make the addition of new lints like this also easier in the future.

I've also moved the `map_identity` lint into the `methods` module. It's probably the best to review this PR by checking each commit individually. And that's it, have a great day 🙃

changelog: none
2021-06-09 08:27:05 +00:00
Bastian Kersting
5ec80f32c7 Refactored multiline check 2021-06-09 09:43:25 +02:00
lyj
fe549f711a redundant_clone: fix comment 2021-06-09 15:25:48 +08:00
xFrednet
5336f88403 Move map_identity into the methods module 2021-06-08 19:56:59 +02:00
bors
07217e3370 Auto merge of #7262 - Jarcho:while_let_on_iter_closure, r=xFrednet,flip1995
fix `while_let_on_iterator` suggestion in a closure

fixes: #7249

A future improvement would be to check if the closure is being used as `FnOnce`, in which case the original suggestion would be correct.

changelog: Suggest `&mut iter` inside a closure for `while_let_on_iterator`
2021-06-08 15:52:40 +00:00
bors
c1577ab962 Auto merge of #7325 - Y-Nak:numeric-fallback, r=giraffate
Fix FP in `default_numeric_fallback` with external macro expansion

fixes #7304

changelog: Fix `default_numeric_fallback` FP with external macro expansion
2021-06-08 01:05:17 +00:00
xFrednet
9e54ce865c Reuse is_expr_identity_function for filter_map_identity 2021-06-07 23:31:17 +02:00
xFrednet
bb3b58cfcc Reuse is_expr_identity_function for flat_map_identity 2021-06-07 23:20:11 +02:00
xFrednet
967d815a42 Extracting is_expr_identity_function into clippy_utils for reusability 2021-06-07 22:42:11 +02:00