]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoImprove `needless_borrow` lint.
Jason Newcomb [Mon, 15 Nov 2021 16:58:25 +0000 (11:58 -0500)]
Improve `needless_borrow` lint.

* Lint when a borrow is auto dereferenced more than once
* Lint when the expression is used as the expression of a block for a match arm

Moves `needless_borrow` and `ref_binding_to_reference` to `dereference`
lint pass in preperation for `explicit_auto_deref` lint.

2 years agoAuto merge of #7969 - togami2864:fix-typo, r=xFrednet
bors [Sat, 13 Nov 2021 11:17:38 +0000 (11:17 +0000)]
Auto merge of #7969 - togami2864:fix-typo, r=xFrednet

fix typo

just fixed typo

changelog: none

2 years agofix typo
togami2864 [Sat, 13 Nov 2021 06:23:33 +0000 (15:23 +0900)]
fix typo

2 years agoAuto merge of #7966 - Alexendoo:batch-rustfmt, r=camsteffen
bors [Fri, 12 Nov 2021 21:48:37 +0000 (21:48 +0000)]
Auto merge of #7966 - Alexendoo:batch-rustfmt, r=camsteffen

Run rustfmt on batches of multiple files

changelog: none

This gives `cargo dev fmt` a nice speed boost, down from 90s (because old) on my laptop and 120s (because windows) on my desktop to ~5s on both

