]> git.lizzy.rs Git - rust.git/log
rust.git
2 years ago`innerHTML` -> `textContent`
Serial [Wed, 18 May 2022 19:01:02 +0000 (15:01 -0400)]
`innerHTML` -> `textContent`

2 years agoAdd copy lint name button
Serial [Wed, 18 May 2022 14:19:50 +0000 (10:19 -0400)]
Add copy lint name button

2 years agoAuto merge of #8807 - Jarcho:cmp_owned, r=giraffate
bors [Wed, 18 May 2022 00:19:36 +0000 (00:19 +0000)]
Auto merge of #8807 - Jarcho:cmp_owned, r=giraffate

Fix `cmp_owned` on copy types

fixes #8803
fixes #7365

changelog: Don't lint `cmp_owned` on `From::from` for copy types

2 years agoAuto merge of #8814 - yonip23:add-suggestion-to-rc-clone-in-vec-init, r=xFrednet
bors [Tue, 17 May 2022 05:46:00 +0000 (05:46 +0000)]
Auto merge of #8814 - yonip23:add-suggestion-to-rc-clone-in-vec-init, r=xFrednet

add suggestions to rc_clone_in_vec_init

A followup to https://github.com/rust-lang/rust-clippy/pull/8769
I also switch the order of the 2 suggestions, since the loop initialization one is probably the common case.

`@xFrednet` I'm not letting you guys rest for a minute ðŸ˜…
changelog: add suggestions to [`rc_clone_in_vec_init`]

2 years agoAuto merge of #8835 - Jarcho:let_unit_ice, r=llogiq
bors [Mon, 16 May 2022 19:20:44 +0000 (19:20 +0000)]
Auto merge of #8835 - Jarcho:let_unit_ice, r=llogiq

Fix ICE in `let_unit_value` when calling a static or const callable type

fixes #8821

changelog: Fix ICE in `let_unit_value` when calling a static or const callable type

2 years agoAuto merge of #8752 - Serial-ATA:improve-filtering, r=xFrednet
bors [Mon, 16 May 2022 17:49:00 +0000 (17:49 +0000)]
Auto merge of #8752 - Serial-ATA:improve-filtering, r=xFrednet

Add version filtering option to the lint list

I'm no web dev, so I don't know if this is the best execution :smile:.

Here's how it looks:

