]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoFix `#[expect]` for `clippy::needless_return`
xFrednet [Sat, 25 Jun 2022 12:16:31 +0000 (14:16 +0200)]
Fix `#[expect]` for `clippy::needless_return`

2 years agoFix `#[expect]` for `clippy::implicit_return`
xFrednet [Sat, 25 Jun 2022 12:16:31 +0000 (14:16 +0200)]
Fix `#[expect]` for `clippy::implicit_return`

2 years agoFix `#[expect]` for `clippy::boxed_local`
xFrednet [Sat, 25 Jun 2022 12:16:30 +0000 (14:16 +0200)]
Fix `#[expect]` for `clippy::boxed_local`

2 years agoFix `#[expect]` for `clippy::nonminimal_bool`
xFrednet [Sat, 25 Jun 2022 12:16:30 +0000 (14:16 +0200)]
Fix `#[expect]` for `clippy::nonminimal_bool`

2 years agoFix `#[expect]` for `clippy::logic_bug`
xFrednet [Sat, 25 Jun 2022 12:16:30 +0000 (14:16 +0200)]
Fix `#[expect]` for `clippy::logic_bug`

2 years agoTest `#[expect]` for `redundant_clone`
xFrednet [Sat, 25 Jun 2022 12:16:29 +0000 (14:16 +0200)]
Test `#[expect]` for `redundant_clone`

2 years agoFix `#[expect]` for `clippy::ptr_arg`
xFrednet [Sat, 25 Jun 2022 12:16:28 +0000 (14:16 +0200)]
Fix `#[expect]` for `clippy::ptr_arg`

2 years agoAuto merge of #9015 - kyoto7250:issue_8493, r=Jarcho
bors [Sat, 25 Jun 2022 02:40:30 +0000 (02:40 +0000)]
Auto merge of #9015 - kyoto7250:issue_8493, r=Jarcho

ignore item in `thread_local!` macro

close #8493

This PR ignores `thread_local` macro in `declare_interior_mutable_const`.

changelog: ignore `thread_local!` macro in `declare_interior_mutable_const`

2 years agoAuto merge of #9031 - evantypanski:manual_rem_euclid, r=Jarcho
bors [Fri, 24 Jun 2022 17:49:53 +0000 (17:49 +0000)]
Auto merge of #9031 - evantypanski:manual_rem_euclid, r=Jarcho

Add [`manual_rem_euclid`] lint

Closes #8883

Adds a lint for checking manual use of `rem_euclid(n)`

changelog: Add [`manual_rem_euclid`] lint

2 years agoAuto merge of #9037 - smoelius:fix-extra-unused-lifetimes-fp, r=dswij
bors [Fri, 24 Jun 2022 08:39:45 +0000 (08:39 +0000)]
Auto merge of #9037 - smoelius:fix-extra-unused-lifetimes-fp, r=dswij

Fix `extra_unused_lifetimes` false positive

This PR fixes #9014.

I confirmed the FP on the `crates.io` source as `@JohnTitor` mentioned, and confirmed that the FP is no longer present following this change.

I did not include a test in this PR because I think constructing one would be complicated, and the fix is pretty simple. But please let me know if this is unacceptable.

changelog: fix `extra_unused_lifetimes` FP

2 years agoAuto merge of #9036 - xFrednet:0000-force-warn-in-driver, r=dswij
bors [Fri, 24 Jun 2022 02:26:35 +0000 (02:26 +0000)]
Auto merge of #9036 - xFrednet:0000-force-warn-in-driver, r=dswij

Check for `--force-warn` in Clippy's driver run condition

Just a thing I've noticed while tinkering on the driver. Currently, the driver only checks for `--cap-lints=allow` to determine if Clippy should run on the code, but ignores possible `--force-warn` arguments

---

changelog: Others: Allowing all lints and only `--force-warn`ing some will now work with Clippy's driver

2 years agoAuto merge of #8953 - DevAccentor:slow_vector_initialization, r=Manishearth
bors [Thu, 23 Jun 2022 22:29:52 +0000 (22:29 +0000)]
Auto merge of #8953 - DevAccentor:slow_vector_initialization, r=Manishearth

add vec.capacity() to [`slow_vec_initialization`] detection

fix #8800

for example
```rust
let mut vec1 = Vec::with_capacity(len);
vec1.resize(vec1.capacity(), 0);

let mut vec2 = Vec::with_capacity(len);
vec2.extend(repeat(0).take(vec2.capacity()));
```
will trigger the lint

---

changelog: add `vec.capacity()` to [`slow_vec_initialization`] detection

2 years agoAdd external macro guard and test middle MSRV
Evan Typanski [Thu, 23 Jun 2022 20:34:52 +0000 (16:34 -0400)]
Add external macro guard and test middle MSRV

2 years agoSplit constant check functions and simplify
Evan Typanski [Thu, 23 Jun 2022 14:35:14 +0000 (10:35 -0400)]
Split constant check functions and simplify

