]> git.lizzy.rs Git - rust.git/log
rust.git
19 months agoRollup merge of #104006 - flip1995:lang-items-clippy, r=oli-obk
Matthias Krüger [Fri, 18 Nov 2022 13:13:37 +0000 (14:13 +0100)]
Rollup merge of #104006 - flip1995:lang-items-clippy, r=oli-obk

Add variant_name function to `LangItem`

Clippy has an internal lint that checks for the usage of hardcoded def paths and suggests to replace them with a lang or diagnostic item, if possible. This was implemented with a hack, by getting all the variants of the `LangItem` enum and then index into it with the position of the `LangItem` in the `items` list. This is no longer possible, because the `items` list can't be accessed anymore.

Follow up to #103603

cc `@camsteffen`
r? `@oli-obk`

This is blocking the sync between Clippy and Rust. I'm not sure if this is the best solution here, or if I should add a method `items()` to `LanguageItems` and keep the code in Clippy unchanged.

19 months agoAllow manual swap in const fn
koka [Fri, 18 Nov 2022 12:51:43 +0000 (21:51 +0900)]
Allow manual swap in const fn

19 months agoKeep original literal notation in suggestion
koka [Fri, 18 Nov 2022 12:23:16 +0000 (21:23 +0900)]
Keep original literal notation in suggestion

19 months agoAuto merge of #9863 - smoelius:expect-unwrap-used-typo, r=flip1995
bors [Fri, 18 Nov 2022 11:49:47 +0000 (11:49 +0000)]
Auto merge of #9863 - smoelius:expect-unwrap-used-typo, r=flip1995

Fix typo in `expect_used` and `unwrap_used` warning messages

"\`an Option\`" -> "an \`Option\`" and "\`a Result\`" -> "a \`Result\`".

changelog: fix typo in `expect_used` and `unwrap_used` warning messages

19 months agoAuto merge of #9850 - pheki:fix-7499-missing-ref, r=dswij
bors [Fri, 18 Nov 2022 09:43:51 +0000 (09:43 +0000)]
Auto merge of #9850 - pheki:fix-7499-missing-ref, r=dswij

Preserve `ref` on `infallible_destructuring_match` suggestion

Fixes https://github.com/rust-lang/rust-clippy/issues/7499

changelog: [`infallible_destructuring_match`]: Preserve `ref` on suggestion

19 months agoAuto merge of #9858 - DesmondWillowbrook:never_loop, r=dswij
bors [Fri, 18 Nov 2022 09:31:20 +0000 (09:31 +0000)]
Auto merge of #9858 - DesmondWillowbrook:never_loop, r=dswij

`never_loop`: don't emit AlwaysBreaks if it targets a block

ref: https://github.com/rust-lang/rust-clippy/pull/9837#issuecomment-1312788194

