Commit graph

4635 commits

Author SHA1 Message Date
bors
4acbff9eb0 Auto merge of #7437 - ebobrow:redundant-closure-move, r=flip1995
suggest `&mut` for redundant FnMut closures

fixes #6903

changelog: suggest `&mut` for redundant FnMut closures
2021-07-14 15:15:28 +00:00
Elliot Bobrow
4c398e07e0 suggest &mut for redundant FnMut closures 2021-07-14 07:56:27 -07:00
lyj
251c3b64da fix 5707 2021-07-14 10:57:47 +08:00
bors
8131445e53 Auto merge of #7446 - Y-Nak:fix-7445, r=xFrednet,flip1995
`default_numeric_fallback`: Fix FP with floating literal

Fix #7445

changelog: `default_numeric_fallback`: Fix FP with floating literal
2021-07-13 14:31:02 +00:00
Yoshitomo Nakanishi
25e4c7d73f default_numeric_fallback: Add rustfix tests 2021-07-13 23:18:31 +09:00
Cameron Steffen
306f9e843d Split a lint message into help 2021-07-13 08:57:16 -05:00
Cameron Steffen
20dbb277cf Fix useless_format false positive 2021-07-13 08:57:16 -05:00
Yoshitomo Nakanishi
04aa3f7e9b default_numeric_fallback: Add more tests for floating literal 2021-07-09 18:24:23 +09:00
Yoshitomo Nakanishi
3bc5abef62 default_numeric_fallback: Fix FP with floating literal 2021-07-08 11:37:12 +09:00
iobtl
eeefbb7617 fix false positive (panic message) with assert macro using message parameter 2021-07-06 15:14:53 +08:00
Mateusz Gacek
59a164e86c Add new lint: strlen_on_c_strings 2021-07-05 11:10:45 +02:00
bors
3cc6778512 Auto merge of #7431 - DevinR528:fix-macro-brace, r=llogiq
Fix emitting in nested (proc_)macros for nonstandard_macro_braces lint

fixes #7422

changelog: fixes false positives in [`nonstandard_macro_braces`]
2021-07-04 16:47:11 +00:00
Devin Ragotzy
1d110f8c2e Fix emitting in nested (proc_)macros for nonstandard_macro_braces lint 2021-07-04 07:06:23 -04:00
Cameron Steffen
cb4670deb3 Fix use_self ICE 2021-07-03 12:40:50 -05:00
bors
c195db7fee Auto merge of #7426 - ebobrow:doc-markdown-fp, r=llogiq
fix doc_markdown false positive

fixes #7421

changelog: don't lint unbalanced tick marks in code blocks
2021-07-03 16:53:21 +00:00
Elliot Bobrow
e9a5694597 fix doc_markdown false positive 2021-07-03 09:34:10 -07:00
bors
84209994ad Auto merge of #7316 - lengyijun:rc_mutex, r=llogiq
Add new lint: `rc_mutex`

changelog: Add new lint `rc_mutex`.

It lints on `Rc<Mutex<T>>`.

`Rc<Mutex<T>>` should be corrected to `Rc<RefCell<T>>`
2021-07-03 10:26:03 +00:00
David Tolnay
0f662e5833
Downgrade nonstandard_macro_braces to nursery 2021-07-02 22:16:04 -07:00
flip1995
a82a744155
Merge remote-tracking branch 'upstream/master' into rustup 2021-07-01 17:41:24 +02:00
bors
753bce30f0 Auto merge of #7407 - m-ou-se:doc-hidden-variants, r=flip1995
Don't suggest doc(hidden) or unstable variants in wildcard lint

Clippy's wildcard lint would suggest doc(hidden) and unstable variants for non_exhaustive enums, even though those aren't part of the public interface (yet) and should only be matched on using a `_`, just like potential future additions to the enum. There was already some logic to exclude a *single* doc(hidden) variant. This extends that to all hidden variants, and also hides `#[unstable]` variants.

See https://github.com/rust-lang/rust/pull/85746#issuecomment-868886893

This PR includes https://github.com/rust-lang/rust-clippy/pull/7406 as the first commit.

Here's the diff that this PR adds on top of that PR: https://github.com/m-ou-se/rust-clippy/compare/std-errorkind...m-ou-se:doc-hidden-variants

---

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

changelog: No longer suggest unstable and doc(hidden) variants in wildcard lint. wildcard_enum_match_arm, match_wildcard_for_single_variants
2021-07-01 15:02:21 +00:00
flip1995
fae7a09eea
match_wildcard_for_single_variants: don't produce bad suggestion
This fixes a bug where match_wildcard_for_single_variants produced a
bad suggestion where besides the missing variant, one or more hidden
variants were left.

This also adds tests to the ui-tests match_wildcard_for_single_variants
and wildcard_enum_match_arm to make sure that the correct suggestion is
produced.
2021-07-01 12:38:30 +02:00
flip1995
0ffba7a684
Simplify wildcard_enum_match_arm test 2021-07-01 11:47:56 +02:00
bors
cadb93b6de Auto merge of #7400 - popzxc:restrict-locales, r=Manishearth
New lint: `disallowed_script_idents`

This PR implements a new lint to restrict locales that can be used in the code,
as proposed in #7376.

Current concerns / unresolved questions:

- ~~Mixed usage of `script` (as a Unicode term) and `locale` (as something that is easier to understand for the broad audience). I'm not sure whether these terms are fully interchangeable and whether in the current form it is more confusing than helpful.~~ `script` is now used everywhere.
- ~~Having to mostly copy-paste `AllowedScript`. Probably it's not a big problem, as the list of scripts is standardized and is unlikely to change, and even if we'd stick to the `unicode_script::Script`, we'll still have to implement custom deserialization, and I don't think that it will be shorter in terms of the amount of LoC.~~ `unicode::Script` is used together with a filtering deserialize function.
- Should we stick to the list of "recommended scripts" from [UAX #31](http://www.unicode.org/reports/tr31/#Table_Recommended_Scripts) in the configuration?

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

changelog: ``[`disallowed_script_idents`]``

r? `@Manishearth`
2021-06-30 18:14:16 +00:00
Igor Aleksanov
018be41dee Implement 'disallowed_script_idents' lint 2021-06-30 19:06:33 +03:00
bors
3525a6b61a Auto merge of #7390 - popzxc:issue-7331, r=flip1995
Improve lint message for match-same-arms lint

fixes #7331

Follow-up to #7377

This PR improves the lint message for `match-same-arms` lint and adds `todo!(..)`  example to the lint docs.

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

changelog: None
2021-06-30 15:12:55 +00:00
Mara Bos
38569c03eb Don't suggest unstable and doc(hidden) variants. 2021-06-26 15:28:38 +02:00
Mara Bos
3e59563394 Don't use exact definition of std's ErrorKind in test.
Every time we add something to this enum in std, this test breaks.
2021-06-26 14:50:42 +02:00
Cameron Steffen
f02632cee6 Move some lints to suspicious 2021-06-25 08:53:29 -05:00
Ryan Levick
abc9a46868 Fix clippy test 2021-06-25 15:29:14 +02:00
bors
8d427b624f Auto merge of #7379 - popzxc:issue-7305, r=flip1995
Do not spawn blacklisted_name lint in test context

---

fixed #7305

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

changelog: `blacklisted_name` lint is not spawned in the test context anymore.
2021-06-25 10:12:05 +00:00
Igor Aleksanov
28d3873ef5 Do not spawn blacklisted_name lint in test context
Fix detecting of the 'test' attribute

Update UI test to actually check that warning is not triggered in the test code

Fix approach for detecting the test module

Add nested test case

Remove code duplication by extracting 'is_test_module_or_function' into 'clippy_utils'

Cleanup the code
2021-06-25 12:36:22 +03:00
Igor Aleksanov
39856b17ec Improve lint message for match-same-arms lint
Simplify error message producing & remove extra example
2021-06-25 12:33:35 +03:00
bors
b286b38a29 Auto merge of #7300 - DevinR528:import-rename, r=camsteffen
Add import_rename lint, this adds a field on the Conf struct

fixes #7276

changelog: Add ``[`import_rename`]`` a lint that enforces import renaming defined in the config file.
2021-06-24 20:23:13 +00:00
Devin Ragotzy
9492de5843 Add import_rename lint, this adds a field on the Conf struct
Rename lint and fix review issues
2021-06-24 16:13:02 -04:00
Joe Ranweiler
642239c857 Update var name in test 2021-06-22 19:02:34 -07:00
Joe Ranweiler
d2087ad00d Remove bad cast in test, cover more cases 2021-06-22 18:45:03 -07:00
bors
48fa1dc8bb Auto merge of #7357 - ebobrow:unbalanced-tick, r=xFrednet,flip1995
check for unbalanced tick pairs in doc-markdown lint

fixes #6753

changelog: check for unbalanced tick pairs in doc-markdown lint
2021-06-21 17:15:12 +00:00
Elliot Bobrow
20cb1bc7c1 check for unbalanced tick pairs in doc-markdown 2021-06-21 08:52:09 -07:00
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
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
hi-rustin
e1cc628af4 Address comment 2021-06-18 16:20:30 +08:00
hi-rustin
6e8549e05e Make clippy tests happy 2021-06-18 16:11:32 +08: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
flip1995
e3eede7b90
Merge remote-tracking branch 'upstream/master' into rustup 2021-06-17 10:21:47 +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