2 years agoCheck for `--force-warn` in Clippy's driver run condition
xFrednet [Thu, 23 Jun 2022 07:44:53 +0000 (09:44 +0200)]
Check for `--force-warn` in Clippy's driver run condition

2 years agoFix `extra_unused_lifetimes` false positive
Samuel E. Moelius III [Tue, 21 Jun 2022 09:18:27 +0000 (05:18 -0400)]
Fix `extra_unused_lifetimes` false positive

2 years agoAuto merge of #9034 - alex-semenyuk:example_vec_resize_to_zero, r=giraffate
bors [Wed, 22 Jun 2022 23:59:16 +0000 (23:59 +0000)]
Auto merge of #9034 - alex-semenyuk:example_vec_resize_to_zero, r=giraffate

Example for VEC_RESIZE_TO_ZERO

changelog: none

Example for VEC_RESIZE_TO_ZERO - what we should use instead

2 years agoAuto merge of #9028 - kyoto7250:issue_8798, r=xFrednet
bors [Wed, 22 Jun 2022 22:35:21 +0000 (22:35 +0000)]
Auto merge of #9028 - kyoto7250:issue_8798, r=xFrednet

confirm  using chain in collapsible_span_lint_calls

close #8798

This PR fixes false positive when using chain in `collapsible_span_lint_calls`.

changelog: None

2 years agoAuto merge of #9026 - hellow554:neg_multiply_precedence, r=xFrednet
bors [Wed, 22 Jun 2022 22:18:08 +0000 (22:18 +0000)]
Auto merge of #9026 - hellow554:neg_multiply_precedence, r=xFrednet

put parentheses around neg_multiply suggestion if needed

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

changelog: [`neg_multiply`]: put parentheses around suggestion if needed

2 years agoSimplify with let else
Evan Typanski [Wed, 22 Jun 2022 19:26:08 +0000 (15:26 -0400)]
Simplify with let else

2 years agoAdd MSRV check for const rem_euclid
Evan Typanski [Wed, 22 Jun 2022 18:17:52 +0000 (14:17 -0400)]
Add MSRV check for const rem_euclid

2 years agoFix case for function params
Evan Typanski [Wed, 22 Jun 2022 18:08:47 +0000 (14:08 -0400)]
Fix case for function params

2 years agoPrefer if let chain over macro
Evan Typanski [Wed, 22 Jun 2022 17:31:04 +0000 (13:31 -0400)]
Prefer if let chain over macro

2 years agoFix case where rem was considered commutative
Evan Typanski [Wed, 22 Jun 2022 17:26:13 +0000 (13:26 -0400)]
Fix case where rem was considered commutative

2 years agoPrefer `.ok()?` over `.unwrap()`
Evan Typanski [Wed, 22 Jun 2022 17:15:35 +0000 (13:15 -0400)]
Prefer `.ok()?` over `.unwrap()`

2 years agoExample for VEC_RESIZE_TO_ZERO
alexey semenyuk [Wed, 22 Jun 2022 11:01:52 +0000 (11:01 +0000)]
Example for VEC_RESIZE_TO_ZERO

2 years agoAuto merge of #9030 - Serial-ATA:remove-clippy-dev-dep, r=flip1995
bors [Wed, 22 Jun 2022 08:02:54 +0000 (08:02 +0000)]
Auto merge of #9030 - Serial-ATA:remove-clippy-dev-dep, r=flip1995

Remove `cargo_dev` dependency

changelog: none

Sorry about that :sweat_smile:.

r? `@flip1995`

2 years agoAuto merge of #9017 - alex-semenyuk:while_let_on_iterator_doc_fix, r=giraffate
bors [Wed, 22 Jun 2022 00:01:49 +0000 (00:01 +0000)]
Auto merge of #9017 - alex-semenyuk:while_let_on_iterator_doc_fix, r=giraffate

Example for `WHILE_LET_ON_ITERATOR`

changelog: none

example for `WHILE_LET_ON_ITERATOR`, using `for` instead of `while let`

2 years agoFix case where suggestion errored for infer type
Evan Typanski [Tue, 21 Jun 2022 20:41:36 +0000 (16:41 -0400)]
Fix case where suggestion errored for infer type

2 years agoImplement manual_rem_euclid lint
Evan Typanski [Tue, 21 Jun 2022 18:13:15 +0000 (14:13 -0400)]
Implement manual_rem_euclid lint

2 years agoRemove `cargo_dev` dependency
Serial [Tue, 21 Jun 2022 18:04:37 +0000 (14:04 -0400)]
Remove `cargo_dev` dependency

2 years ago`For` example should be used instead `while` in WHILE_LET_ON_ITERATOR
alexey semenyuk [Sat, 18 Jun 2022 19:42:39 +0000 (19:42 +0000)]
`For` example should be used instead `while` in WHILE_LET_ON_ITERATOR

`For` example should be used instead `while` in WHILE_LET_ON_ITERATOR

For example should be used instead while in WHILE_LET_ON_ITERATOR

Revert some changes

Fix cargo dev fmt