250 at a time was to give windows a good amount of headroom (failed at ~800, https://github.com/rust-lang/rust/issues/40384)

Also adds rustfmt to the toolchain file and has the clippy_dev workflow test using the pinned version as a follow up to #7963

2 years agoRun rustfmt on batches of multiple files
Alex Macleod [Fri, 12 Nov 2021 16:41:08 +0000 (16:41 +0000)]
Run rustfmt on batches of multiple files

2 years agoRun clippy_dev workflow on current rust-toolchain
Alex Macleod [Fri, 12 Nov 2021 18:54:31 +0000 (18:54 +0000)]
Run clippy_dev workflow on current rust-toolchain

2 years agoAdd rustfmt component to rust-toolchain
Alex Macleod [Fri, 12 Nov 2021 18:54:08 +0000 (18:54 +0000)]
Add rustfmt component to rust-toolchain

2 years agoAuto merge of #7948 - 5225225:castlosslessbool, r=llogiq
bors [Fri, 12 Nov 2021 18:17:18 +0000 (18:17 +0000)]
Auto merge of #7948 - 5225225:castlosslessbool, r=llogiq

Lint for bool to integer casts in `cast_lossless`

The lint description says

> Checks for casts between *numerical* types that may be replaced by safe conversion functions.

Which is strictly speaking being violated here, but it seems within the spirit of the lint. I think it is still a useful lint to have, and having a different lint for just this feels excessive. Thoughts?

Fixes #7947

changelog: Lint for bool to integer casts in [`cast_lossless`]

2 years agoChange cast_lossless message for bools only
5225225 [Fri, 12 Nov 2021 17:01:35 +0000 (17:01 +0000)]
Change cast_lossless message for bools only

2 years agoAuto merge of #7963 - Jarcho:dev_fmt, r=flip1995
bors [Fri, 12 Nov 2021 09:43:09 +0000 (09:43 +0000)]
Auto merge of #7963 - Jarcho:dev_fmt, r=flip1995

Use rustfmt version from `rust-toolchain`

changelog: None

2 years agoUse rustfmt version from `rust-toolchain`
Jason Newcomb [Fri, 12 Nov 2021 02:14:40 +0000 (21:14 -0500)]
Use rustfmt version from `rust-toolchain`

2 years agoAuto merge of #7956 - camsteffen:author, r=llogiq
bors [Thu, 11 Nov 2021 19:33:06 +0000 (19:33 +0000)]
Auto merge of #7956 - camsteffen:author, r=llogiq

Author improvements

changelog: none

Various aspects of the author implementation are re-imagined to be much less repetitive. Also fixes some bugs. I hope this makes author more fun to work on for future contributors.

The last commit is pretty heavy but I tried to at least separate some changes so that the test file diffs per commit are simple.

2 years agoAuto merge of #7643 - xFrednet:7569-splits-for-slices, r=camsteffen
bors [Thu, 11 Nov 2021 16:42:57 +0000 (16:42 +0000)]
Auto merge of #7643 - xFrednet:7569-splits-for-slices, r=camsteffen

New lint `index_refutable_slice` to avoid slice indexing

A new lint to check for slices that could be deconstructed to avoid indexing. This lint should hopefully prevent some panics in other projects and ICEs for us. See #7569 for an example

The implementation specifically checks for immutable bindings in `if let` statements to slices and arrays. Then it checks if these bindings are only used for value access using indices and that these indices are lower than the configured limit. I did my best to keep the implementation small, however the check was sadly quite complex. Now it's around 300 lines for the implementation and the rest are test.

---

Optional future improvements:
* Check for these instances also in `match` statements
* Check for mutable slice bindings that could also be destructed

---

changelog: New lint [`index_refutable_slice`]

I've already fixed a bunch of lint triggers in #7638 to make this PR smaller

Closes: #7569
2 years agoNew `index_refutable_slice` lint
xFrednet [Tue, 31 Aug 2021 17:17:24 +0000 (19:17 +0200)]
New `index_refutable_slice` lint

* Finding pattern slices for `avoidable_slice_indexing`
* `avoidable_slice_indexing` analysing slice usage
* Add configuration to `avoidable_slice_indexing`
* Emitting `avoidable_slice_indexing` with suggestions
* Dogfooding and fixing bugs
* Add ui-toml test for `avoidable_slice_indexing`
* Correctly suggest `ref` keywords for `avoidable_slice_indexing`
* Test and document `mut` for `avoid_slice_indexing`
* Handle macros with `avoidable_slice_indexing` lint
* Ignore slices with sub patterns in `avoidable_slice_indexing`
* Update lint description for `avoidable_slice_indexing`
* Move `avoidable_slice_indexing` to nursery
* Added more tests for `avoidable_slice_indexing`
* Update documentation and message for `avoidable_slice_indexing`
* Teach `avoidable_slice_indexing` about `HirId`s and `Visitors`
* Rename lint to `index_refutable_slice` and connected config

2 years agoMake author DRYer
Cameron Steffen [Fri, 5 Nov 2021 22:05:04 +0000 (17:05 -0500)]
Make author DRYer

2 years agoAuto merge of #7813 - xFrednet:6492-lint-version, r=flip1995
bors [Thu, 11 Nov 2021 12:38:04 +0000 (12:38 +0000)]
Auto merge of #7813 - xFrednet:6492-lint-version, r=flip1995

Add Clippy version to Clippy's lint list

Hey, hey, the semester is finally over, and I wanted to get back into hacking on Clippy. It has also been some time since our metadata collection monster has been feed. So, this PR adds a new attribute `clippy::version` to document which version a lint was stabilized. I considered using `git blame` but that would be very hacky and probably not accurate.

I'm also thinking that this attribute can be used to have a `clippy::nightly` lint group which is allow-by-default that delays setting the actual lint group until the defined version is reached. Just something to consider regarding #6623 :upside_down_face:

This PR only adds the version to 4 lints to keep it reviewable. I'll do a followup PR to add the version to other lints if the implementation is accepted :upside_down_face:

![image](https://user-images.githubusercontent.com/17087237/137118859-0aafdfdf-7595-4289-8ba4-33d58eb6991d.png)

Also, mobile approved xD

![image](https://user-images.githubusercontent.com/17087237/137118944-833cf7fb-a4a1-45d6-9af8-32c951822360.png)

---

r? `@flip1995`

cc: #7172

closes: #6492

changelog: [Clippy's lint list](https://rust-lang.github.io/rust-clippy/master/index.html) now displays the version a lint was added. :tada:

---

Example lint declaration after this update:

```rs
declare_clippy_lint! {
    /// [...]
    ///
    /// ### Example
    /// ```rust
    /// // Bad
    /// let x = 3.14;
    /// // Good
    /// let x = std::f32::consts::PI;
    /// ```
    #[clippy::version = "pre 1.29.0"]
    pub APPROX_CONSTANT,
    correctness,
    "the approximate of a known float constant (in `std::fXX::consts`)"
}
```

2 years agoNew internal lint to make `clippy::version` attribute mandatory
xFrednet [Thu, 11 Nov 2021 11:54:53 +0000 (12:54 +0100)]
New internal lint to make  `clippy::version` attribute mandatory

2 years agoAuto merge of #7877 - dswij:no-std-fp, r=camsteffen
bors [Thu, 11 Nov 2021 05:31:11 +0000 (05:31 +0000)]
Auto merge of #7877 - dswij:no-std-fp, r=camsteffen

[`swap`] lints now check if there is `no_std` or `no_core` attribute

Closes #7858

changelog: [`swap`] lints now check if there is `no_std` or `no_core` attribute

2 years agoAdd test for `swap` lint when `no_std` is present
dswij [Mon, 25 Oct 2021 04:32:53 +0000 (12:32 +0800)]
Add test for `swap` lint when `no_std` is present

Adds additional test to check for `swap` suggestion when `no_std` is present

2 years agoCheck for no_std and no_core attribute in `swap` lint
dswij [Mon, 25 Oct 2021 04:29:05 +0000 (12:29 +0800)]
Check for no_std and no_core attribute in `swap` lint

This commit adds a `no_std` and `no_core` check on `swap` lint and additionally suggest `core::mem::swap` whenever possible.
Remove warning if both `std` and `core` is not present.

2 years agoRefactor utils on checking attribute
dswij [Mon, 25 Oct 2021 03:59:18 +0000 (11:59 +0800)]
Refactor utils on checking attribute

Moved out reusable pieces from `is_automatically_derived` and
`any_parent_is_automatically_derived`.

2 years agoauthor: Remove needless `ref`s
Cameron Steffen [Wed, 10 Nov 2021 21:59:49 +0000 (15:59 -0600)]
author: Remove needless `ref`s

2 years agoauthor: reorder match arm
Cameron Steffen [Mon, 8 Nov 2021 23:47:33 +0000 (17:47 -0600)]
author: reorder match arm

2 years agoauthor: fix some bugs
Cameron Steffen [Wed, 10 Nov 2021 21:42:49 +0000 (15:42 -0600)]
author: fix some bugs

2 years agoauthor: name qpath consistently
Cameron Steffen [Mon, 8 Nov 2021 23:05:37 +0000 (17:05 -0600)]
author: name qpath consistently

2 years agoAddress review feedback
xFrednet [Wed, 10 Nov 2021 19:08:38 +0000 (20:08 +0100)]
Address review feedback

2 years agoUpdated version label and style on Clippy's lint list
xFrednet [Tue, 2 Nov 2021 16:49:12 +0000 (17:49 +0100)]
Updated version label and style on Clippy's lint list

2 years agoAdd lint to check for invalid `clippy:version` attributes
xFrednet [Thu, 21 Oct 2021 21:00:31 +0000 (23:00 +0200)]
Add lint to check for invalid `clippy:version` attributes

2 years agoAdded `clippy::version` attribute to all normal lints
xFrednet [Thu, 21 Oct 2021 19:06:26 +0000 (21:06 +0200)]
Added `clippy::version` attribute to all normal lints

So, some context for this, well, more a story. I'm not used to scripting, I've never really scripted anything, even if it's a valuable skill. I just never really needed it. Now, `@flip1995` correctly suggested using a script for this in `rust-clippy#7813`...

And I decided to write a script using nushell because why not? This was a mistake... I spend way more time on this than I would like to admit. It has definitely been more than 4 hours. It shouldn't take that long, but me being new to scripting and nushell just wasn't a good mixture... Anyway, here is the script that creates another script which adds the versions. Fun...

Just execute this on the `gh-pages` branch and the resulting `replacer.sh` in `clippy_lints` and it should all work.

```nu
mv v0.0.212 rust-1.00.0;
mv beta rust-1.57.0;
mv master rust-1.58.0;

let paths = (open ./rust-1.58.0/lints.json | select id id_span | flatten | select id path);
let versions = (
    ls | where name =~ "rust-" | select name | format {name}/lints.json |
    each { open $it | select id | insert version $it | str substring "5,11" version} |
    group-by id | rotate counter-clockwise id version |
    update version {get version | first 1} | flatten | select id version);
$paths | each { |row|
    let version = ($versions | where id == ($row.id) | format {version})
    let idu = ($row.id | str upcase)
    $"sed -i '0,/($idu),/{s/pub ($idu),/#[clippy::version = "($version)"]\n    pub ($idu),/}' ($row.path)"
} | str collect ";" | str find-replace --all '1.00.0' 'pre 1.29.0' | save "replacer.sh";
```

And this still has some problems, but at this point I just want to be done -.-

2 years agoManually add `clippy::version` attribute to deprecated lints
xFrednet [Sun, 17 Oct 2021 14:57:13 +0000 (16:57 +0200)]
Manually add `clippy::version` attribute to deprecated lints

2 years agoDocument new `clippy::version` attribute and make it mandatory
xFrednet [Sun, 17 Oct 2021 13:02:12 +0000 (15:02 +0200)]
Document new `clippy::version` attribute and make it mandatory

2 years agoAdd clippy version to Clippy's lint list
xFrednet [Tue, 12 Oct 2021 21:01:44 +0000 (23:01 +0200)]
Add clippy version to Clippy's lint list

2 years agoAdded `clippy::version` attribute as lint metadata
xFrednet [Tue, 12 Oct 2021 20:51:44 +0000 (22:51 +0200)]
Added `clippy::version` attribute as lint metadata

2 years agoAuto merge of #7955 - dswij:let-else-early-return, r=giraffate
bors [Wed, 10 Nov 2021 13:26:38 +0000 (13:26 +0000)]
Auto merge of #7955 - dswij:let-else-early-return, r=giraffate

Fix `semicolon_if_nothing_returned` FP on `let-else` stmts

closes #7912

`semicolon_if_nothing_returned` now additionally checks if the statements ends in `;` , this will also prevent `let-else` statements to be linted.

changelog: fix [`semicolon_if_nothing_returned`] FP  firing on `let-else`

2 years ago`semicolon_if_nothing_returned` now checks if the stmt ends with semicolon
dswij [Wed, 10 Nov 2021 06:46:00 +0000 (14:46 +0800)]
`semicolon_if_nothing_returned` now checks if the stmt ends with semicolon

2 years agoAdd `semicolon_if_nothing_returned` test for `let-else` stmts
dswij [Wed, 10 Nov 2021 06:41:41 +0000 (14:41 +0800)]
Add `semicolon_if_nothing_returned` test for `let-else` stmts

2 years agoAuto merge of #7951 - mikerite:matches-20211109, r=llogiq
bors [Tue, 9 Nov 2021 19:28:48 +0000 (19:28 +0000)]
Auto merge of #7951 - mikerite:matches-20211109, r=llogiq

`match_overlapping_arm` refactoring

The main purpose of this pull request is to remove the unneeded and scary `unimplented!()` in the `match_arm_overlapping` code.

The rest is gratuitous refactoring.

changelog: none

2 years agoAuto merge of #7950 - Serial-ATA:issue-7920, r=llogiq
bors [Tue, 9 Nov 2021 19:14:24 +0000 (19:14 +0000)]
Auto merge of #7950 - Serial-ATA:issue-7920, r=llogiq

Fix `explicit_counter_loop` suggestion for non-usize types

changelog: Add a new suggestion for non-usize types in [`explicit_counter_loop`]

closes: #7920

2 years agoCheck MSRV for bool to int from impl
5225225 [Tue, 9 Nov 2021 17:35:35 +0000 (17:35 +0000)]
Check MSRV for bool to int from impl

2 years agofix dogfood lint on clippy_utils
5225225 [Mon, 8 Nov 2021 22:03:06 +0000 (22:03 +0000)]
fix dogfood lint on clippy_utils

2 years agoLint for bool to integer casts in `cast_lossless`
5225225 [Mon, 8 Nov 2021 20:44:50 +0000 (20:44 +0000)]
Lint for bool to integer casts in `cast_lossless`

2 years agoAuto merge of #7949 - Serial-ATA:issue-7921, r=flip1995
bors [Tue, 9 Nov 2021 12:37:49 +0000 (12:37 +0000)]
Auto merge of #7949 - Serial-ATA:issue-7921, r=flip1995

Fix suggestion for deref expressions in redundant_pattern_matching

changelog: Fix suggestion for deref expressions in [`redundant_pattern_matching`]

closes: #7921

2 years agoFix suggestion for deref expressions in redundant_pattern_matching
Serial [Mon, 8 Nov 2021 23:31:18 +0000 (18:31 -0500)]
Fix suggestion for deref expressions in redundant_pattern_matching

2 years agomatches: remove `pub` from some items
Michael Wright [Tue, 9 Nov 2021 03:44:02 +0000 (05:44 +0200)]
matches: remove `pub` from some items

There is no reason for these to be `pub`. They aren't used anywhere
else.

2 years agoImprove variable naming 2
Michael Wright [Tue, 9 Nov 2021 03:44:02 +0000 (05:44 +0200)]
Improve variable naming 2

2 years agoImprove variable naming
Michael Wright [Tue, 9 Nov 2021 03:44:02 +0000 (05:44 +0200)]
Improve variable naming

2 years agoSimplify range comparison code
Michael Wright [Tue, 9 Nov 2021 03:44:02 +0000 (05:44 +0200)]
Simplify range comparison code

Reword the `Kind` type so that the `cmp` function is simpler.

2 years agoChange `Bound` to `EndBound`
Michael Wright [Tue, 9 Nov 2021 03:44:02 +0000 (05:44 +0200)]
Change `Bound` to `EndBound`

Only the end bounds of ranges can actually be included or excluded. This
commit changes the SpannedRange type to reflect that. Update `Kind::value`
to and `Kind::cmp` for this change. `Kind::cmp` gets flipped to check value
first and then the bound details and is much shorter.

2 years agoRemove `unimplemented!()` case in matches code
Michael Wright [Tue, 9 Nov 2021 03:44:02 +0000 (05:44 +0200)]
Remove `unimplemented!()` case in matches code

This unbounded case never actually happens because `all_ranges(..)` uses
the scrutinee type bounds for open ranges. Switch to our own `Bound`
enum so that we don't have this case.

2 years agoFix explicit_counter_loop suggestion for non-usize types
Serial [Tue, 9 Nov 2021 03:09:26 +0000 (22:09 -0500)]
Fix explicit_counter_loop suggestion for non-usize types

2 years agoAuto merge of #7944 - Serial-ATA:deprecated-cfg-attr-msrv, r=giraffate
bors [Tue, 9 Nov 2021 00:58:37 +0000 (00:58 +0000)]
Auto merge of #7944 - Serial-ATA:deprecated-cfg-attr-msrv, r=giraffate

Add MSRV to deprecated_cfg_attr

changelog: Add MSRV to [`deprecated_cfg_attr`]

closes: #7922

2 years agoAdd MSRV to deprecated_cfg_attr
Serial [Sun, 7 Nov 2021 18:52:34 +0000 (13:52 -0500)]
Add MSRV to deprecated_cfg_attr

2 years agoAuto merge of #7938 - camsteffen:visitors, r=xFrednet
bors [Mon, 8 Nov 2021 13:39:58 +0000 (13:39 +0000)]
Auto merge of #7938 - camsteffen:visitors, r=xFrednet

Introduce `expr_visitor` and `expr_visitor_no_bodies`

changelog: none

A couple utils that satisfy a *lot* of visitor use cases. Factoring in every possible usage would be really big so I just focused on cleaning clippy_utils.

2 years agoAuto merge of #7945 - Serial-ATA:issue-7934, r=flip1995
bors [Mon, 8 Nov 2021 10:48:34 +0000 (10:48 +0000)]
Auto merge of #7945 - Serial-ATA:issue-7934, r=flip1995

Fix ICE in undocumented_unsafe_blocks

changelog: Fix ICE in [`undocumented_unsafe_blocks`]

closes: #7934

2 years agoFix ICE in undocumented_unsafe_blocks
Serial [Sun, 7 Nov 2021 19:28:30 +0000 (14:28 -0500)]
Fix ICE in undocumented_unsafe_blocks

2 years agoAuto merge of #7917 - Alexendoo:cargo-dev-lint, r=giraffate
bors [Sun, 7 Nov 2021 06:06:26 +0000 (06:06 +0000)]
Auto merge of #7917 - Alexendoo:cargo-dev-lint, r=giraffate

Add `cargo dev lint` to manually run clippy on a file

I found the manual run command really useful, this makes it a bit easier to type

Not sure if this belongs in the changelog or not

changelog: Add `cargo dev lint` to manually run clippy on a file

2 years agoAuto merge of #7894 - Serial-ATA:extend-author-lint, r=camsteffen
bors [Sat, 6 Nov 2021 20:08:32 +0000 (20:08 +0000)]
Auto merge of #7894 - Serial-ATA:extend-author-lint, r=camsteffen

Extend author lint

changelog: none

* Print float and int suffixes
* Print labels
* Struct field checks
* Repeat length expression check
* Destructure method calls
* Destructure closures

2 years agoAdd `cargo dev lint` to manually run clippy on a file
Alex Macleod [Tue, 2 Nov 2021 13:21:27 +0000 (13:21 +0000)]
Add `cargo dev lint` to manually run clippy on a file

I found the manual run command really useful, this makes it a bit easier
to type

2 years agoExtend author lint
Serial [Fri, 29 Oct 2021 01:39:41 +0000 (21:39 -0400)]
Extend author lint

2 years agoRemove if let check for match_ref_pats
Cameron Steffen [Fri, 5 Nov 2021 19:50:22 +0000 (14:50 -0500)]
Remove if let check for match_ref_pats

2 years agoFactor in some expr_visitor usages
Cameron Steffen [Fri, 5 Nov 2021 18:41:31 +0000 (13:41 -0500)]
Factor in some expr_visitor usages

2 years agoAdd expr_visitor util
Cameron Steffen [Wed, 20 Oct 2021 18:16:50 +0000 (13:16 -0500)]
Add expr_visitor util

2 years agoRemove trim_semicolon
Cameron Steffen [Tue, 2 Nov 2021 21:08:09 +0000 (16:08 -0500)]
Remove trim_semicolon

2 years agoAuto merge of #7937 - flip1995:rustfmt-skip-artefact, r=Manishearth
bors [Fri, 5 Nov 2021 15:34:46 +0000 (15:34 +0000)]
Auto merge of #7937 - flip1995:rustfmt-skip-artefact, r=Manishearth

Remove rustfmt::skip attribute from register_plugins function

r? `@Manishearth` since you added this in #540 :smile:

changelog: none

2 years agoAuto merge of #7897 - camsteffen:in-macro, r=flip1995
bors [Fri, 5 Nov 2021 14:42:32 +0000 (14:42 +0000)]
Auto merge of #7897 - camsteffen:in-macro, r=flip1995

Replace `in_macro` usage with `from_expansion`

changelog: none

Generally replace `in_macro(span)` with `span.from_expansion()`. If we're just trying to avoid expanded code, this seems more appropriate because any kind of expanded code is prone to false positives. One place I did not touch is `macro_use.rs`. I think this lint could use a rewrite so I moved `in_macro` there, the only place it is still used.

2 years agoEdit docs about macros
Cameron Steffen [Fri, 5 Nov 2021 13:30:22 +0000 (08:30 -0500)]
Edit docs about macros

2 years agoAuto merge of #7909 - mikerite:fix-7816, r=camsteffen
bors [Fri, 5 Nov 2021 14:16:38 +0000 (14:16 +0000)]
Auto merge of #7909 - mikerite:fix-7816, r=camsteffen

Fix false negative in [`match_overlapping_arms`]

changelog: Fix false negative in [`match_overlapping_arms`]

2 years agoUse Span::from_expansion instead of in_macro
Cameron Steffen [Fri, 29 Oct 2021 16:14:22 +0000 (11:14 -0500)]
Use Span::from_expansion instead of in_macro

2 years agoRemove rustfmt::skip attribute from register_plugins function
flip1995 [Fri, 5 Nov 2021 10:54:37 +0000 (10:54 +0000)]
Remove rustfmt::skip attribute from register_plugins function

2 years agoAuto merge of #7928 - xFrednet:rust-90354-deploy-clippy-docs, r=flip1995
bors [Thu, 4 Nov 2021 12:27:50 +0000 (12:27 +0000)]
Auto merge of #7928 - xFrednet:rust-90354-deploy-clippy-docs, r=flip1995

Reference `clippy_utils` docs on nightly-rustc and some other documentation updates

The `clippy_utils` crate is now part of the nightly-rustc documentation. See [**very beautiful documentation**](https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/). This PR references them in our documentation and updates some other documentation.

changelog: none

2 years agoAdded note about the usage of `clippy_utils::path`
xFrednet [Thu, 4 Nov 2021 12:27:08 +0000 (13:27 +0100)]
Added note about the usage of `clippy_utils::path`

2 years agoAuto merge of #7929 - flip1995:rustup, r=flip1995
bors [Thu, 4 Nov 2021 12:07:07 +0000 (12:07 +0000)]
Auto merge of #7929 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: none

2 years agoBump nightly version -> 2021-11-04
flip1995 [Thu, 4 Nov 2021 12:03:53 +0000 (12:03 +0000)]
Bump nightly version -> 2021-11-04

2 years agoMerge remote-tracking branch 'upstream/master' into rustup
flip1995 [Thu, 4 Nov 2021 12:03:28 +0000 (12:03 +0000)]
Merge remote-tracking branch 'upstream/master' into rustup

2 years agoAdd clippy docs to check for a specific type
xFrednet [Thu, 4 Nov 2021 11:39:42 +0000 (12:39 +0100)]
Add clippy docs to check for a specific type

2 years agoImprove `clippy_utils` function docs
xFrednet [Thu, 4 Nov 2021 11:09:48 +0000 (12:09 +0100)]
Improve `clippy_utils` function docs

2 years agoReference nightly-rustc docs in clippy's docs
xFrednet [Thu, 4 Nov 2021 11:09:15 +0000 (12:09 +0100)]
Reference nightly-rustc docs in clippy's docs

2 years agoAuto merge of #7926 - lengyijun:patch-1, r=giraffate
bors [Thu, 4 Nov 2021 05:12:59 +0000 (05:12 +0000)]
Auto merge of #7926 - lengyijun:patch-1, r=giraffate

lower_case in  span_lint_and_help document

changelog: none

2 years agoUpdate diagnostics.rs
lyj [Thu, 4 Nov 2021 03:57:14 +0000 (11:57 +0800)]
Update diagnostics.rs

2 years agoRollup merge of #90500 - xFrednet:00000-update-clippy-deps, r=flip1995
Matthias Krüger [Tue, 2 Nov 2021 22:48:49 +0000 (23:48 +0100)]
Rollup merge of #90500 - xFrednet:00000-update-clippy-deps, r=flip1995

Update Clippy dependencies

Clippy has two outdated dependencies, where one indirect dependency has been flagged by rustsec for dropping a lifetime. See [RUSTSEC-2020-0146](https://rustsec.org/advisories/RUSTSEC-2020-0146). This PR updates these dependencies.

With previous dependency updates, it was tried to prevent duplicates in the `Cargo.lock` file of rust-lang/rust. I've tried to keep this in mind with this update.

* Dependency `semver`
    * Used in `src/tools/cargo/Cargo.toml` as version `1.0.3`
    * Used in `src/tools/rust-analyzer/crates/project_model/Cargo.toml` as version `1`
    * Updated in Clippy from `0.11` to `1.0` (Clippy usually defines the major and minor patch version). The `Cargo.lock` file lists `1.0.3` which is one patch version behind the most recent one but prevents a duplicate with cargo's pinned version.
* Dependency `cargo_metadata`
    * Used in several tools as `0.14`
    * Used in `src/tools/tidy` and `src/tools/rls` as `0.12`
    * Updated in Clippy from `0.12` to `0.14`

All updates to the `Cargo.lock` have been done automatically by `x.py`.

There are still some tools with these outdated dependencies. Clippy didn't require any changes, and it would be likely that the others could also be updated without any problem. Let me know if I should try to update them as well :upside_down_face:.

Keep up the good work, whoever is reading this :crab:

---

For Clippy:

changelog: none

2 years agoAuto merge of #7904 - Serial-ATA:improve-doc-suggestion, r=xFrednet
bors [Tue, 2 Nov 2021 21:07:21 +0000 (21:07 +0000)]
Auto merge of #7904 - Serial-ATA:improve-doc-suggestion, r=xFrednet

Add suggestion to missing backticks error

changelog: Add a machine applicable suggestion for the [`doc_markdown`] missing backticks lint

closes: #7737

2 years agoSpecify fixable doc tests
Serial [Tue, 2 Nov 2021 21:04:35 +0000 (17:04 -0400)]
Specify fixable doc tests

2 years agoAdd suggestion to missing backticks error
Serial [Sun, 31 Oct 2021 00:11:06 +0000 (20:11 -0400)]
Add suggestion to missing backticks error

2 years agoAuto merge of #7916 - samueltardieu:double-colon-prefix, r=xFrednet
bors [Tue, 2 Nov 2021 17:02:06 +0000 (17:02 +0000)]
Auto merge of #7916 - samueltardieu:double-colon-prefix, r=xFrednet

Advise to put a :: prefix inside the ticks

Fixes #7914.

changelog: Keep an initial `::` when [`doc_markdown`] suggests to use ticks

2 years agoAdvise to put a :: prefix inside the ticks
Samuel Tardieu [Tue, 2 Nov 2021 13:44:21 +0000 (14:44 +0100)]
Advise to put a :: prefix inside the ticks

2 years agoAuto merge of #7918 - samueltardieu:use-config-toml, r=flip1995
bors [Tue, 2 Nov 2021 16:16:20 +0000 (16:16 +0000)]
Auto merge of #7918 - samueltardieu:use-config-toml, r=flip1995

Use .cargo/config.toml instead of .cargo/config

`.cargo/config.toml` is the preferred form for the local configuration file. This is emphasized in _The Cargo Book_ with the following note:

> Note: Cargo also reads config files without the `.toml` extension, such as `.cargo/config`. Support for the `.toml` extension was added in version 1.39 and is the preferred form.

Moreover, this helps with toml-aware text editors as they will recognize the file extension.

changelog: none

2 years agoUse .cargo/config.toml instead of .cargo/config
Samuel Tardieu [Tue, 2 Nov 2021 16:04:39 +0000 (17:04 +0100)]
Use .cargo/config.toml instead of .cargo/config

`.cargo/config.toml` is the preferred form for the local configuration
file. This is emphasized in _The Cargo Book_ with the following note:

> Note: Cargo also reads config files without the `.toml` extension, such
> as `.cargo/config`. Support for the `.toml` extension was added in version
> 1.39 and is the preferred form.

Moreover, this helps with toml-aware text editors as they will recognize
the file extension.

2 years agoAuto merge of #7906 - smoelius:master, r=camsteffen
bors [Tue, 2 Nov 2021 14:06:36 +0000 (14:06 +0000)]
Auto merge of #7906 - smoelius:master, r=camsteffen

Fix #7903

Fixes #7903 (cc: `@Arnavion)`

changelog: none (bug is in same release)

r? `@camsteffen`

2 years agoUpdate clippy dependencies
xFrednet [Tue, 2 Nov 2021 13:19:31 +0000 (14:19 +0100)]
Update clippy dependencies

* semver = "0.11" -> "1.0"
* cargo_metadata = "0.12" -> "0.14"

2 years agoAuto merge of #7907 - Alexendoo:non-ascii-restriction, r=flip1995
bors [Tue, 2 Nov 2021 10:36:26 +0000 (10:36 +0000)]
Auto merge of #7907 - Alexendoo:non-ascii-restriction, r=flip1995

Move non_ascii_literal to restriction

It feels like the more apt category, since cases where you'd want it enabled would be pretty specific

changelog: Move [`non_ascii_literal`] to `restriction`

2 years agoAuto merge of #7901 - samueltardieu:fix-7893, r=xFrednet,flip1995
bors [Tue, 2 Nov 2021 10:23:15 +0000 (10:23 +0000)]
Auto merge of #7901 - samueltardieu:fix-7893, r=xFrednet,flip1995

Prevent clippy::needless_lifetimes false positive in async function definition

Scan `OpaqueDef` bounds for lifetimes as well. Those `OpaqueDef` instances are generated while desugaring an `async` function definition.

This fixes #7893

changelog: Prevent [`clippy::needless_lifetimes`] false positive in `async` function definition

2 years agoAuto merge of #7851 - nbdd0121:master, r=flip1995
bors [Tue, 2 Nov 2021 10:09:47 +0000 (10:09 +0000)]
Auto merge of #7851 - nbdd0121:master, r=flip1995

Fix manual_assert and match_wild_err_arm for `#![no_std]` and Rust 2021

Rust 2015 `std::panic!` has a wrapping block while `core::panic!` and Rust 2021 `std::panic!` does not. See rust-lang/rust#88919 for details.

Note that the test won't pass until clippy changes in rust-lang/rust#88860 is synced.

---

changelog: Fix [`manual_assert`] and [`match_wild_err_arm`] for `#![no_std]` and Rust 2021.

Fixes #7723

2 years agoAdd test case for `clippy::needless_lifetimes` in async context
Samuel Tardieu [Sat, 30 Oct 2021 10:11:45 +0000 (12:11 +0200)]
Add test case for `clippy::needless_lifetimes` in async context

Edition needs to be set to 2018 due to the use of `async`.

2 years agoAuto merge of #7726 - dswij:unseparated-literal-suffix, r=flip1995
bors [Tue, 2 Nov 2021 09:57:12 +0000 (09:57 +0000)]
Auto merge of #7726 - dswij:unseparated-literal-suffix, r=flip1995

Unseparated literal suffix

Closes #7658

Since `literal_suffix` style is opinionated, we should disable by default and only enforce if it's stated as so.

changelog: [`unseparated_literal_suffix`] is renamed to `literal_suffix`, adds a new configuration `literal-suffix-style` to enforce a certain style writing literal_suffix. Possible values for `literal-suffix-style`: `"separated"`, `"unseparated"`

2 years agoExamine lifetimes in `OpaqueDef` bounds as well
Samuel Tardieu [Sat, 30 Oct 2021 10:02:20 +0000 (12:02 +0200)]
Examine lifetimes in `OpaqueDef` bounds as well

Fix #7893.

2 years agoAuto merge of #7819 - rust-lang:avoid-linting-impossible-truncation, r=flip1995
bors [Tue, 2 Nov 2021 09:44:27 +0000 (09:44 +0000)]
Auto merge of #7819 - rust-lang:avoid-linting-impossible-truncation, r=flip1995

avoid linting `possible_truncation` on bit-reducing operations

---

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

changelog: avoid linting `possible_truncation` on bit-reducing operations

2 years agoAuto merge of #7911 - giraffate:small_fixes_for_missing_backticks, r=Manishearth
bors [Tue, 2 Nov 2021 00:19:57 +0000 (00:19 +0000)]
Auto merge of #7911 - giraffate:small_fixes_for_missing_backticks, r=Manishearth

Small fixes for missing backticks in doc

changelog: none

2 years agoSmall fixes for missing backticks in doc
Takayuki Nakata [Tue, 2 Nov 2021 00:09:22 +0000 (09:09 +0900)]
Small fixes for missing backticks in doc

2 years agoFix #7903
Samuel E. Moelius III [Mon, 1 Nov 2021 23:16:37 +0000 (19:16 -0400)]
Fix #7903

2 years agoAccount for revisions in missing-test-files
Gary Guo [Sun, 24 Oct 2021 21:19:59 +0000 (22:19 +0100)]
Account for revisions in missing-test-files