The previous fix (#9837) was too simple and ignored all break commands inside a labelled block, regardless of whether their destination was a labelled block or a loop. This fix tracks all the labelled blocks in scope to ensure that only breaks targeting loops are considered.

changelog: [`never_loop`]: prevent false negatives from `breaks` nested in labelled blocks

19 months agoRm diagnostic item, use lang item
Deadbeef [Tue, 5 Jul 2022 16:56:16 +0000 (16:56 +0000)]
Rm diagnostic item, use lang item

19 months agoRollup merge of #104483 - oli-obk:santa-clauses-make-goals, r=compiler-errors
Matthias Krüger [Thu, 17 Nov 2022 21:33:19 +0000 (22:33 +0100)]
Rollup merge of #104483 - oli-obk:santa-clauses-make-goals, r=compiler-errors

Convert predicates into Predicate in the Obligation constructor

instead of having almost all callers do that.

This reduces a bit of boilerplate, and also paves the way for my work towards https://github.com/rust-lang/compiler-team/issues/531 (as it makes it easier to accept both goals and clauses where right now it only accepts predicates).

19 months agoAdd variant_name function to `LangItem`
Philipp Krones [Sat, 5 Nov 2022 14:08:37 +0000 (15:08 +0100)]
Add variant_name function to `LangItem`

Clippy has an internal lint that checks for the usage of hardcoded def
paths and suggests to replace them with a lang or diagnostic item, if
possible. This was implemented with a hack, by getting all the variants
of the `LangItem` enum and then index into it with the position of the
`LangItem` in the `items` list. This is no longer possible, because the
`items` list can't be accessed anymore.

19 months agoFix typo in `expect_used` and `unwrap_used` warning messages
Samuel Moelius [Thu, 17 Nov 2022 14:57:39 +0000 (14:57 +0000)]
Fix typo in `expect_used` and `unwrap_used` warning messages

19 months agoAuto merge of #104170 - cjgillot:hir-def-id, r=fee1-dead
bors [Thu, 17 Nov 2022 07:42:27 +0000 (07:42 +0000)]
Auto merge of #104170 - cjgillot:hir-def-id, r=fee1-dead

Record `LocalDefId` in HIR nodes instead of a side table

This is part of an attempt to remove the `HirId -> LocalDefId` table from HIR.
This attempt is a prerequisite to creation of `LocalDefId` after HIR lowering (https://github.com/rust-lang/rust/pull/96840), by controlling how `def_id` information is accessed.

This first part adds the information to HIR nodes themselves instead of a table.
The second part is https://github.com/rust-lang/rust/pull/103902
The third part will be to make `hir::Visitor::visit_fn` take a `LocalDefId` as last parameter.
The fourth part will be to completely remove the side table.

19 months agoBox `ExprKind::{Closure,MethodCall}`, and `QSelf` in expressions, types, and patterns.
Nicholas Nethercote [Thu, 8 Sep 2022 00:52:51 +0000 (10:52 +1000)]
Box `ExprKind::{Closure,MethodCall}`, and `QSelf` in expressions, types, and patterns.

19 months agoAuto merge of #102944 - nnethercote:ast-Lit-third-time-lucky, r=petrochenkov
bors [Wed, 16 Nov 2022 23:03:14 +0000 (23:03 +0000)]
Auto merge of #102944 - nnethercote:ast-Lit-third-time-lucky, r=petrochenkov

Use `token::Lit` in `ast::ExprKind::Lit`.

Instead of `ast::Lit`.

Literal lowering now happens at two different times. Expression literals are lowered when HIR is crated. Attribute literals are lowered during parsing.

r? `@petrochenkov`

19 months agoAuto merge of #9859 - koka831:no-run-side-effect, r=Manishearth
bors [Wed, 16 Nov 2022 17:32:31 +0000 (17:32 +0000)]
Auto merge of #9859 - koka831:no-run-side-effect, r=Manishearth

Avoid generating files via doctest

When we run `cargo test` in `clippy_lints` directory, it will generate [`foo.txt`](https://github.com/rust-lang/rust-clippy/blob/master/clippy_lints/foo.txt) in the directory.
In order to avoid that, this PR adds `no_run` to rustdoc which contains `File::create`.

changelog: none

19 months agoAvoid generating files via doctest
koka [Wed, 16 Nov 2022 15:02:22 +0000 (00:02 +0900)]
Avoid generating files via doctest

When we run `cargo test` in `clippy_lints` directory, it will generate
`foo.txt` in the directory.
In order to avoid that, add `no_run` to rustdoc which contains
`File::create`.

19 months agoConvert predicates into Predicate in the Obligation constructor
Oli Scherer [Wed, 9 Nov 2022 10:49:28 +0000 (10:49 +0000)]
Convert predicates into Predicate in the Obligation constructor

19 months agocleanup and dedupe CTFE and Miri error reporting
Ralf Jung [Tue, 15 Nov 2022 11:06:20 +0000 (12:06 +0100)]
cleanup and dedupe CTFE and Miri error reporting

19 months agofix clippy suggestions
Kartavya Vashishtha [Wed, 16 Nov 2022 07:45:22 +0000 (13:15 +0530)]
fix clippy suggestions

19 months agoupdate tests
Kartavya Vashishtha [Wed, 16 Nov 2022 06:09:09 +0000 (11:39 +0530)]
update tests

19 months agodon't emit AlwaysBreaks if it targets a block
Kartavya Vashishtha [Wed, 16 Nov 2022 05:31:07 +0000 (11:01 +0530)]
don't emit AlwaysBreaks if it targets a block

Introduced an ignored_ids parameter.
Takes O(n^2) time in the worst case.

Can be changed to collect block ids in first phase,
and then filter with binary search in second.

19 months agoUse `token::Lit` in `ast::ExprKind::Lit`.
Nicholas Nethercote [Mon, 10 Oct 2022 02:40:56 +0000 (13:40 +1100)]
Use `token::Lit` in `ast::ExprKind::Lit`.

Instead of `ast::Lit`.

Literal lowering now happens at two different times. Expression literals
are lowered when HIR is crated. Attribute literals are lowered during
parsing.

This commit changes the language very slightly. Some programs that used
to not compile now will compile. This is because some invalid literals
that are removed by `cfg` or attribute macros will no longer trigger
errors. See this comment for more details:
https://github.com/rust-lang/rust/pull/102944#issuecomment-1277476773

19 months agoExtend `needless_borrowed_reference` to structs and tuples, ignore _
Alex Macleod [Tue, 15 Nov 2022 18:24:18 +0000 (18:24 +0000)]
Extend `needless_borrowed_reference` to structs and tuples, ignore _

19 months agoAuto merge of #9849 - koka831:fix/9748, r=Manishearth
bors [Tue, 15 Nov 2022 09:13:54 +0000 (09:13 +0000)]
Auto merge of #9849 - koka831:fix/9748, r=Manishearth

Allow return types for closures with lifetime binder

fix https://github.com/rust-lang/rust-clippy/issues/9748

changelog: Fix [`unused_unit`] Allow return types for closures with lifetime binder

19 months agoAuto merge of #9570 - nfejzic:lint-unchecked-duration-subtraction, r=llogiq
bors [Tue, 15 Nov 2022 06:09:10 +0000 (06:09 +0000)]
Auto merge of #9570 - nfejzic:lint-unchecked-duration-subtraction, r=llogiq

feat: lint unchecked subtraction of a 'Duration' from an 'Instant'

Hello all, I tried to tackle the open issue #9371 and this is what I came up with.

I have a difficulty currently - some tests are failing:

```
failures:
    [ui] ui/manual_instant_elapsed.rs
```

The `manual_instant_elapsed` is failing because of `Instant::now() - duration` test, this now gets also picked by `unchecked_duration_subtraction` lint.
What is the correct way to proceed in this case? Simply update the `.stderr` file for `manual_instant_elapsed` lint?

changelog: [`unchecked_duration_subtraction`]: Add lint for unchecked subtraction of a `Duration` from an `Instant`.

fixes #9371

19 months agoKeep `ref` on `infallible_destructuring_match` suggestion
Aphek [Tue, 15 Nov 2022 04:57:56 +0000 (01:57 -0300)]
Keep `ref` on `infallible_destructuring_match` suggestion

19 months agoAllow return types for closures with lifetime binder
koka [Tue, 15 Nov 2022 03:58:17 +0000 (12:58 +0900)]
Allow return types for closures with lifetime binder

19 months agodocs: import Instant and Duration in doctests
Nadir Fejzic [Mon, 14 Nov 2022 21:37:25 +0000 (22:37 +0100)]
docs: import Instant and Duration in doctests

19 months agofix: add extract_msrv_attr call to instan_subtraction lint pass
Nadir Fejzic [Mon, 14 Nov 2022 21:25:56 +0000 (22:25 +0100)]
fix: add extract_msrv_attr call to instan_subtraction lint pass

19 months agodocs: update unchecked duration subtraction lint doc
Nadir Fejzic [Mon, 14 Nov 2022 21:08:11 +0000 (22:08 +0100)]
docs: update unchecked duration subtraction lint doc

19 months agochore: update lint version of MANUAL_INSTAN_ELAPSED to 1.65
Nadir Fejzic [Mon, 14 Nov 2022 21:00:09 +0000 (22:00 +0100)]
chore: update lint version of MANUAL_INSTAN_ELAPSED to 1.65

19 months agoAuto merge of #9848 - lukas-code:vec-box, r=Jarcho
bors [Mon, 14 Nov 2022 15:54:45 +0000 (15:54 +0000)]
Auto merge of #9848 - lukas-code:vec-box, r=Jarcho

Fix `vec-box-size-threshold` off-by-one error

The docs for `vec-box-size-threshold` say "The size of the boxed type in bytes, where boxing in a `Vec` is allowed", but previously a boxed type of exactly that size wasn't allowed in `Vec`.

changelog: [`vec_box`]: Fix off-by-one error for `vec-box-size-threshold` configuration.

19 months agofix `vec-box-size-threshold` off-by-one error
Lukas Markeffsky [Mon, 14 Nov 2022 15:06:21 +0000 (16:06 +0100)]
fix `vec-box-size-threshold` off-by-one error

19 months agoFix clippy and rustdoc
Maybe Waffle [Sun, 13 Nov 2022 22:58:20 +0000 (22:58 +0000)]
Fix clippy and rustdoc

please, please, don't match on `Symbol::as_str`s, every time you do,
somewhere in the world another waffle becomes sad...

19 months agoAuto merge of #9837 - DesmondWillowbrook:never_loop, r=dswij
bors [Sun, 13 Nov 2022 15:44:14 +0000 (15:44 +0000)]
Auto merge of #9837 - DesmondWillowbrook:never_loop, r=dswij

fix never_loop false positive

fixes #9831

changelog: [`never_loop`]: fixed false positive on unconditional break in internal labeled block

19 months agoAuto merge of #9829 - hrxi:pr_or_fun_call, r=llogiq
bors [Sun, 13 Nov 2022 14:29:42 +0000 (14:29 +0000)]
Auto merge of #9829 - hrxi:pr_or_fun_call, r=llogiq

Make it clear that `or_fun_call` can be a false-positive

Also move it to nursery so that the false-positives can be dealt with.

CC #8574

changelog: [`or_fun_call`]: Mention false-positives, move to nursery.

19 months agoAuto merge of #9822 - Veykril:unnecessary-safety-doc, r=Jarcho
bors [Sun, 13 Nov 2022 14:18:04 +0000 (14:18 +0000)]
Auto merge of #9822 - Veykril:unnecessary-safety-doc, r=Jarcho

Add `unnecessary_safety_doc` lint

changelog: [`unnecessary_safety_doc`]: Add `unnecessary_safety_doc` lint

fixes https://github.com/rust-lang/rust-clippy/issues/6880

This lint does not trigger for private functions, just like `missing_safety_docs`. Reason for that was implementation simplicity and because I figured asking first would make more sense, so if it should trigger for private functions as well let me know and I'll fix that up as well.

19 months agoStore a LocalDefId in hir::Variant & hir::Field.
Camille GILLOT [Sun, 6 Nov 2022 19:46:55 +0000 (19:46 +0000)]
Store a LocalDefId in hir::Variant & hir::Field.

19 months agoAuto merge of #9698 - kraktus:xc_bool, r=xFrednet
bors [Sun, 13 Nov 2022 09:57:36 +0000 (09:57 +0000)]
Auto merge of #9698 - kraktus:xc_bool, r=xFrednet

 [`fn_params_excessive_bools`] Make it possible to allow the lint at the method level

changelog: FP: [`fn_params_excessive_bools`]: `#[allow]` now works on methods

fix https://github.com/rust-lang/rust-clippy/issues/9687

Tested without committing but `#[allow]`ing now works. Also rewrote the lint to be a late lint while at it :)
r? `@xFrednet`

19 months agoMake it clear that `or_fun_call` can be a false-positive
hrxi [Sat, 12 Nov 2022 21:26:09 +0000 (22:26 +0100)]
Make it clear that `or_fun_call` can be a false-positive

Also move it to nursery so that the false-positives can be dealt with.

CC #8574

19 months agoAuto merge of #9835 - koka831:fix/9035, r=Alexendoo
bors [Sat, 12 Nov 2022 21:07:18 +0000 (21:07 +0000)]
Auto merge of #9835 - koka831:fix/9035, r=Alexendoo

Avoid linting unsized mutable reference

fix https://github.com/rust-lang/rust-clippy/issues/9035

changelog: [`mut_mut`] avoid suggesting to reborrow unsized mutable reference

19 months agoAuto merge of #9836 - koka831:patch-9300, r=Alexendoo
bors [Sat, 12 Nov 2022 20:54:39 +0000 (20:54 +0000)]
Auto merge of #9836 - koka831:patch-9300, r=Alexendoo

Fix is_async_fn to check FnKind::Method

This is a follow-up PR of https://github.com/rust-lang/rust-clippy/pull/9828 to support also async methods.

changelog: [`cognitive_complexity`] support async method

r? `@Alexendoo`

19 months agofix never_loop false positive
Kartavya Vashishtha [Sat, 12 Nov 2022 15:06:30 +0000 (20:36 +0530)]
fix never_loop false positive

on unconditional break to internal labeled block

ref #9831

19 months agoFix is_async_fn to check FnKind::Method
koka [Sat, 12 Nov 2022 13:36:20 +0000 (22:36 +0900)]
Fix is_async_fn to check FnKind::Method

19 months agoAuto merge of #9834 - koka831:refac/manual-is-ascii-check, r=xFrednet
bors [Sat, 12 Nov 2022 11:44:22 +0000 (11:44 +0000)]
Auto merge of #9834 - koka831:refac/manual-is-ascii-check, r=xFrednet

refac: remove unnecessary mutability

refactor `manual_is_ascii_check` lint.

* remove unnecessary mutability
* fix typo

changelog: none

r? `@xFrednet`

19 months agoAvoid lint to unsized mutable reference
koka [Sat, 12 Nov 2022 11:31:25 +0000 (20:31 +0900)]
Avoid lint to unsized mutable reference

19 months agofix: use HasPlaceholders
koka [Sat, 12 Nov 2022 10:15:21 +0000 (19:15 +0900)]
fix: use HasPlaceholders
* remove unnecessary mutability
* fix typo

19 months agoIntroduce `ExprKind::IncludedBytes`
clubby789 [Mon, 31 Oct 2022 18:30:09 +0000 (18:30 +0000)]
Introduce `ExprKind::IncludedBytes`

19 months agoAuto merge of #9662 - ebobrow:result-large-err, r=dswij
bors [Fri, 11 Nov 2022 06:58:59 +0000 (06:58 +0000)]
Auto merge of #9662 - ebobrow:result-large-err, r=dswij

`result_large_err` show largest variants in err msg

fixes #9538

changelog: Sugg: [`result_large_err`]: Now show largest enum variants in error message

19 months agoAuto merge of #9830 - hrxi:pr_bool_to_int_with_if, r=Manishearth
bors [Thu, 10 Nov 2022 19:37:05 +0000 (19:37 +0000)]
Auto merge of #9830 - hrxi:pr_bool_to_int_with_if, r=Manishearth

Make `bool_to_int_with_if` a pedantic lint

In all the cases I've observed, it did not make the code clearer. Using bools as integer is frowned upon in some languages, in others it's simply not possible.

You can find comments on the original pull request #8131 that agree with this point of view.

changelog: [`bool_to_int_with_if`]: Change the categorization to pedantic

19 months agoMake `bool_to_int_with_if` a pedantic lint
hrxi [Thu, 10 Nov 2022 18:42:20 +0000 (19:42 +0100)]
Make `bool_to_int_with_if` a pedantic lint

In all the cases I've observed, it did not make the code clearer. Using
bools as integer is frowned upon in some languages, in others it's
simply not possible.

You can find comments on the original pull request #8131 that agree with
this point of view.

19 months agoAuto merge of #9828 - koka831:fix/9300, r=Alexendoo
bors [Thu, 10 Nov 2022 17:40:46 +0000 (17:40 +0000)]
Auto merge of #9828 - koka831:fix/9300, r=Alexendoo

fix: cognitive_complexity for async fn

fix https://github.com/rust-lang/rust-clippy/issues/9300

changelog: [`cognitive_complexity`] support async fn

19 months agofix: cognitive_complexity for async fn
koka [Thu, 10 Nov 2022 15:14:18 +0000 (00:14 +0900)]
fix: cognitive_complexity for async fn

19 months agofix: update lints
Nadir Fejzic [Thu, 10 Nov 2022 14:55:45 +0000 (15:55 +0100)]
fix: update lints

19 months agofix: remove (redundant) semicolon in lint suggestion
Nadir Fejzic [Tue, 8 Nov 2022 14:04:32 +0000 (15:04 +0100)]
fix: remove (redundant) semicolon in lint suggestion

19 months agofix: add rust-fix annotation to unckd. duration subtr. lint test
Nadir Fejzic [Tue, 8 Nov 2022 09:22:58 +0000 (10:22 +0100)]
fix: add rust-fix annotation to unckd. duration subtr. lint test

19 months agostyle: inline variables in `format!`
Nadir Fejzic [Mon, 7 Nov 2022 21:21:32 +0000 (22:21 +0100)]
style: inline variables in `format!`

19 months agotest: update tests for manual_instant_elapsed lint
Nadir Fejzic [Mon, 7 Nov 2022 20:37:04 +0000 (21:37 +0100)]
test: update tests for manual_instant_elapsed lint

19 months agorefactor: improve code re-use in InstantSubtraction lint pass
Nadir Fejzic [Mon, 7 Nov 2022 20:34:24 +0000 (21:34 +0100)]
refactor: improve code re-use in InstantSubtraction lint pass

19 months agodocs: update docs for unchecked duration subtr. lint
Nadir Fejzic [Mon, 7 Nov 2022 19:59:55 +0000 (20:59 +0100)]
docs: update docs for unchecked duration subtr. lint

19 months agorefactor: lint man. instant elapsed and unch. dur. subtr. in single pass
Nadir Fejzic [Mon, 7 Nov 2022 19:58:49 +0000 (20:58 +0100)]
refactor: lint man. instant elapsed and unch. dur. subtr. in single pass

19 months agostyle: remove `dbg!` call
Nadir Fejzic [Sat, 1 Oct 2022 14:50:56 +0000 (16:50 +0200)]
style: remove `dbg!` call

19 months agodocs: add docs for `unchecked_duration_subtraction` lint
Nadir Fejzic [Sat, 1 Oct 2022 14:50:45 +0000 (16:50 +0200)]
docs: add docs for `unchecked_duration_subtraction` lint

19 months agotest: add tests for 'unchecked_duration_subtraction' lint
Nadir Fejzic [Sat, 1 Oct 2022 14:02:57 +0000 (16:02 +0200)]
test: add tests for 'unchecked_duration_subtraction' lint

19 months agofeat: add and implement unchecked_duration_subtraction lint
Nadir Fejzic [Sat, 1 Oct 2022 13:58:10 +0000 (15:58 +0200)]
feat: add and implement unchecked_duration_subtraction lint

19 months agoAdd `unnecessary_safety_doc` lint
Lukas Wirth [Wed, 9 Nov 2022 15:54:10 +0000 (16:54 +0100)]
Add `unnecessary_safety_doc` lint

19 months agoAuto merge of #9813 - Jarcho:issue_9811, r=xFrednet
bors [Wed, 9 Nov 2022 14:06:42 +0000 (14:06 +0000)]
Auto merge of #9813 - Jarcho:issue_9811, r=xFrednet

Fix `explicit_auto_deref` fp

fixes #9763
fixes #9811

changelog: `explicit_auto_deref`: Don't lint when the target type is a projection with generic arguments

19 months agobless clippy
yukang [Wed, 9 Nov 2022 11:23:23 +0000 (19:23 +0800)]
bless clippy

19 months agoAuto merge of #9817 - mgrachev:patch-1, r=Manishearth
bors [Tue, 8 Nov 2022 16:07:32 +0000 (16:07 +0000)]
Auto merge of #9817 - mgrachev:patch-1, r=Manishearth

Update lint example for `collapsible_str_replace`

To fix this warning:
```
warning: the borrowed expression implements the required traits
  --> src/fixes/quote_character.rs:16:43
   |
16 |         let hello = "hesuo worpd".replace(&['s', 'u', 'p'], "l");
   |                                           ^^^^^^^^^^^^^^^^ help: change this to: `['s', 'u', 'p']`
   |
   = note: `#[warn(clippy::needless_borrow)]` on by default
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
```

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

changelog: none

19 months agoAuto merge of #9791 - smoelius:issues-9739-9782, r=Jarcho
bors [Tue, 8 Nov 2022 14:15:40 +0000 (14:15 +0000)]
Auto merge of #9791 - smoelius:issues-9739-9782, r=Jarcho

Address issues 9739 and 9782

This PR fixes #9739 in the manner I suggested in https://github.com/rust-lang/rust-clippy/issues/9739#issuecomment-1296802376.

This PR also fixes the compilation failures in #9782 (but doesn't address `@e00E's` other objections).

Fixes #9739

r? `@Jarcho`

changelog: Fix two `needless_borrow` false positives, one involving borrows in `if`-`else`s, the other involving qualified function calls

19 months agoAuto merge of #9818 - rs017991:patch-1, r=Jarcho
bors [Tue, 8 Nov 2022 13:58:04 +0000 (13:58 +0000)]
Auto merge of #9818 - rs017991:patch-1, r=Jarcho

Fixed Typo

changelog: none

19 months agoFixed Typo
Ryan Scheidter [Tue, 8 Nov 2022 13:48:39 +0000 (07:48 -0600)]
Fixed Typo

19 months agoUpdate lint example for `collapsible_str_replace`
Grachev Mikhail [Tue, 8 Nov 2022 12:33:50 +0000 (15:33 +0300)]
Update lint example for `collapsible_str_replace`

19 months agoAuto merge of #9765 - koka831:feat/manual_is_ascii_check, r=xFrednet
bors [Tue, 8 Nov 2022 09:20:52 +0000 (09:20 +0000)]
Auto merge of #9765 - koka831:feat/manual_is_ascii_check, r=xFrednet

Add `manual_is_ascii_check` lint

Addresses https://github.com/rust-lang/rust-clippy/issues/9290

This PR adds new lint `manual_is_ascii_check`, which detects comparison with ascii ranges using `matches!` macros.

As I mentioned as following in the Issue;
> Yes, that's true. we'll start small and then grow it.
> So I'll try to handle matches! macro with single range as suggested above.

However during writing first version, I was thinking that the changes to support alphabetic and digits will be small patch, so I made a single PR in hope review cost can be reduced.

changelog: add new lint [`manual_is_ascii_check`]

r? `@xFrednet`

19 months ago`result_large_err` show largest variants in err msg
Elliot Bobrow [Sun, 16 Oct 2022 18:37:26 +0000 (11:37 -0700)]
`result_large_err` show largest variants in err msg

19 months agoAuto merge of #8744 - Jarcho:needless_collect_fp, r=llogiq
bors [Mon, 7 Nov 2022 20:47:27 +0000 (20:47 +0000)]
Auto merge of #8744 - Jarcho:needless_collect_fp, r=llogiq

Extend `needless_collect`

Extends when `is_empty` and `contains` are linted.

`is_empty` will be linted when `<IterTy as Iterator>::Item` is the same as `<CollectTy as IntoIterator>::Item`. This can be a false positive if the `FromIterator` implementation filters out items, but I don't know of any which do that also implement `IntoIterator` with a matching `Item` type.

`contains` will be linted when the argument type is `&<IterTy as Iterator>::Item`. It has the same false positives as `is_empty` with the same note that I know of nothing that actually causes that in practice.

changelog: Lint `needless_collect` when `is_empty` or `contains` is called on some non-std types

19 months ago[`excessive_bools`] lint trait functions even without bodies
kraktus [Mon, 7 Nov 2022 20:00:37 +0000 (21:00 +0100)]
[`excessive_bools`] lint trait functions even without bodies

19 months agoDon't lint `explicit_auto_deref` when the target type is a projection containing...
Jason Newcomb [Mon, 7 Nov 2022 19:08:40 +0000 (14:08 -0500)]
Don't lint `explicit_auto_deref` when the target type is a projection containing a generic argument

19 months agoLint `needless_collect` on non-std collection types
Jason Newcomb [Wed, 20 Apr 2022 20:10:18 +0000 (16:10 -0400)]
Lint `needless_collect` on non-std collection types

19 months ago[`fn_params_excessive_bools`] whitelist in signle function in test
kraktus [Sat, 29 Oct 2022 15:43:43 +0000 (17:43 +0200)]
[`fn_params_excessive_bools`] whitelist in signle function in test

19 months ago`excessive_bools`, do not lint in trait impls
kraktus [Sat, 29 Oct 2022 14:12:41 +0000 (16:12 +0200)]
`excessive_bools`, do not lint in trait impls

Should not lint because the trait might not be changeable by the user
We only lint in the trait definition

19 months agodogfood
kraktus [Sun, 23 Oct 2022 14:03:05 +0000 (16:03 +0200)]
dogfood

19 months agorefactor `has_repr_attr`
kraktus [Fri, 28 Oct 2022 12:57:51 +0000 (14:57 +0200)]
refactor `has_repr_attr`

19 months agoRewrite `ExcessiveBools` to be a `LateLintPass` lint
kraktus [Fri, 28 Oct 2022 12:54:59 +0000 (14:54 +0200)]
Rewrite `ExcessiveBools` to be a `LateLintPass` lint

changelog: [`fn_params_excessive_bools`] Make it possible to allow the lint at the method level

19 months agorefactor to avoid potential ICE
kraktus [Sun, 23 Oct 2022 12:00:44 +0000 (14:00 +0200)]
refactor to avoid potential ICE

19 months agoMove `needless_collect` into the `methods` lint pass
Jason Newcomb [Fri, 22 Apr 2022 22:49:15 +0000 (18:49 -0400)]
Move `needless_collect` into the `methods` lint pass

19 months agoAuto merge of #9705 - jntrnr:disable_needless_collect, r=Manishearth
bors [Mon, 7 Nov 2022 17:08:10 +0000 (17:08 +0000)]
Auto merge of #9705 - jntrnr:disable_needless_collect, r=Manishearth

Move needless_collect to nursery

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

changelog: [`needless_collect`]: Move `needless_collect` to nursery (Now allow-by-default)

After chatting with a few folks, it seems like `needless_collect` is giving false positives pretty regularly (https://github.com/rust-lang/rust-clippy/issues?q=is%3Aissue+is%3Aopen+needless_collect). We're big supporters of clippy in Nushell, and it's one of the passes we require for CI, but we've had to disable this particular lint. Perhaps it should be moved to the nursery until it's improved?

(apologies if this isn't the right approach to disabling a lint by default. I tried to follow the idea I saw other PRs doing in the past)

19 months agoAuto merge of #9804 - Alexendoo:coc, r=flip1995
bors [Mon, 7 Nov 2022 08:45:48 +0000 (08:45 +0000)]
Auto merge of #9804 - Alexendoo:coc, r=flip1995

Update CoC to rust-lang/rust's

I spotted mentions of IRC channels that no longer exist when grepping, so this updates it to the same as the one in https://github.com/rust-lang/rust/blob/master/CODE_OF_CONDUCT.md

r? `@flip1995`

changelog: none

19 months agofeat: implement manual_is_ascii_check lint
koka [Mon, 24 Oct 2022 14:49:59 +0000 (23:49 +0900)]
feat: implement manual_is_ascii_check lint

modify

fix: allow unused in test code

fix: types in doc comment

Update clippy_lints/src/manual_is_ascii_check.rs

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

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

Co-authored-by: Fridtjof Stoldt <xFrednet@gmail.com>
fix ui test result

fix: unnecessary format!

chore: apply feedbacks

* check msrvs also for const fn
* check applicability manually
* modify documents

19 months agoAuto merge of #9760 - SquareMan:let_underscore_future, r=llogiq
bors [Sat, 5 Nov 2022 21:34:24 +0000 (21:34 +0000)]
Auto merge of #9760 - SquareMan:let_underscore_future, r=llogiq

Add new lint [`let_underscore_future`]

This closes #9721
---

changelog: add new lint [`let_underscore_future`]

19 months agoUpdate CoC to rust-lang/rust's
Alex Macleod [Sat, 5 Nov 2022 21:03:14 +0000 (21:03 +0000)]
Update CoC to rust-lang/rust's

19 months agoAuto merge of #9797 - trevarj:print-config, r=xFrednet
bors [Sat, 5 Nov 2022 09:49:40 +0000 (09:49 +0000)]
Auto merge of #9797 - trevarj:print-config, r=xFrednet

Add allow-print-in-tests config

Add a config, allow-print-in-tests, that can be set in clippy.toml which allows the usage of `[e]print[ln]!` macros in tests.

Closes #9795

---

changelog: Enhancement: [print_stdout], [print_stderr]: Can now be enabled in test with the `allow-print-in-tests` config value

19 months agoAuto merge of #9799 - bebecue:patch-1, r=dswij
bors [Sat, 5 Nov 2022 07:03:02 +0000 (07:03 +0000)]
Auto merge of #9799 - bebecue:patch-1, r=dswij

Update lint `suspicious_to_owned`

changelog: [`suspicious_to_owned`]: Use explicit type annotation on lint description instead of `matches!`

19 months agoRollup merge of #103660 - ozkanonur:master, r=jyn514
Dylan DPC [Sat, 5 Nov 2022 06:01:28 +0000 (11:31 +0530)]
Rollup merge of #103660 - ozkanonur:master, r=jyn514

improve `filesearch::get_or_default_sysroot`

`fn get_or_default_sysroot` is now improved and used in `miri` and `clippy`, and tests are still passing as they should. So we no longer need to implement custom workarounds/hacks to find sysroot in tools like miri/clippy.

Resolves https://github.com/rust-lang/rust/issues/98832

re-opened from #103581

19 months agoBless all let_underscore tests
Steven Casper [Sat, 5 Nov 2022 04:21:55 +0000 (21:21 -0700)]
Bless all let_underscore tests

19 months agobless
Steven Casper [Sat, 5 Nov 2022 04:09:26 +0000 (21:09 -0700)]
bless

19 months agoMore backticks
Steven Casper [Sat, 5 Nov 2022 03:59:31 +0000 (20:59 -0700)]
More backticks

19 months agoReturn multiple resolutions from `def_path_res`
Alex Macleod [Fri, 4 Nov 2022 21:58:07 +0000 (21:58 +0000)]
Return multiple resolutions from `def_path_res`

19 months agoAuto merge of #9753 - smoelius:changelog, r=xFrednet
bors [Fri, 4 Nov 2022 21:57:46 +0000 (21:57 +0000)]
Auto merge of #9753 - smoelius:changelog, r=xFrednet

Update CONTRIBUTING.md with changelog guidance

`@xFrednet` I cribbed some text of yours from https://github.com/rust-lang/rust-clippy/pull/9743#issuecomment-1295892442 and did some light editing in the hope that others might find it.

r? `@xFrednet`

changelog: Update CONTRIBUTING.md with changelog guidance

19 months agoUpdate lint `suspicious_to_owned`
bebecue [Fri, 4 Nov 2022 20:44:02 +0000 (04:44 +0800)]
Update lint `suspicious_to_owned`

`matches!(data, String)` will matches any type, replace it with explicit type annotation.

20 months agoAdd allow-print-in-tests config
Trevor Arjeski [Fri, 4 Nov 2022 17:33:04 +0000 (20:33 +0300)]
Add allow-print-in-tests config

Add a config, allow-print-in-tests, that can be set in clippy.toml which
allows the usage of `[e]print[ln]!` macros in tests.

Closes #9795