2 years agoput parentheses around neg_multiply suggestion if needed
Marcel Hellwig [Mon, 20 Jun 2022 21:44:18 +0000 (23:44 +0200)]
put parentheses around neg_multiply suggestion if needed

2 years agoAuto merge of #9006 - kyoto7250:issue-8836-v2, r=Jarcho
bors [Mon, 20 Jun 2022 15:08:32 +0000 (15:08 +0000)]
Auto merge of #9006 - kyoto7250:issue-8836-v2, r=Jarcho

feat(fix): ignore `todo!` and `unimplemented!` in `if_same_then_else`

close: #8836
take over:  #8853

This PR adds  check `todo!` and `unimplemented!` in if_same_then_else.
( I thought `unimplemented` should not be checked as well as todo!.)

Thank you in advance.

changelog: ignore todo! and unimplemented! in if_same_then_else

r? `@Jarcho`

2 years agoAuto merge of #9025 - Alexendoo:unused-async-method, r=dswij
bors [Mon, 20 Jun 2022 13:10:52 +0000 (13:10 +0000)]
Auto merge of #9025 - Alexendoo:unused-async-method, r=dswij

unused_async: lint async methods

Now lints:

```rust
impl Foo {
    async fn method(&self) -> &'static str {
        "no await here"
    }
}
```

changelog: [`unused_async`]: lint async methods

Fixes #9024

2 years agounused_async: lint async methods
Alex Macleod [Mon, 20 Jun 2022 12:03:27 +0000 (12:03 +0000)]
unused_async: lint async methods

2 years agoAuto merge of #9023 - unvalley:add-meta-tag-for-lint-list, r=xFrednet
bors [Mon, 20 Jun 2022 10:16:08 +0000 (10:16 +0000)]
Auto merge of #9023 - unvalley:add-meta-tag-for-lint-list, r=xFrednet

Add description meta tag for lint list

closes #8975

changelog:none

2 years agoconfirm using chain in collapsible_span_lint_calls
kyoto7250 [Mon, 20 Jun 2022 04:17:54 +0000 (13:17 +0900)]
confirm  using chain in collapsible_span_lint_calls

2 years agocheck macro in HitEqInterExpr
kyoto7250 [Mon, 20 Jun 2022 02:14:52 +0000 (11:14 +0900)]
check macro in HitEqInterExpr

2 years agocheck last statement
kyoto7250 [Mon, 20 Jun 2022 02:05:40 +0000 (11:05 +0900)]
check last statement

2 years agoAuto merge of #9016 - Alexendoo:needless-return-test, r=giraffate
bors [Mon, 20 Jun 2022 00:43:06 +0000 (00:43 +0000)]
Auto merge of #9016 - Alexendoo:needless-return-test, r=giraffate

Use `RefCell` in `needless_return` tests

changelog: none

