Commit graph

11886 commits

Author SHA1 Message Date
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
bors
fbd77ef5d3 Auto merge of #7411 - camsteffen:use-self-visitor, r=flip1995
Simplify use_self impl

changelog: none

Mainly to remove an extra visit and simplify the "in body?" logic.
2021-06-29 13:23:04 +00:00
Cameron Steffen
bae76f9c17 Remove a visitor from use_self 2021-06-29 08:17:23 -05:00
Cameron Steffen
6e801e251f Use type_of for impl self type 2021-06-29 08:15:45 -05:00
Cameron Steffen
4913d82175 Simplify in impl check 2021-06-29 08:14:21 -05:00
Cameron Steffen
8827e96303 Make ItemKind check dry 2021-06-29 08:14:21 -05:00
bors
95c2ab75db Auto merge of #7405 - jyn514:fix-stable, r=camsteffen
Stabilize `cargo clippy --fix`

This has been unstable since it was first introduced in
https://github.com/rust-lang/rust-clippy/pull/5363. In that time, I have
been using it successfully in nightly without issues. I don't think
there are any blocking issues now that RUSTC_WORKSPACE_WRAPPER is
stabilized, so this can be stabilized.

changelog: Stabilize `cargo clippy --fix`
2021-06-29 13:03:45 +00:00
bors
f4bc9cf390 Auto merge of #7409 - xFrednet:5394-vs-code-tasks, r=giraffate,flip1995
Added `cargo dev setup vscode-tasks` for simplicity

This PR adds a setup command to `clippy dev` that installs tasks into the Clippy vscode workspace. These might be useful as they be used via shortcuts and are accessible over the GUI. The available tasks are:
* `cargo check` (standard Linux shortcut `[ctrl] + [shift] + b`)
* `cargo dev fmt`
* `cargo uitest` (with a comment how to add the `TESTNAME` environment value)
* `cargo test`
* `cargo dev bless`

---

changelog: none

only internal changes again. cc #5394

r? `@flip1995` This should be pretty much the same as the other `cargo dev setup` commands. Would you mind reviewing this? 🙃
2021-06-29 08:53:59 +00:00
Joshua Nelson
aa40487a84 Stabilize cargo clippy --fix
This has been unstable since it was first introduced in
https://github.com/rust-lang/rust-clippy/pull/5363. In that time, I have
been using it successfully in nightly without issues. I don't think
there are any blocking issues now that RUSTC_WORKSPACE_WRAPPER is
stabilized, so this can be stabilized.
2021-06-28 21:46:57 -04:00
xFrednet
e40019134b Updated clippy_dev ui message and vscode task name
Co-authored-by: Takayuki Nakata <f.seasons017@gmail.com>
2021-06-28 20:40:09 +02:00
bors
e405c68b3c Auto merge of #7350 - camsteffen:suspicious, r=flip1995
Add suspicious group

changelog: Introduce `clippy::suspicious` 🤔 group and move several lints into the group

Closes #6366. CC #6626.

A number of lints are moved from each of `correctness`, `style` and `complexity` groups. Notably I didn't move `suspicious_splitn` since I think that is a `correctness` lint despite the name.

Lints moved to `clippy::suspicious`:
* `blanket_clippy_restriction_lints` (was `clippy::style`)
* `empty_loop` (was `clippy::style`)
* `eval_order_dependence` (was `clippy::complexity`)
* `float_equality_without_abs` (was `clippy::correctness`)
* `for_loops_over_fallibles` (was `clippy::correctness`)
* `misrefactored_assign_op` (was `clippy::complexity`)
* `mut_range_bound` (was `clippy::complexity`)
* `mutable_key_type` (was `clippy::correctness`)
* `suspicious_arithmetic_impl` (was `clippy::correctness`)
* `suspicious_assignment_formatting` (was `clippy::style`)
* `suspicious_else_formatting` (was `clippy::style`)
* `suspicious_map` (was `clippy::complexity`)
* `suspicious_op_assign_impl` (was `clippy::correctness`)
* `suspicious_unary_op_formatting` (was `clippy::style`)
2021-06-28 08:35:51 +00:00
xFrednet
2098b27a20 Added cargo dev setup vscode-tasks for simplicity 2021-06-27 22:36:41 +02:00
Cameron Steffen
5b5f0ea606 Add remark-gfm to workflow job 2021-06-25 10:30:37 -05:00
Cameron Steffen
f02632cee6 Move some lints to suspicious 2021-06-25 08:53:29 -05:00
Cameron Steffen
7e21db5b5c Add suspicious group 2021-06-25 08:53:29 -05: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
a03dfb9eac Auto merge of #7361 - xFrednet:5394-expand-setup-command, r=flip1995
Added `cargo dev setup git-hook` and updated `cargo dev setup intellij` including a `remove` command

This PR enables our dev tool to install a git hook that formats the code before each commit and also runs `update_lints` to make sure that everything is registered correctly. The script is located at `util/etc/pre-commit.sh`. I found it reasonable to locate it in the `util` folder and decided to add a `etc` in correlation to the main rust repo and to bring a bit of structure into it.

* The hook can be installed via: `cargo dev setup git-hook`
* And removed via: `cargo dev remove git-hook`

cc: #5394

The refactoring of `src/ide_setup.rs` to `src/setup/intellij.rs` is an extra commit to simplify the review.

---

Changes:
* Added `cargo dev setup git-hook` for formatting before every commit
* Added `cargo dev remove git-hook` to remove the hook again
* Added `cargo dev remove intellij` to remove rustc source path dependencies
* Changed `cargo dev ide_setup` to `cargo dev setup intellij`

changelog: none

This is only an internal change and therefore not worth an entry in the general change log.

---

Tested on:
* [x] Linux (by `@xFrednet)`
* [ ] Windows (All used commands run inside the git bash, so it's very likely to work as well `@xFrednet)`
* [ ] macOS
2021-06-25 09:22:04 +00:00
xFrednet
8e969cdcef
Updated several clippy_dev messages and types (PR suggestions)
Co-authored-by: Philipp Krones <hello@philkrones.com>
2021-06-25 11:17:00 +02:00
xFrednet
f0fa363653
Added cargo dev remove intellij 2021-06-25 11:17:00 +02:00
xFrednet
8fdf2897da
Updated cargo dev setup intellij for cleaner user messages 2021-06-25 11:17:00 +02:00
xFrednet
b48f041bef
Added the cargo dev remove command for convenience 2021-06-25 11:17:00 +02:00
xFrednet
3d0984975e
Print cargo dev help on missing arg and updated setup documentation 2021-06-25 11:17:00 +02:00
xFrednet
41bc0f4d4d
Adjust pre-commit script to readd files after formatting 2021-06-25 11:16:59 +02:00
xFrednet
0a5f28c4b0
Added cargo dev setup git-hook 2021-06-25 11:16:59 +02:00
xFrednet
0941d9f14d
Moved dev ide_setup to setup/intellij.rs 2021-06-25 11:16:55 +02: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
bors
d568387817 Auto merge of #7396 - ranweiler:zero-offset, r=Manishearth
Fix invocation of `zst_offset` lint

The `zst_offset` lint was broken by a refactoring regression in 21083875d2. In the invocation of the `zst_offset` check [here](21083875d2 (diff-7f73f6fe28c04b654223c09c42fe02937d2351fc58a91d21ab812aaf6f9b185dR1927)), we shadow the already-destructured receiver `recv`, and accidentally pass the first argument of the method as if it were the receiver.

This was not caught because the UI test expectation was never correct (a bad cast obscured the actual test result).

This PR:
- Fixes the existing test expectation
- Tests both `const` and `mut` raw pointers
- Passes the actual receiver to the lint's implementation

Fixes #7395.

changelog: Fix [`zst_offset`] invocation and test
2021-06-23 22:22:39 +00:00
bors
417401f849 Auto merge of #7394 - ehuss:update-opener, r=ehuss
Update opener.

This updates the opener dependency, to try to reduce the duplicate dependencies in the rust-lang/rust repo.  The changelog is [here](https://github.com/Seeker14491/opener/blob/master/CHANGELOG.md#050---2021-06-11), and I don't expect it to have much of a change to anyone.

changelog: none
2021-06-23 18:49:31 +00:00
Joe Ranweiler
642239c857 Update var name in test 2021-06-22 19:02:34 -07:00
Joe Ranweiler
10122e4a48 Remove shadowed receiver in check invocation 2021-06-22 18:45:12 -07:00
Joe Ranweiler
d2087ad00d Remove bad cast in test, cover more cases 2021-06-22 18:45:03 -07:00
Eric Huss
9301ffbe35 Update opener. 2021-06-22 16:22:16 -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
bors
a8b374fefb Auto merge of #7386 - camsteffen:fmt-workaround, r=flip1995
Remove rustfmt bug workaround

The bug is reportedly fixed.

changelog: none
2021-06-21 17:01:51 +00:00
Elliot Bobrow
20cb1bc7c1 check for unbalanced tick pairs in doc-markdown 2021-06-21 08:52:09 -07:00
Cameron Steffen
206bb08d10 Remove rustfmt workaround 2021-06-21 10:50:48 -05:00
bors
86bf28dfab Auto merge of #7385 - xFrednet:0000-fix-broken-deploy, r=flip1995
Fixed broken deploy script due to multiline configuration docs

The deploy script on master currently runs into an error (See [log](https://github.com/rust-lang/rust-clippy/runs/2865828873)) due to the new configuration documentation added in #7299. The current documentation collection for the configuration macro sadly doesn't support multiline doc comments. This will be changes in the future with the new metadata collector tracked in #7172 For now we have to use `<br>` inside doc comments to add paragraphs.

This PR restricts `define_Conf!` macro to single lines and adds a comment explaining the reasoning behind it. It also adjusted the actual document parsing to fix a bug. (The parsing was automatically stopping on the first curly bracket, even if it was part of a doc comment).

changelog: none
2021-06-21 08:55:38 +00: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
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
xFrednet
96a9786b1c Fixed broken deploy script due to multiline configuration docs 2021-06-20 22:32:32 +02: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