![Desktop](https://user-images.githubusercontent.com/69764315/165403602-9e39fe0f-6a96-46cb-ba51-8b035e74cce4.gif)

And on mobile:

![Mobile](https://user-images.githubusercontent.com/69764315/165403908-fc4a0051-2ed4-48a3-b45b-b261f49ce259.png)

I've split this into two commits, in the second one I moved the JS into its own file to make it easier to work on. Is that alright? And if so, could the same thing be done to the css?

changelog: none
cc: #7958, `@repi`
r? `@xFrednet`

2 years agoFix ICE in `let_unit_value` when calling a static or const callable type
Jason Newcomb [Mon, 16 May 2022 14:00:32 +0000 (10:00 -0400)]
Fix ICE in `let_unit_value` when calling a static or const callable type

2 years agoAuto merge of #8761 - tamaroning:fix_8505, r=Jarcho
bors [Mon, 16 May 2022 00:47:10 +0000 (00:47 +0000)]
Auto merge of #8761 - tamaroning:fix_8505, r=Jarcho

`undocumented_unsafe_blocks` does not trigger on unsafe trait impls

Closes #8505

changelog: This lint checks unsafe impls NOT from macro expansions and checks ones in macro declarations.
~~`unsafe impl`s from macro invocations don't trigger the lint for now.~~
~~This lint checks unsafe impls from/not from macro expansions~~

2 years agoAuto merge of #8699 - Jarcho:vec_init_then_push_7071, r=dswij,xFrednet
bors [Sun, 15 May 2022 21:51:24 +0000 (21:51 +0000)]
Auto merge of #8699 - Jarcho:vec_init_then_push_7071, r=dswij,xFrednet

Don't lint `vec_init_then_push` when further extended

fixes #7071

This will still lint when a larger number of pushes are done (four currently). The exact number could be debated, but this is more readable then a sequence of pushes so it shouldn't be too large.

changelog: Don't lint `vec_init_then_push` when further extended.
changelog: Remove `mut` binding from `vec_init_then_push` when possible.

2 years agoUpdate `vec_init_then_push` docs
Jason Newcomb [Sun, 24 Apr 2022 13:46:17 +0000 (09:46 -0400)]
Update `vec_init_then_push` docs

2 years agoAuto merge of #8621 - Jarcho:eval_order_dependence_4637, r=Jarcho
bors [Sun, 15 May 2022 21:36:24 +0000 (21:36 +0000)]
Auto merge of #8621 - Jarcho:eval_order_dependence_4637, r=Jarcho

Rename `eval_order_dependence` to `mixed_read_write_expression`, move to nursery

As per the [reference](https://doc.rust-lang.org/1.51.0/reference/expressions.html#evaluation-order-of-operands) evaluation order is now defined.

I'm pretty sure rust always compiled with this evaluation order anyways so there's no reason the put an msrv limit on the lint.

changelog: Rename `eval_order_dependence` to `mixed_read_write_expression`, move to nursery

2 years agoAdd renamed lints to the changelog link list
Jason Newcomb [Tue, 3 May 2022 15:03:08 +0000 (11:03 -0400)]
Add renamed lints to the changelog link list

2 years agoMove `mixed_read_write_in_expression` into `restriction`
Jason Newcomb [Tue, 3 May 2022 14:58:53 +0000 (10:58 -0400)]
Move `mixed_read_write_in_expression` into `restriction`

2 years agoRename `eval_order_dependence` to `mixed_read_write_in_expression`
Jason Newcomb [Tue, 3 May 2022 14:56:59 +0000 (10:56 -0400)]
Rename `eval_order_dependence` to `mixed_read_write_in_expression`

2 years agoImprove appearance on smaller screens
Serial [Sun, 15 May 2022 16:43:35 +0000 (12:43 -0400)]
Improve appearance on smaller screens

2 years agoUse early returns
Serial [Sun, 15 May 2022 15:30:00 +0000 (11:30 -0400)]
Use early returns

2 years agoAuto merge of #8832 - Alexendoo:duplicate-mod, r=Manishearth
bors [Sun, 15 May 2022 03:52:37 +0000 (03:52 +0000)]
Auto merge of #8832 - Alexendoo:duplicate-mod, r=Manishearth

Add `duplicate_mod` lint

Inspired by #8827, warns if there's a single file that is loaded by more than one `mod` item

```rust,ignore
// lib.rs
mod a;
mod b;
```
```rust,ignore
// a.rs
#[path = "./b.rs"]
mod b;
```

It adds a `canonicalize` call per `mod file;` encountered, which I don't think should be too heavy

Integration tests with common modules, e.g. [`test_utils`](https://github.com/rust-lang/rust-clippy/tree/2038084cf2253b57cf8b405ab000a92b68346f43/tests/test_utils) doesn't trigger it as each test is compiled separately, however I couldn't figure out a good way to add a test for that

changelog: Add [`duplicate_mod`] lint

2 years agoSwitch input to `type=number`; Separate version validation out of `byVersion`
Serial [Sun, 15 May 2022 00:08:10 +0000 (20:08 -0400)]
Switch input to `type=number`; Separate version validation out of `byVersion`

2 years agoAdd `duplicate_mod` lint
Alex Macleod [Sat, 14 May 2022 18:35:16 +0000 (19:35 +0100)]
Add `duplicate_mod` lint

2 years agoAuto merge of #8813 - evantypanski:redundant_alloc_fat_ptr, r=Alexendoo
bors [Fri, 13 May 2022 15:02:58 +0000 (15:02 +0000)]
Auto merge of #8813 - evantypanski:redundant_alloc_fat_ptr, r=Alexendoo

Fix redundant_allocation warning for Rc<Box<str>>

changelog: [`redundant_allocation`] Fixes #8604

Fixes false positives where a fat pointer with `str` type was made thin by another allocation, but that thinning allocation was marked as redundant

2 years agoComment why `hir_ty_to_ty` is safe in `check_ty`
Evan Typanski [Fri, 13 May 2022 09:55:50 +0000 (05:55 -0400)]
Comment why `hir_ty_to_ty` is safe in `check_ty`

2 years agoAuto merge of #8825 - ydah:fix_spelling, r=giraffate
bors [Fri, 13 May 2022 06:03:39 +0000 (06:03 +0000)]
Auto merge of #8825 - ydah:fix_spelling, r=giraffate

Tweak some words improved representation

Hello! Thank you for this awesome project!

This PR has implemented improved representation.

- Use "lib" instead of "lifb"
- Use "triggered" instead of "triggere"
- Use "blacklisted_name" instead of "blackisted_name"
- Use "stabilization" instead of "stabilisation"
- Use "behavior" instead of "behaviour"
- Use "target" instead of "tartet"
- Use "checked_add" instead of "chcked_add"
- Use "anti-pattern" instead of "antipattern"
- Use "suggestion" instead of "suggesttion"
- Use "example" instead of "exampel"
- Use "Cheat Sheet" instead of "Cheatsheet"

---

changelog: none

2 years agoTweak some words improved representation
ydah [Fri, 13 May 2022 05:20:25 +0000 (14:20 +0900)]
Tweak some words improved representation

This PR has implemented improved representation.

- Use "lib" instead of "lifb"
- Use "triggered" instead of "triggere"
- Use "blacklisted_name" instead of "blackisted_name"
- Use "stabilization" instead of "stabilisation"
- Use "behavior" instead of "behaviour"
- Use "target" instead of "tartet"
- Use "checked_add" instead of "chcked_add"
- Use "anti-pattern" instead of "antipattern"
- Use "suggestion" instead of "suggesttion"
- Use "example" instead of "exampel"
- Use "Cheat Sheet" instead of "Cheatsheet"

2 years agoAuto merge of #8799 - Alexendoo:lintcheck-common, r=giraffate
bors [Thu, 12 May 2022 23:56:31 +0000 (23:56 +0000)]
Auto merge of #8799 - Alexendoo:lintcheck-common, r=giraffate

Some lintcheck cleanup

A grab bag of smaller changes:

Panics if a crate source isn't valid, and fixes the `ryu` crate entry so it's picked up. Took me a while to realise why I couldn't do `cargo lintcheck --only ryu` ðŸ˜…

Parses messages with `cargo_metadata`, this catches a few more lints that were ignored because the message had an [expansion field](https://docs.rs/cargo_metadata/latest/cargo_metadata/diagnostic/struct.DiagnosticSpanMacroExpansion.html) that contained a path pointing into `.../.toolchains/...`. It also no longer emits some log lines with `null` as the column

It also merges the `run_clippy_lint` invocations and splits `LintcheckConfig` out into its own file

changelog: none

2 years agoinline construct_lint_suggestions
yonip23 [Thu, 12 May 2022 23:20:28 +0000 (02:20 +0300)]
inline construct_lint_suggestions

2 years agoCatch other thinning allocations using Ty
Evan Typanski [Thu, 12 May 2022 23:06:23 +0000 (19:06 -0400)]
Catch other thinning allocations using Ty

2 years agoSome lintcheck cleanup
Alex Macleod [Sat, 7 May 2022 21:10:56 +0000 (22:10 +0100)]
Some lintcheck cleanup

2 years agofix indentation + test
yonip23 [Thu, 12 May 2022 07:06:15 +0000 (10:06 +0300)]
fix indentation + test

2 years agofix
tamaron [Thu, 12 May 2022 03:33:05 +0000 (12:33 +0900)]
fix

2 years agofix clippy warning
yonip23 [Wed, 11 May 2022 20:16:49 +0000 (23:16 +0300)]
fix clippy warning

2 years agoAuto merge of #8818 - koic:use_rust_2021_prelude, r=flip1995
bors [Wed, 11 May 2022 20:16:42 +0000 (20:16 +0000)]
Auto merge of #8818 - koic:use_rust_2021_prelude, r=flip1995

Use the traits added to the Rust 2021 Edition prelude

Follow up https://github.com/rust-lang/rust/pull/96861.

This PR uses the traits added to the Rust 2021 Edition prelude.

> The `TryInto`, `TryFrom` and `FromIterator` traits are now part of the prelude.

https://doc.rust-lang.org/edition-guide/rust-2021/prelude.html

---

changelog: none

2 years agofix review comments
yonip23 [Wed, 11 May 2022 20:11:52 +0000 (23:11 +0300)]
fix review comments

2 years agoAuto merge of #8726 - Serial-ATA:issue-8723, r=dswij,xFrednet
bors [Wed, 11 May 2022 17:39:25 +0000 (17:39 +0000)]
Auto merge of #8726 - Serial-ATA:issue-8723, r=dswij,xFrednet

Fix `match_single_binding` suggestion for assign expressions

changelog: Fix suggestion for assign expressions in [`match_single_binding`]
closes: #8723

2 years agoUse the traits added to the Rust 2021 Edition prelude
Koichi ITO [Tue, 10 May 2022 16:03:52 +0000 (01:03 +0900)]
Use the traits added to the Rust 2021 Edition prelude

Follow up https://github.com/rust-lang/rust/pull/96861.

This PR uses the traits added to the Rust 2021 Edition prelude.

> The `TryInto`, `TryFrom` and `FromIterator` traits are now part of the prelude.

https://doc.rust-lang.org/edition-guide/rust-2021/prelude.html

2 years agoFix `match_single_binding` for assign expressions
Serial [Wed, 20 Apr 2022 14:14:11 +0000 (10:14 -0400)]
Fix `match_single_binding` for assign expressions

2 years agoadd suggestions to rc_clone_in_vec_init
yonip23 [Tue, 10 May 2022 21:46:20 +0000 (00:46 +0300)]
add suggestions to rc_clone_in_vec_init

2 years agoFix redundant_allocation warning for Rc<Box<str>>
Evan Typanski [Tue, 10 May 2022 18:21:51 +0000 (14:21 -0400)]
Fix redundant_allocation warning for Rc<Box<str>>

2 years agochore
tamaron [Tue, 10 May 2022 15:27:12 +0000 (00:27 +0900)]
chore

2 years agofix
tamaron [Tue, 10 May 2022 14:08:18 +0000 (23:08 +0900)]
fix

2 years agoAuto merge of #8796 - nsunderland1:master, r=giraffate
bors [Tue, 10 May 2022 13:25:27 +0000 (13:25 +0000)]
Auto merge of #8796 - nsunderland1:master, r=giraffate

New lint: [`derive_partial_eq_without_eq`]

Introduces a new lint, [`derive_partial_eq_without_eq`].

See: #1781 (doesn't close it though).

changelog: add lint [`derive_partial_eq_without_eq`]

2 years agoAuto merge of #8769 - yonip23:8719, r=xFrednet
bors [Tue, 10 May 2022 12:21:12 +0000 (12:21 +0000)]
Auto merge of #8769 - yonip23:8719, r=xFrednet

introduce rc_clone_in_vec_init lint

Closes #8719

changelog: Introduce [`rc_clone_in_vec_init`] lint

2 years agointroduce rc_clone_in_vec_init lint
yonip23 [Sun, 8 May 2022 19:20:25 +0000 (22:20 +0300)]
introduce rc_clone_in_vec_init lint

2 years agoNew lint: [`derive_partial_eq_without_eq`]
nsunderland1 [Fri, 6 May 2022 07:10:11 +0000 (00:10 -0700)]
New lint: [`derive_partial_eq_without_eq`]

2 years agoAuto merge of #8809 - Alexendoo:metadata-collection-expect, r=xFrednet
bors [Mon, 9 May 2022 19:55:37 +0000 (19:55 +0000)]
Auto merge of #8809 - Alexendoo:metadata-collection-expect, r=xFrednet

Ignore unfulfilled_lint_expectations in metadata collection

r? `@xFrednet`

When metadata collection is enabled the regular early/late pass registrations are skipped, which the `#[expect()]`s were no fan of: https://github.com/rust-lang/rust-clippy/runs/6356675328?check_suite_focus=true

changelog: none

2 years agoIgnore unfulfilled_lint_expectations in metadata collection
Alex Macleod [Mon, 9 May 2022 19:30:06 +0000 (20:30 +0100)]
Ignore unfulfilled_lint_expectations in metadata collection

2 years agoAuto merge of #8797 - xFrednet:0000-expect-a-playground, r=flip1995
bors [Mon, 9 May 2022 17:14:43 +0000 (17:14 +0000)]
Auto merge of #8797 - xFrednet:0000-expect-a-playground, r=flip1995

Replace `#[allow]` with `#[expect]` in Clippy

Hey `@rust-lang/clippy,` `@Alexendoo,` `@dswij,` I'm currently working on the expect attribute as defined in [Rust RFC 2383](https://rust-lang.github.io/rfcs/2383-lint-reasons.html). With that, an `#[allow]` attribute can be replaced with a `#[expect]` attribute that suppresses the lint, but also emits a warning, if the lint isn't emitted in the expected scope.

With this PR I would like to test the attribute on a project scale and Clippy obviously came to mind. This PR replaces (almost) all `#[allow]` attributes in `clippy_utils` and `clippy_lints` with the `#[expect]` attribute. I was also able to remove some allows since, the related FPs have been fixed :tada:.

My question is now, are there any concerns regarding this? It's still okay to add normal `#[allow]` attributes, I see the need to nit-pick about that in new PRs, unless it's actually a FP. Also, I would not recommend using `#[expect]` in tests, as changes to a lint could the trigger the expect attribute in other files.

Additionally, I've noticed that Clippy has a bunch of `#[allow(clippy::too_many_lines)]` attributes. Should we maybe allow the lint all together or increase the threshold setting? To me, it seems like we mostly just ignore it in our code. :sweat_smile: :upside_down_face:

---

changelog: none

r? `@flip1995` (I've requested you for now, since you're also helping with reviewing the expect implementation. You are welcome to delegate this PR, even if it should be a simple review :upside_down_face: )

2 years agoDon't lint `cmp_owned` when `From::from` results in a copy type.
Jason Newcomb [Mon, 9 May 2022 16:29:31 +0000 (12:29 -0400)]
Don't lint `cmp_owned` when `From::from` results in a copy type.

2 years agoReduce unnecessary work in `cmp_owned`
Jason Newcomb [Mon, 9 May 2022 15:41:25 +0000 (11:41 -0400)]
Reduce unnecessary work in `cmp_owned`

2 years agoAuto merge of #8805 - Alexendoo:let-chain-docs, r=flip1995
bors [Mon, 9 May 2022 13:56:53 +0000 (13:56 +0000)]
Auto merge of #8805 - Alexendoo:let-chain-docs, r=flip1995

Recommend let chains over if_chain in docs

Switches over bit_mask.rs to let chains in order to create a nice example

While the rustfmt thing isn't resolved yet, my rust-analyzer isn't a fan of large `if_chains!`s, it stops giving me hover info and such after some number of if statements

changelog: none

2 years agoRecommend let chains over if_chain in docs
Alex Macleod [Mon, 9 May 2022 13:23:16 +0000 (14:23 +0100)]
Recommend let chains over if_chain in docs

2 years agouse let chains in bit_mask.rs
Alex Macleod [Mon, 9 May 2022 13:06:46 +0000 (14:06 +0100)]
use let chains in bit_mask.rs

2 years agoAuto merge of #8802 - smoelius:allow-expect-unwrap-in-tests, r=llogiq
bors [Sun, 8 May 2022 15:00:30 +0000 (15:00 +0000)]
Auto merge of #8802 - smoelius:allow-expect-unwrap-in-tests, r=llogiq

Optionally allow `expect` and `unwrap` in tests

This addresses #1015, except it makes the new behavior optional.

The reason for the msrv-related changes is as follows.

Rather than expand `check_methods` list of arguments, it seemed easier to make `check_methods` a method of `Methods`, so that `check_methods` could access `Methods`' fields.

`check_methods` had an `msrv` parameter, which I consequently made a field of `Methods`. But, to avoid adding a lifetime parameter to `Methods`, I made the field type `Option<RustcVersion>` instead of the parameter's existing type, `Option<&RustcVersion>`. This seemed sensible since `RustcVersion` implements `Copy`. But this broke a lot of code that expected an `Option<&RustcVersion>` or `&Option<RustcVersion>`. I changed all of those occurrences to `Option<RustcVersion>`. IMHO, the code is better as a result of these changes, though.

The msrv-related changes are in their own commit to (hopefully) ease review.

Closes #1015

changelog: optionally allow `expect` and `unwrap` in tests

r? `@llogiq`

2 years agoOptionally allow `expect` and `unwrap` in tests
Samuel E. Moelius III [Sun, 8 May 2022 10:44:58 +0000 (06:44 -0400)]
Optionally allow `expect` and `unwrap` in tests

2 years agoPass msrvs by copy
Samuel E. Moelius III [Sun, 8 May 2022 11:13:14 +0000 (07:13 -0400)]
Pass msrvs by copy

2 years agoReplace `#[allow]` with `#[expect]` in Clippy
xFrednet [Sat, 7 May 2022 14:49:19 +0000 (16:49 +0200)]
Replace `#[allow]` with `#[expect]` in Clippy

2 years agoAuto merge of #8794 - smoelius:fix-8759, r=llogiq
bors [Sat, 7 May 2022 12:31:47 +0000 (12:31 +0000)]
Auto merge of #8794 - smoelius:fix-8759, r=llogiq

Address `unnecessary_to_owned` false positive

My proposed fix for #8759 is to revise the conditions that delineate `redundant_clone` and `unnecessary_to_owned`:
```rust
        // Only flag cases satisfying at least one of the following three conditions:
        // * the referent and receiver types are distinct
        // * the referent/receiver type is a copyable array
        // * the method is `Cow::into_owned`
        // This restriction is to ensure there is no overlap between `redundant_clone` and this
        // lint. It also avoids the following false positive:
        //  https://github.com/rust-lang/rust-clippy/issues/8759
        //   Arrays are a bit of a corner case. Non-copyable arrays are handled by
        // `redundant_clone`, but copyable arrays are not.
```
This change causes a few cases that were previously flagged by `unnecessary_to_owned` to no longer be flagged. But one could argue those cases would be better handled by `redundant_clone`.

Closes #8759

changelog: none

2 years agofix
tamaron [Sat, 7 May 2022 09:18:57 +0000 (18:18 +0900)]
fix

2 years agoAuto merge of #8793 - Alexendoo:dev-lint-extra-args, r=xFrednet
bors [Fri, 6 May 2022 16:14:11 +0000 (16:14 +0000)]
Auto merge of #8793 - Alexendoo:dev-lint-extra-args, r=xFrednet

Pass through extra args in `cargo dev lint`

changelog: Pass through extra args in `cargo dev lint`

Lets you pass some useful flags through, like `-A/W/etc`, `--fix`, `--force-warn`

2 years agoResolved conflicts
tamaron [Fri, 29 Apr 2022 09:34:58 +0000 (18:34 +0900)]
Resolved conflicts

2 years agoPass through extra args in `cargo dev lint`
Alex Macleod [Fri, 6 May 2022 12:21:08 +0000 (13:21 +0100)]
Pass through extra args in `cargo dev lint`

2 years agoAddress `unnecessary_to_owned` false positive
Samuel E. Moelius III [Fri, 6 May 2022 01:39:54 +0000 (21:39 -0400)]
Address `unnecessary_to_owned` false positive

2 years agoAuto merge of #8763 - arieluy:manual_range_contains, r=xFrednet
bors [Fri, 6 May 2022 11:33:47 +0000 (11:33 +0000)]
Auto merge of #8763 - arieluy:manual_range_contains, r=xFrednet

Support negative ints in manual_range_contains

fixes: #8721
changelog: Fixes issue where ranges containing ints with different signs would be
incorrect due to comparing as unsigned.

2 years agoAuto merge of #8792 - jyn514:remove-ast-json, r=flip1995
bors [Fri, 6 May 2022 09:44:19 +0000 (09:44 +0000)]
Auto merge of #8792 - jyn514:remove-ast-json, r=flip1995

Suggest -Zunpretty=ast-tree instead of -Zast-json

-Zast-json is being removed shortly: https://github.com/rust-lang/rust/pull/85993.
ast-tree does essentially the same thing, and still works today even before that PR lands.

changelog: none

2 years agoCreate RangeBounds struct
Ariel Uy [Fri, 6 May 2022 04:13:17 +0000 (21:13 -0700)]
Create RangeBounds struct

For check_range_bounds return type.

2 years agoSuggest -Zunpretty=ast-tree instead of -Zast-json
Joshua Nelson [Fri, 6 May 2022 01:11:41 +0000 (20:11 -0500)]
Suggest -Zunpretty=ast-tree instead of -Zast-json

-Zast-json is being removed shortly: https://github.com/rust-lang/rust/pull/85993.
ast-tree does essentially the same thing, and still works today even before that PR lands.

2 years agoAuto merge of #8778 - sunfishcode:main, r=giraffate
bors [Fri, 6 May 2022 00:26:18 +0000 (00:26 +0000)]
Auto merge of #8778 - sunfishcode:main, r=giraffate

Fix `cast_lossless` to avoid warning on `usize` to `f64` conversion.

Previously, the `cast_lossless` lint would issue a warning on code that
converted a `usize` value to `f64`, on 32-bit targets.

`usize` to `f64` is a lossless cast on 32-bit targets, however there is
no corresponding `f64::from` that takes a `usize`, so `cast_lossless`'s
suggested replacement does not compile.

This PR disables the lint in the case of casting from `usize` or `isize`.

Fixes #3689.

changelog: [`cast_lossless`] no longer gives wrong suggestion on usize,isize->f64

2 years agoUse CamelCase; Fix filter ranges
Serial [Thu, 5 May 2022 22:27:56 +0000 (18:27 -0400)]
Use CamelCase; Fix filter ranges

2 years agoAuto merge of #8790 - Jarcho:attribute_line, r=flip1995
bors [Thu, 5 May 2022 21:39:11 +0000 (21:39 +0000)]
Auto merge of #8790 - Jarcho:attribute_line, r=flip1995

Lint `empty_lint_after_outer_attr` on argumentless macros

Reverts the change from 034c81b76145a0514916f34713671b16f26988df as it's no longer needed. The test is left just in case. Original issue is #2475.

changelog: Lint `empty_lint_after_outer_attr` on argumentless macros again

2 years agoRevert hack fixing #2475 added in commit 034c81b76145a0514916f34713671b16f26988df...
Jason Newcomb [Thu, 5 May 2022 17:24:38 +0000 (13:24 -0400)]
Revert hack fixing #2475 added in commit 034c81b76145a0514916f34713671b16f26988df. It's no longer needed.

2 years agoAuto merge of #8789 - fedemartinezdev:master, r=flip1995
bors [Thu, 5 May 2022 17:11:06 +0000 (17:11 +0000)]
Auto merge of #8789 - fedemartinezdev:master, r=flip1995

Added missing `### What it does`

Adds the missing line to ``[`cast-slice-different-sizes`]`` lint documentation
fixes #8781

changelog: none

2 years agoAdded missing `### What it does`
Federico Martinez [Thu, 5 May 2022 16:50:34 +0000 (18:50 +0200)]
Added missing `### What it does`

Adds the missing line to cast-slice-different-sizes lint documentation
/closes 8781

2 years agoAuto merge of #8788 - flip1995:rustup, r=xFrednet,flip1995
bors [Thu, 5 May 2022 13:12:09 +0000 (13:12 +0000)]
Auto merge of #8788 - flip1995:rustup, r=xFrednet,flip1995

Rustup

r? `@ghost`

changelog: move trait_duplication_in_bounds and type_repetition_in_bounds to nursery temporarily. This could already be reverted before the release. Check the Clippy in the Rust repo beta branch when writing this changelog.

2 years agoFix ICE in EarlyAttribtues lints
flip1995 [Thu, 5 May 2022 13:10:06 +0000 (14:10 +0100)]
Fix ICE in EarlyAttribtues lints

2 years agoHACK: Move buggy lints to nursery
flip1995 [Thu, 5 May 2022 12:32:31 +0000 (13:32 +0100)]
HACK: Move buggy lints to nursery

Those lints are trait_duplication_in_bounds and
type_repetition_in_bounds. I don't think those can be fixed on the
Clippy side alone, but need changes in the compiler. So let's move them
to nursery to get the sync through and then fix them on the rustc side.

Also adds a regression test that has to be fixed before they can be
moved back to pedantic.

2 years agoBump nightly version -> 2022-05-05
flip1995 [Thu, 5 May 2022 12:32:18 +0000 (13:32 +0100)]
Bump nightly version -> 2022-05-05

2 years agoMerge remote-tracking branch 'upstream/master' into rustup
flip1995 [Thu, 5 May 2022 12:01:37 +0000 (13:01 +0100)]
Merge remote-tracking branch 'upstream/master' into rustup

2 years agoChange input placeholder
Serial [Thu, 5 May 2022 00:43:08 +0000 (20:43 -0400)]
Change input placeholder

2 years agoAuto merge of #96546 - nnethercote:overhaul-MacArgs, r=petrochenkov
bors [Wed, 4 May 2022 21:16:28 +0000 (21:16 +0000)]
Auto merge of #96546 - nnethercote:overhaul-MacArgs, r=petrochenkov

Overhaul `MacArgs`

Motivation:
- Clarify some code that I found hard to understand.
- Eliminate one use of three places where `TokenKind::Interpolated` values are created.

r? `@petrochenkov`

2 years agoOverhaul `MacArgs::Eq`.
Nicholas Nethercote [Thu, 28 Apr 2022 20:52:01 +0000 (06:52 +1000)]
Overhaul `MacArgs::Eq`.

The value in `MacArgs::Eq` is currently represented as a `Token`.
Because of `TokenKind::Interpolated`, `Token` can be either a token or
an arbitrary AST fragment. In practice, a `MacArgs::Eq` starts out as a
literal or macro call AST fragment, and then is later lowered to a
literal token. But this is very non-obvious. `Token` is a much more
general type than what is needed.

This commit restricts things, by introducing a new type `MacArgsEqKind`
that is either an AST expression (pre-lowering) or an AST literal
(post-lowering). The downside is that the code is a bit more verbose in
a few places. The benefit is that makes it much clearer what the
possibilities are (though also shorter in some other places). Also, it
removes one use of `TokenKind::Interpolated`, taking us a step closer to
removing that variant, which will let us make `Token` impl `Copy` and
remove many "handle Interpolated" code paths in the parser.

Things to note:
- Error messages have improved. Messages like this:
  ```
  unexpected token: `"bug" + "found"`
  ```
  now say "unexpected expression", which makes more sense. Although
  arbitrary expressions can exist within tokens thanks to
  `TokenKind::Interpolated`, that's not obvious to anyone who doesn't
  know compiler internals.
- In `parse_mac_args_common`, we no longer need to collect tokens for
  the value expression.

2 years agoAuto merge of #8575 - FoseFx:trim_split_whitespace2, r=flip1995
bors [Wed, 4 May 2022 13:31:19 +0000 (13:31 +0000)]
Auto merge of #8575 - FoseFx:trim_split_whitespace2, r=flip1995

add `trim_split_whitespace`

Closes #8521

changelog: [`trim_split_whitespace`]

2 years agoAuto merge of #8780 - Alexendoo:init-numbered-field-alias, r=flip1995
bors [Wed, 4 May 2022 13:17:35 +0000 (13:17 +0000)]
Auto merge of #8780 - Alexendoo:init-numbered-field-alias, r=flip1995

Ignore type aliases in `init_numbered_fields`

changelog: Ignore type aliases in [`init_numbered_fields`]

Fixes #8638

2 years agoadd trim_split_whitespace
Max Baumann [Tue, 22 Mar 2022 20:15:09 +0000 (21:15 +0100)]
add trim_split_whitespace

2 years agoOnly require minor version
Serial [Tue, 3 May 2022 22:12:31 +0000 (18:12 -0400)]
Only require minor version

2 years agoAuto merge of #8779 - binggh:easier-needless-late-init, r=llogiq
bors [Tue, 3 May 2022 20:42:35 +0000 (20:42 +0000)]
Auto merge of #8779 - binggh:easier-needless-late-init, r=llogiq

Easier readability for `needless_late_init` message

Closes #8530

Updated the lint to use a `MultiSpan`, showing where the `let` statement was first used and where the initialisation statement was done, as in the format described, for easier readability.

Was wondering why, when pushing the span label for the initialisation statement, that sometimes the prior statement above the initialisation statement gets pulled into the output as well - any insight is appreciated!

---

changelog: [`needless_late_init`]: Now shows the `let` statement where it was first initialized

2 years agoAuto merge of #96558 - bjorn3:librarify_parse_format, r=davidtwco
bors [Tue, 3 May 2022 20:03:54 +0000 (20:03 +0000)]
Auto merge of #96558 - bjorn3:librarify_parse_format, r=davidtwco

Make rustc_parse_format compile on stable

This allows it to be used by lightweight formatting systems and may allow it to be used by rust-analyzer.

2 years agoAuto merge of #8783 - flip1995:ouir-nursery, r=llogiq
bors [Tue, 3 May 2022 18:06:52 +0000 (18:06 +0000)]
Auto merge of #8783 - flip1995:ouir-nursery, r=llogiq

Move only_used_in_recursion to nursery

r? `@llogiq`

I still think this is the right thing to do for this lint. See: #8782

I want to get this merged before the sync on Thursday, because I want to backport this and the last fix #8691 to beta.

changelog: Move [`only_used_in_recursion`] to nursery

2 years agoMove only_used_in_recursion to nursery
flip1995 [Tue, 3 May 2022 15:41:12 +0000 (16:41 +0100)]
Move only_used_in_recursion to nursery

2 years agoIgnore type aliases in `init_numbered_fields`
Alex Macleod [Tue, 3 May 2022 12:39:38 +0000 (13:39 +0100)]
Ignore type aliases in `init_numbered_fields`

2 years agocargo dev bless
binggh [Tue, 3 May 2022 09:51:34 +0000 (17:51 +0800)]
cargo dev bless

2 years agoEasier readability for needless_late_init
binggh [Tue, 3 May 2022 09:51:23 +0000 (17:51 +0800)]
Easier readability for needless_late_init

2 years agoMake rustc_parse_format compile on stable
bjorn3 [Fri, 29 Apr 2022 16:48:58 +0000 (18:48 +0200)]
Make rustc_parse_format compile on stable

This allows it to be used by lightweight formatting systems and may
allow it to be used by rust-analyzer.

2 years agoAuto merge of #8730 - tamaroning:fix8724, r=Alexendoo
bors [Tue, 3 May 2022 07:05:51 +0000 (07:05 +0000)]
Auto merge of #8730 - tamaroning:fix8724, r=Alexendoo

[FP] identity_op in front of if

fix #8724

changelog: FP: [`identity_op`]: is now allowed in front of if statements, blocks and other expressions where the suggestion would be invalid.

Resolved simular problems with blocks, mathces, and loops.
identity_op always does NOT suggest reducing `0 + if b { 1 } else { 2 } + 3` into  `if b { 1 } else { 2 } + 3` even in the case that the expression is in `f(expr)` or `let x = expr;` for now.

2 years agoFix `cast_lossless` to avoid warning on `usize` to `f64` conversion.
Dan Gohman [Mon, 2 May 2022 20:46:29 +0000 (13:46 -0700)]
Fix `cast_lossless` to avoid warning on `usize` to `f64` conversion.

Previously, the `cast_lossless` lint would issue a warning on code that
converted a `usize` value to `f64`, on 32-bit targets.

`usize` to `f64` is a lossless cast on 32-bit targets, however there is
no corresponding `f64::from` that takes a `usize`, so `cast_lossless`'s
suggested replacement does not compile.

This PR disables the lint in the case of casting from `usize` or `isize`.

Fixes #3689.

changelog: [`cast_lossless`] no longer gives wrong suggestion on usize->f64

2 years agorustc: Panic by default in `DefIdTree::parent`
Vadim Petrochenkov [Mon, 25 Apr 2022 19:08:45 +0000 (22:08 +0300)]
rustc: Panic by default in `DefIdTree::parent`

Only crate root def-ids don't have a parent, and in majority of cases the argument of `DefIdTree::parent` cannot be a crate root.
So we now panic by default in `parent` and introduce a new non-panicing function `opt_parent` for cases where the argument can be a crate root.

Same applies to `local_parent`/`opt_local_parent`.

2 years agoimprove identity_op
tamaron [Fri, 22 Apr 2022 01:39:38 +0000 (10:39 +0900)]
improve identity_op

fix

Update identity_op.rs

ok

update without_loop_counters test

chore

fix

chore

remove visitor and leftmost

fix

add document

2 years agoFix the clippy build
Scott McMurray [Mon, 25 Apr 2022 02:08:23 +0000 (19:08 -0700)]
Fix the clippy build

2 years agoAuto merge of #8767 - xFrednet:8765-fix-doc-example, r=camsteffen
bors [Sat, 30 Apr 2022 17:37:00 +0000 (17:37 +0000)]
Auto merge of #8767 - xFrednet:8765-fix-doc-example, r=camsteffen

Add missing quite in `large_include_file` example

Roses are red,
violets are blue,
this fix,
was simple to do

Closes: https://github.com/rust-lang/rust-clippy/issues/8765
changelog: None

2 years agoAuto merge of #8625 - Jarcho:rename_lint, r=xFrednet
bors [Sat, 30 Apr 2022 17:22:34 +0000 (17:22 +0000)]
Auto merge of #8625 - Jarcho:rename_lint, r=xFrednet

Add `cargo dev rename_lint`

fixes #7799

changelog: None

2 years agoAdd missing quite in `large_include_file` example
xFrednet [Sat, 30 Apr 2022 17:16:19 +0000 (19:16 +0200)]
Add missing quite in `large_include_file` example

2 years agoAuto merge of #8720 - asquared31415:ptr-cast-ice-fix, r=Alexendoo,xFrednet
bors [Sat, 30 Apr 2022 16:51:01 +0000 (16:51 +0000)]
Auto merge of #8720 - asquared31415:ptr-cast-ice-fix, r=Alexendoo,xFrednet

fix ICE in `cast_slice_different_sizes`

fixes #8708

changelog: fixes an ICE introduced in #8445