The stdio locks no longer fail to compile if the `return` is removed due to them now being `'static` (#9008)

2 years agoAdd description meta tag for lint list
unvalley [Sun, 19 Jun 2022 15:19:08 +0000 (00:19 +0900)]
Add description meta tag for lint list

2 years agoUse RefCell in needless_return tests
Alex Macleod [Sat, 18 Jun 2022 16:36:47 +0000 (16:36 +0000)]
Use RefCell in needless_return tests

2 years agoignore item in thread_local!
kyoto7250 [Thu, 16 Jun 2022 14:19:46 +0000 (23:19 +0900)]
ignore item in thread_local!

2 years agocargo dev fmt
kyoto7250 [Sat, 18 Jun 2022 09:29:39 +0000 (18:29 +0900)]
cargo dev fmt

2 years agocheck macro in eq_block
kyoto7250 [Sat, 18 Jun 2022 09:24:39 +0000 (18:24 +0900)]
check macro in eq_block

2 years agocheck only first statement
kyoto7250 [Sat, 18 Jun 2022 08:49:03 +0000 (17:49 +0900)]
check only first statement

2 years agocheck macro_backtrace only
kyoto7250 [Sat, 18 Jun 2022 08:41:26 +0000 (17:41 +0900)]
check macro_backtrace only

2 years agoAuto merge of #8989 - kyoto7250:default_iter_empty, r=Alexendoo
bors [Fri, 17 Jun 2022 21:06:09 +0000 (21:06 +0000)]
Auto merge of #8989 - kyoto7250:default_iter_empty, r=Alexendoo

feat(lint): add default_iter_empty

close #8915

This PR adds `default_iter_empty` lint.

This lint checks `std::iter::Empty::default()` and replace with `std::iter::empty()`.

Thank you in advance.

---

changelog: add `default_instead_of_iter_empty` lint.

2 years agocheck only the end
kyoto7250 [Fri, 17 Jun 2022 15:19:30 +0000 (00:19 +0900)]
check only the end

2 years agofeat(lint): add default_iter_empty
kyoto7250 [Sun, 12 Jun 2022 12:30:55 +0000 (21:30 +0900)]
feat(lint): add default_iter_empty

Update description in clippy_lints/src/default_iter_empty.rs

Co-authored-by: Fridtjof Stoldt <xFrednet@gmail.com>
Update clippy_lints/src/default_iter_empty.rs

Co-authored-by: Alex Macleod <alex@macleod.io>
Update clippy_lints/src/default_iter_empty.rs

Co-authored-by: Alex Macleod <alex@macleod.io>
renamed default_iter_empty to default_instead_of_iter_empty

Avoid duplicate messages

add tests for regression

rewrite 'Why is this bad?'

cargo dev fmt

delete default_iter_empty lint in renamed_lint.rs

rewrite a message in the suggestion

cargo dev update_lints --check

2 years agouse get_diagnostic_name for checking macro_call
kyoto7250 [Fri, 17 Jun 2022 01:10:40 +0000 (10:10 +0900)]
use get_diagnostic_name for checking macro_call

2 years agoAuto merge of #9007 - flip1995:rustup, r=flip1995
bors [Thu, 16 Jun 2022 14:07:23 +0000 (14:07 +0000)]
Auto merge of #9007 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: none

2 years agoBump nightly version -> 2022-06-16
flip1995 [Thu, 16 Jun 2022 14:04:12 +0000 (16:04 +0200)]
Bump nightly version -> 2022-06-16

2 years agoMerge remote-tracking branch 'upstream/master' into rustup
flip1995 [Thu, 16 Jun 2022 13:33:15 +0000 (15:33 +0200)]
Merge remote-tracking branch 'upstream/master' into rustup

2 years agoAuto merge of #9005 - flip1995:book_ci_2, r=xFrednet
bors [Thu, 16 Jun 2022 12:49:20 +0000 (12:49 +0000)]
Auto merge of #9005 - flip1995:book_ci_2, r=xFrednet

Build mdbook in remark workflow

r? `@xFrednet`

Supersedes #8959

changelog: none

2 years agofeat(fix): ignore todo! and unimplemented! in if_same_then_else
kyoto7250 [Thu, 16 Jun 2022 12:29:43 +0000 (21:29 +0900)]
feat(fix): ignore todo! and unimplemented! in if_same_then_else

2 years agoBuild mdbook in remark workflow
flip1995 [Thu, 16 Jun 2022 12:10:35 +0000 (14:10 +0200)]
Build mdbook in remark workflow

This is just to ensure that the book builds all time to not get in trouble when syncing with rust-lang/rust

2 years agoAuto merge of #9002 - andylizi:fix-never-loop, r=Manishearth
bors [Wed, 15 Jun 2022 18:36:32 +0000 (18:36 +0000)]
Auto merge of #9002 - andylizi:fix-never-loop, r=Manishearth

Fix false positive for `never_loop` struct expression fields

Fixes #9001.

changelog: [`never_loop`]: Now checks for `continue` in struct expression

2 years agoIgnore bodies containing `todo!()` in `clippy::if_same_then_else`
Dany Marcoux [Wed, 18 May 2022 18:28:11 +0000 (20:28 +0200)]
Ignore bodies containing `todo!()` in `clippy::if_same_then_else`

2 years agoRollup merge of #98110 - cjgillot:closure-brace, r=Aaron1011
Yuki Okushi [Wed, 15 Jun 2022 10:37:14 +0000 (19:37 +0900)]
Rollup merge of #98110 - cjgillot:closure-brace, r=Aaron1011

Make `ExprKind::Closure` a struct variant.

Simple refactor since we both need it to introduce additional fields in `ExprKind::Closure`.

r? ``@Aaron1011``

2 years agoFix false positive for `never_loop` struct expression fields
andylizi [Wed, 15 Jun 2022 09:54:43 +0000 (17:54 +0800)]
Fix false positive for `never_loop` struct expression fields

2 years agoAuto merge of #8964 - tamaroning:read_zero_byte_vec, r=dswij
bors [Wed, 15 Jun 2022 06:16:14 +0000 (06:16 +0000)]
Auto merge of #8964 - tamaroning:read_zero_byte_vec, r=dswij

Warn about read into zero-length `Vec`

Closes #8886

- \[x] Followed [lint naming conventions][lint_naming]
- \[x] Added passing UI tests (including committed `.stderr` file)
- \[x] `cargo test` passes locally
- \[x] Executed `cargo dev update_lints`
- \[x] Added lint documentation
- \[x] Run `cargo dev fmt`

changelog: none

2 years agoAuto merge of #8999 - Alexendoo:error-pattern, r=xFrednet
bors [Tue, 14 Jun 2022 16:54:13 +0000 (16:54 +0000)]
Auto merge of #8999 - Alexendoo:error-pattern, r=xFrednet

Remove error-pattern comments

The `clippy_lints` one [is unused](https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/.60error-pattern.60), the others in `ui-toml` also appear not to have an effect

changelog: none

2 years agoRemove error-pattern comments
Alex Macleod [Tue, 14 Jun 2022 16:28:34 +0000 (16:28 +0000)]
Remove error-pattern comments

2 years agoadd lint
tamaron [Mon, 6 Jun 2022 13:48:05 +0000 (22:48 +0900)]
add lint

2 years agofix wrong evaluation in clippy
b-naber [Fri, 3 Jun 2022 19:41:01 +0000 (21:41 +0200)]
fix wrong evaluation in clippy

2 years agoaddress review
b-naber [Fri, 3 Jun 2022 18:42:35 +0000 (20:42 +0200)]
address review

2 years agofix clippy test failures
b-naber [Thu, 2 Jun 2022 13:15:01 +0000 (15:15 +0200)]
fix clippy test failures

2 years agoimplement valtrees as the type-system representation for constant values
b-naber [Wed, 16 Feb 2022 09:56:01 +0000 (10:56 +0100)]
implement valtrees as the type-system representation for constant values

2 years agoAuto merge of #8947 - Serial-ATA:lint-produces-output, r=xFrednet
bors [Tue, 14 Jun 2022 10:42:09 +0000 (10:42 +0000)]
Auto merge of #8947 - Serial-ATA:lint-produces-output, r=xFrednet

Add lint output to lint list

changelog: Add the ability to show the lint output in the lint list

This just adds the logic to produce the output, it hasn't been added to any lints yet. It did help find some mistakes in some docs though :smile:.

### Screenshots

<details>
<summary>A single code block</summary>

![single-code-block](https://user-images.githubusercontent.com/69764315/172013766-145b22b1-1d91-4fb8-9cd0-b967a52d6330.png)
</details>

<details>
<summary>A single code block with a "Use instead" section</summary>

![with-usage](https://user-images.githubusercontent.com/69764315/172013792-d2dd6c9c-defa-41e0-8c27-8e8e311adb63.png)
</details>

<details>
<summary>Multiple code blocks</summary>

![multi-code-block](https://user-images.githubusercontent.com/69764315/172013808-5328f59b-e7c5-4914-a396-253822a6d350.png)
</details>

This is the last task in #7172 :tada:.
r? `@xFrednet` (?)

2 years agoAuto merge of #8901 - Jarcho:sharing_code, r=dswij
bors [Tue, 14 Jun 2022 08:59:40 +0000 (08:59 +0000)]
Auto merge of #8901 - Jarcho:sharing_code, r=dswij

Rework `branches_sharing_code`

fixes #7378

This changes the lint from checking pairs of blocks, to checking all the blocks at the same time. As such there's almost none of the original code left.

changelog: Don't lint `branches_sharing_code` when using different binding names

2 years agoAuto merge of #8997 - Jarcho:clap_deprecate, r=flip1995
bors [Tue, 14 Jun 2022 08:33:52 +0000 (08:33 +0000)]
Auto merge of #8997 - Jarcho:clap_deprecate, r=flip1995

Fix `clap` deprecation warnings

Clap `3.2.0` deprecated a few functions used by lintcheck.

changelog: None

2 years agoRename the `ConstS::val` field as `kind`.
Nicholas Nethercote [Fri, 10 Jun 2022 01:18:06 +0000 (11:18 +1000)]
Rename the `ConstS::val` field as `kind`.

And likewise for the `Const::val` method.

Because its type is called `ConstKind`. Also `val` is a confusing name
because `ConstKind` is an enum with seven variants, one of which is
called `Value`. Also, this gives consistency with `TyS` and `PredicateS`
which have `kind` fields.

The commit also renames a few `Const` variables from `val` to `c`, to
avoid confusion with the `ConstKind::Value` variant.

2 years agoFix `clap` deprecation warnings
Jason Newcomb [Tue, 14 Jun 2022 01:10:30 +0000 (21:10 -0400)]
Fix `clap` deprecation warnings

2 years agoAuto merge of #8988 - xFrednet:8947-test-monster-in-bors-ci, r=flip1995
bors [Mon, 13 Jun 2022 08:21:54 +0000 (08:21 +0000)]
Auto merge of #8988 - xFrednet:8947-test-monster-in-bors-ci, r=flip1995

Test metadata collection in Bors CI workflow

This PR adds a new check to bors CI workflows, which ensures that the metadata collection success, when it's run as part of the `deploy` script. I've only added it to bors workflows, as the runtime will be high while it'll also succeed most of the time. This is a preparation for rust-lang/rust-clippy#8947.

---

changelog: none

r? `@ghost`

2 years agoremove unnecessary `to_string` and `String::new` for `tool_only_span_suggestion`
Takayuki Maeda [Mon, 13 Jun 2022 07:01:16 +0000 (16:01 +0900)]
remove unnecessary `to_string` and `String::new` for `tool_only_span_suggestion`

2 years agoremove unnecessary `to_string` and `String::new`
Takayuki Maeda [Mon, 13 Jun 2022 06:48:40 +0000 (15:48 +0900)]
remove unnecessary `to_string` and `String::new`

2 years agoAuto merge of #8983 - Alexendoo:redundant_closure_tests, r=giraffate
bors [Mon, 13 Jun 2022 00:14:31 +0000 (00:14 +0000)]
Auto merge of #8983 - Alexendoo:redundant_closure_tests, r=giraffate

Add tests for some fixed `redundant_closure` issues

closes #7861
closes #5939

changelog: none

2 years agoTest metadata collection in Bors CI workflow
xFrednet [Sun, 12 Jun 2022 13:51:00 +0000 (15:51 +0200)]
Test metadata collection in Bors CI workflow

2 years agoMake `ExprKind::Closure` a struct variant.
Camille GILLOT [Sat, 11 Jun 2022 19:25:25 +0000 (21:25 +0200)]
Make `ExprKind::Closure` a struct variant.

2 years agoAdd tests for some fixed redundant_closure issues
Alex Macleod [Fri, 10 Jun 2022 13:25:22 +0000 (13:25 +0000)]
Add tests for some fixed redundant_closure issues

2 years agoAuto merge of #8976 - xFrednet:rust-97660-catch-emissions-with-expect, r=Jarcho
bors [Thu, 9 Jun 2022 22:28:36 +0000 (22:28 +0000)]
Auto merge of #8976 - xFrednet:rust-97660-catch-emissions-with-expect, r=Jarcho

Fix some `#[expect]` lint interaction

Fixing the first few lints that aren't caught by `#[expect]`. The root cause of these examples was, that the lint was emitted at the wrong location.

---

changelog: none

r? `@Jarcho`

cc: rust-lang/rust#97660

2 years agoAuto merge of #8979 - Alexendoo:version-numbers, r=flip1995
bors [Thu, 9 Jun 2022 14:02:36 +0000 (14:02 +0000)]
Auto merge of #8979 - Alexendoo:version-numbers, r=flip1995

Correct some `#[clippy::version]`s

Some were a bit off

changelog: none

2 years agoCorrect some `#[clippy::version]`s
Alex Macleod [Thu, 9 Jun 2022 13:43:26 +0000 (13:43 +0000)]
Correct some `#[clippy::version]`s

2 years agoAuto merge of #8954 - Serial-ATA:doc-comment-issues, r=xFrednet
bors [Thu, 9 Jun 2022 11:03:49 +0000 (11:03 +0000)]
Auto merge of #8954 - Serial-ATA:doc-comment-issues, r=xFrednet

Improve lint doc consistency

changelog: none

This is a continuation of #8908.

Notable changes:
- Removed empty `Known Problems` sections
- Removed "Good"/"Bad" language (replaced with "Use instead")
- Removed (and added some :smile:) duplication
- Ignored the [`create_dir`] example so it doesn't create `clippy_lints/foo` :smile:

2 years agoFix [`needless_bool`] example
Serial [Thu, 9 Jun 2022 10:54:01 +0000 (06:54 -0400)]
Fix [`needless_bool`] example

2 years agoFix `#[expect]` for `default_numeric_fallback`
xFrednet [Thu, 9 Jun 2022 07:17:46 +0000 (09:17 +0200)]
Fix `#[expect]` for `default_numeric_fallback`

2 years agoAuto merge of #8907 - kyoto7250:fix_8898, r=giraffate
bors [Thu, 9 Jun 2022 00:04:09 +0000 (00:04 +0000)]
Auto merge of #8907 - kyoto7250:fix_8898, r=giraffate

fix(lint): check const context

close: https://github.com/rust-lang/rust-clippy/issues/8898

This PR fixes a bug in checked_conversions.

Thank you in advance.

changelog: check const context in checked_conversions.

2 years agoAuto merge of #8950 - Jarcho:derive_non_pub, r=dswij
bors [Wed, 8 Jun 2022 14:03:50 +0000 (14:03 +0000)]
Auto merge of #8950 - Jarcho:derive_non_pub, r=dswij

Fixes for `derive_partial_eq_without_eq`

fixes  #8875

changelog: Don't lint `derive_partial_eq_without_eq` on non-public types
changelog: Better handle generics in `derive_partial_eq_without_eq`

2 years agoAuto merge of #8960 - Jarcho:iter_cloned, r=giraffate
bors [Wed, 8 Jun 2022 00:41:05 +0000 (00:41 +0000)]
Auto merge of #8960 - Jarcho:iter_cloned, r=giraffate

Changes to `iter_overeager_cloned`

fixes: #8494

changelog: Don't lint `iter_overeager_cloned` on `.cloned().flatten()` when `T::Item` doesn't implement `IntoIterator`

2 years agoFolding revamp.
Nicholas Nethercote [Thu, 2 Jun 2022 01:38:15 +0000 (11:38 +1000)]
Folding revamp.

This commit makes type folding more like the way chalk does it.

Currently, `TypeFoldable` has `fold_with` and `super_fold_with` methods.
- `fold_with` is the standard entry point, and defaults to calling
  `super_fold_with`.
- `super_fold_with` does the actual work of traversing a type.
- For a few types of interest (`Ty`, `Region`, etc.) `fold_with` instead
  calls into a `TypeFolder`, which can then call back into
  `super_fold_with`.

With the new approach, `TypeFoldable` has `fold_with` and
`TypeSuperFoldable` has `super_fold_with`.
- `fold_with` is still the standard entry point, *and* it does the
  actual work of traversing a type, for all types except types of
  interest.
- `super_fold_with` is only implemented for the types of interest.

Benefits of the new model.
- I find it easier to understand. The distinction between types of
  interest and other types is clearer, and `super_fold_with` doesn't
  exist for most types.
- With the current model is easy to get confused and implement a
  `super_fold_with` method that should be left defaulted. (Some of the
  precursor commits fixed such cases.)
- With the current model it's easy to call `super_fold_with` within
  `TypeFolder` impls where `fold_with` should be called. The new
  approach makes this mistake impossible, and this commit fixes a number
  of such cases.
- It's potentially faster, because it avoids the `fold_with` ->
  `super_fold_with` call in all cases except types of interest. A lot of
  the time the compile would inline those away, but not necessarily
  always.

2 years agoHide unnecessary code in [`implicit_saturating_sub`]
Serial [Tue, 7 Jun 2022 22:51:45 +0000 (18:51 -0400)]
Hide unnecessary code in [`implicit_saturating_sub`]

2 years agoAuto merge of #95565 - jackh726:remove-borrowck-mode, r=nikomatsakis
bors [Tue, 7 Jun 2022 05:04:14 +0000 (05:04 +0000)]
Auto merge of #95565 - jackh726:remove-borrowck-mode, r=nikomatsakis

Remove migrate borrowck mode

Closes #58781
Closes #43234

# Stabilization proposal

This PR proposes the stabilization of `#![feature(nll)]` and the removal of `-Z borrowck`. Current borrow checking behavior of item bodies is currently done by first infering regions *lexically* and reporting any errors during HIR type checking. If there *are* any errors, then MIR borrowck (NLL) never occurs. If there *aren't* any errors, then MIR borrowck happens and any errors there would be reported. This PR removes the lexical region check of item bodies entirely and only uses MIR borrowck. Because MIR borrowck could never *not* be run for a compiled program, this should not break any programs. It does, however, change diagnostics significantly and allows a slightly larger set of programs to compile.

Tracking issue: #43234
RFC: https://github.com/rust-lang/rfcs/blob/master/text/2094-nll.md
Version: 1.63 (2022-06-30 => beta, 2022-08-11 => stable).

## Motivation

Over time, the Rust borrow checker has become "smarter" and thus allowed more programs to compile. There have been three different implementations: AST borrowck, MIR borrowck, and polonius (well, in progress). Additionally, there is the "lexical region resolver", which (roughly) solves the constraints generated through HIR typeck. It is not a full borrow checker, but does emit some errors.

The AST borrowck was the original implementation of the borrow checker and was part of the initially stabilized Rust 1.0. In mid 2017, work began to implement the current MIR borrow checker and that effort ompleted by the end of 2017, for the most part. During 2018, efforts were made to migrate away from the AST borrow checker to the MIR borrow checker - eventually culminating into "migrate" mode - where HIR typeck with lexical region resolving following by MIR borrow checking - being active by default in the 2018 edition.

In early 2019, migrate mode was turned on by default in the 2015 edition as well, but with MIR borrowck errors emitted as warnings. By late 2019, these warnings were upgraded to full errors. This was followed by the complete removal of the AST borrow checker.

In the period since, various errors emitted by the MIR borrow checker have been improved to the point that they are mostly the same or better than those emitted by the lexical region resolver.

While there do remain some degradations in errors (tracked under the [NLL-diagnostics tag](https://github.com/rust-lang/rust/issues?q=is%3Aopen+is%3Aissue+label%3ANLL-diagnostics), those are sufficiently small and rare enough that increased flexibility of MIR borrow check-only is now a worthwhile tradeoff.

## What is stabilized

As said previously, this does not fundamentally change the landscape of accepted programs. However, there are a [few](https://github.com/rust-lang/rust/issues?q=is%3Aopen+is%3Aissue+label%3ANLL-fixed-by-NLL) cases where programs can compile under `feature(nll)`, but not otherwise.

There are two notable patterns that are "fixed" by this stabilization. First, the `scoped_threads` feature, which is a continutation of a pre-1.0 API, can sometimes emit a [weird lifetime error](https://github.com/rust-lang/rust/issues/95527) without NLL. Second, actually seen in the standard library. In the `Extend` impl for `HashMap`, there is an implied bound of `K: 'a` that is available with NLL on but not without - this is utilized in the impl.

As mentioned before, there are a large number of diagnostic differences. Most of them are better, but some are worse. None are serious or happen often enough to need to block this PR. The biggest change is the loss of error code for a number of lifetime errors in favor of more general "lifetime may not live long enough" error. While this may *seem* bad, the former error codes were just attempts to somewhat-arbitrarily bin together lifetime errors of the same type; however, on paper, they end up being roughly the same with roughly the same kinds of solutions.

## What isn't stabilized

This PR does not completely remove the lexical region resolver. In the future, it may be possible to remove that (while still keeping HIR typeck) or to remove it together with HIR typeck.

## Tests

Many test outputs get updated by this PR. However, there are number of tests specifically geared towards NLL under `src/test/ui/nll`

## History

* On 2017-07-14, [tracking issue opened](https://github.com/rust-lang/rust/issues/43234)
* On 2017-07-20, [initial empty MIR pass added](https://github.com/rust-lang/rust/pull/43271)
* On 2017-08-29, [RFC opened](https://github.com/rust-lang/rfcs/pull/2094)
* On 2017-11-16, [Integrate MIR type-checker with NLL](https://github.com/rust-lang/rust/pull/45825)
* On 2017-12-20, [NLL feature complete](https://github.com/rust-lang/rust/pull/46862)
* On 2018-07-07, [Don't run AST borrowck on mir mode](https://github.com/rust-lang/rust/pull/52083)
* On 2018-07-27, [Add migrate mode](https://github.com/rust-lang/rust/pull/52681)
* On 2019-04-22, [Enable migrate mode on 2015 edition](https://github.com/rust-lang/rust/pull/59114)
* On 2019-08-26, [Don't downgrade errors on 2015 edition](https://github.com/rust-lang/rust/pull/64221)
* On 2019-08-27, [Remove AST borrowck](https://github.com/rust-lang/rust/pull/64790)

2 years agoChanges to `iter_overeager_cloned`
Jason Newcomb [Tue, 7 Jun 2022 04:40:32 +0000 (00:40 -0400)]
Changes to `iter_overeager_cloned`
* Don't lint on `.cloned().flatten()` when `T::Item` doesn't implement `IntoIterator`
* Reduce verbosity of lint message
* Narrow down the scope of the replacement range

2 years agoSuppress `unused` in doc examples
Serial [Tue, 7 Jun 2022 00:28:16 +0000 (20:28 -0400)]
Suppress `unused` in doc examples

2 years agoAdd lint output to lint list
Serial [Sat, 28 May 2022 19:27:53 +0000 (15:27 -0400)]
Add lint output to lint list

2 years agoRollup merge of #97794 - eltociear:patch-13, r=matthiaskrgr
Matthias Krüger [Mon, 6 Jun 2022 23:13:48 +0000 (01:13 +0200)]
Rollup merge of #97794 - eltociear:patch-13, r=matthiaskrgr

Fix typo in redundant_pattern_match.rs

alway -> always

2 years agoAuto merge of #7359 - joshrotenberg:clippy_guide, r=xFrednet
bors [Mon, 6 Jun 2022 16:53:37 +0000 (16:53 +0000)]
Auto merge of #7359 - joshrotenberg:clippy_guide, r=xFrednet

Clippy book

A work in progress Clippy Book using mdbook. See #6011.

This is currently just a moving around of things:

1. The current README.md split up a bit and put into sections.
1. A rough outline of Clippy lint categories (currently no content, potentially add a basic introduction for each and some example, see questions below.
1. The `docs` content repurposed into a top level `Development` section.
1. The current Roadmap.

Some big questions:

1. is `guide/` the right place? I'm modeling after mdbook itself.
1. What is the relationship between ALL the Clippy Lints and this guide? It seems like they can coexist. Does that mean the guide should just point to the current side with regard to actual lints, and maybe just include some examples to keep it interesting? Keeping both up to date seems like a maintenance nightmare unless its automated somehow. Or should the current ALL the Clippy lints somehow be incorporated into the book?
1. Related to the above, where should this guide be published since the `gh-pages` branch is already in use?
1. This PR doesn't currently change any existing content. Obviously that would make sense assuming the general structure and relocation is an acceptable approach.

---

Open Tasks for follow up PR:
- Set up CI/CD
- Split up Installation and Usage
- Add more content to Usage (and Installation) chapters
- Enhance CI chapter with more examples for different CIs

---

changelog: The first version of the *Clippy Book*
staring, *The Clippy Team*, *Bors* and *rustc*

2 years agoAuto merge of #8944 - xFrednet:8877-append-doc-idents, r=Manishearth
bors [Mon, 6 Jun 2022 16:34:27 +0000 (16:34 +0000)]
Auto merge of #8944 - xFrednet:8877-append-doc-idents, r=Manishearth

List configuration values can now be extended instead of replaced

I've seen some `clippy.toml` files, that have a few additions to the default list of a configuration and then a copy of our default. The list will therefore not be updated, when we add new names. This change should make it simple for new users to append values instead of replacing them.

I'm uncertain if the documentation of the `".."` is apparent. Any suggestions are welcome. I've also check that the lint list displays the examples correctly.

<details>
<summary>Lint list screenshots</summary>

![image](https://user-images.githubusercontent.com/17087237/171999434-393f2f83-09aa-4bab-8b05-bd4973150f27.png)

![image](https://user-images.githubusercontent.com/17087237/171999401-e6942b53-25e6-4b09-89e5-d867c7463156.png)

</details>

---

changelog: enhancement: [`doc_markdown`]: Users can now indicate, that the `doc-valid-idents` should extend the default and not replace it
changelog: enhancement: [`blacklisted-name`]: Users can now indicate, that the `blacklisted-names` should extend the default and not replace it

Closes: #8877
That's it. Have a fantastic weekend to everyone reading this. Here is a cookie :cookie: