]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoAdd bound_fn_sig
Jack Huey [Sun, 8 May 2022 19:43:18 +0000 (15:43 -0400)]
Add bound_fn_sig

2 years agoAdd bound_type_of
Jack Huey [Sun, 8 May 2022 19:12:56 +0000 (15:12 -0400)]
Add bound_type_of

2 years agoremove TestItemNamesVisitor
Miguel Guarniz [Sat, 7 May 2022 18:51:05 +0000 (14:51 -0400)]
remove TestItemNamesVisitor

Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
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 agoAuto merge of #95562 - lcnr:attr-no-encode, r=davidtwco
bors [Thu, 12 May 2022 12:48:30 +0000 (12:48 +0000)]
Auto merge of #95562 - lcnr:attr-no-encode, r=davidtwco

don't encode only locally used attrs

Part of https://github.com/rust-lang/compiler-team/issues/505.

We now filter builtin attributes before encoding them in the crate metadata in case they should only be used in the local crate. To prevent accidental misuse `get_attrs` now requires the caller to state which attribute they are interested in. For places where that isn't trivially possible, I've added a method `fn get_attrs_unchecked` which I intend to remove in a followup PR.

After this pull request landed, we can then slowly move all attributes to only be used in the local crate while being certain that we don't accidentally try to access them from extern crates.

cc https://github.com/rust-lang/rust/pull/94963#issuecomment-1082924289

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 agoBless clippy.
Camille GILLOT [Wed, 11 May 2022 16:51:14 +0000 (18:51 +0200)]
Bless clippy.

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 agoIntroduce EarlyBinder
Jack Huey [Sun, 8 May 2022 05:17:58 +0000 (01:17 -0400)]
Introduce EarlyBinder

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 agoupdate clippy
lcnr [Tue, 26 Apr 2022 12:04:23 +0000 (14:04 +0200)]
update clippy

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 agofix clippy
SparrowLii [Mon, 9 May 2022 13:48:57 +0000 (21:48 +0800)]
fix clippy

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 #95542 - xFrednet:rfc-2383-expect-query, r=wesleywiser
bors [Mon, 9 May 2022 00:02:55 +0000 (00:02 +0000)]
Auto merge of #95542 - xFrednet:rfc-2383-expect-query, r=wesleywiser

Support tool lints with the `#[expect]` attribute (RFC 2383)

This PR fixes the ICE https://github.com/rust-lang/rust/issues/94953 by making the assert for converted expectation IDs conditional.

Additionally, it moves the lint expectation check into a separate query to support rustdoc and other tools. On the way, I've also added some tests to ensure that the attribute works for Clippy and rustdoc lints.

The number of changes comes from the long test file. This may look like a monster PR, this may smell like a monster PR and this may be a monster PR, but it's a harmless monster. :sauropod:

---

Closes: https://github.com/rust-lang/rust/issues/94953
cc: https://github.com/rust-lang/rust/issues/85549

r? `@wesleywiser`

cc: `@rust-lang/rustdoc`

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 agoAuto merge of #96770 - flip1995:fix-trait-type-in-bounds, r=cjgillot
bors [Sun, 8 May 2022 14:10:12 +0000 (14:10 +0000)]
Auto merge of #96770 - flip1995:fix-trait-type-in-bounds, r=cjgillot

Track if a where bound comes from a impl Trait desugar

With https://github.com/rust-lang/rust/pull/93803 `impl Trait` function arguments get desugared to hidden where bounds. However, Clippy needs to know if a bound was originally a `impl Trait` or an actual bound. This adds a field to the `WhereBoundPredicate` struct to keep track of this information during AST->HIR lowering.

r? `@cjgillot`

cc `@estebank` (as the reviewer of #93803)

2 years agoTest `expect` attribute for tool lints, clippy edition (RFC 2383)
xFrednet [Thu, 31 Mar 2022 19:49:50 +0000 (21:49 +0200)]
Test `expect` attribute for tool lints, clippy edition (RFC 2383)

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 agoAuto merge of #94206 - PrestonFrom:significant_drop, r=flip1995
bors [Sun, 8 May 2022 00:57:08 +0000 (00:57 +0000)]
Auto merge of #94206 - PrestonFrom:significant_drop, r=flip1995

Create clippy lint against unexpectedly late drop for temporaries in match scrutinee expressions

A new clippy lint for issue 93883 (https://github.com/rust-lang/rust/issues/93883). Relies on a new trait in `marker` (called `SignificantDrop` to enable linting), which is why this PR is for the rust-lang repo and not the clippy repo.

changelog: new lint [`significant_drop_in_scrutinee`]

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 agoTrack if a where bound comes from a impl Trait desugar
flip1995 [Thu, 5 May 2022 14:50:11 +0000 (15:50 +0100)]
Track if a where bound comes from a impl Trait desugar

With #93803 `impl Trait` function arguments get desugared to hidden
where bounds. However, Clippy needs to know if a bound was originally a
impl Trait or an actual bound. This adds a field to the
`WhereBoundPredicate` struct to keep track of this information during
HIR lowering.

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 agoLint for significant drops who may have surprising lifetimes #1
Preston From [Fri, 18 Feb 2022 06:02:22 +0000 (00:02 -0600)]
Lint for significant drops who may have surprising lifetimes #1

author Preston From <prestonfrom@gmail.com> 1645164142 -0600
committer Preston From <prestonfrom@gmail.com> 1650005351 -0600

2 years agoAuto merge of #96531 - kckeiks:remove-item-like-visitor-from-rustc-typeck, r=cjgillot
bors [Sat, 7 May 2022 01:59:11 +0000 (01:59 +0000)]
Auto merge of #96531 - kckeiks:remove-item-like-visitor-from-rustc-typeck, r=cjgillot

Remove ItemLikeVisitor impls from rustc_typeck

Issue #95004
cc `@cjgillot`

2 years agoRollup merge of #96557 - nbdd0121:const, r=oli-obk
Guillaume Gomez [Fri, 6 May 2022 18:05:37 +0000 (20:05 +0200)]
Rollup merge of #96557 - nbdd0121:const, r=oli-obk

Allow inline consts to reference generic params

Tracking issue: #76001

The RFC says that inline consts cannot reference to generic parameters (for now), same as array length expressions. And expresses that it's desirable for it to reference in-scope generics, when array length expressions gain that feature as well.

However it is possible to implement this for inline consts before doing this for all anon consts, because inline consts are only used as values and they won't be used in the type system. So we can have:
```rust
fn foo<T>() {
    let x = [4i32; std::mem::size_of::<T>()];   // NOT ALLOWED (for now)
    let x = const { std::mem::size_of::<T>() }; // ALLOWED with this PR!
    let x = [4i32; const { std::mem::size_of::<T>() }];   // NOT ALLOWED (for now)
}
```

This would make inline consts super useful for compile-time checks and assertions:
```rust
fn assert_zst<T>() {
    const { assert!(std::mem::size_of::<T>() == 0) };
}
```

This would create an error during monomorphization when `assert_zst` is instantiated with non-ZST `T`s. A error during mono might sound scary, but this is exactly what a "desugared" inline const would do:
```rust
fn assert_zst<T>() {
    struct F<T>(T);
    impl<T> F<T> {
        const V: () = assert!(std::mem::size_of::<T>() == 0);
    }
    let _ = F::<T>::V;
}
```

It should also be noted that the current inline const implementation can already reference the type params via type inference, so this resolver-level restriction is not any useful either:
```rust
fn foo<T>() -> usize {
    let (_, size): (PhantomData<T>, usize) = const {
        const fn my_size_of<T>() -> (PhantomData<T>, usize) {
            (PhantomData, std::mem::size_of::<T>())
        }
        my_size_of()
    };
    size
}
```

```@rustbot``` label: F-inline_const

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 agouse def_span and def_kind queries instead of calling tcx.hir() methods
Miguel Guarniz [Fri, 29 Apr 2022 17:11:22 +0000 (13:11 -0400)]
use def_span and def_kind queries instead of calling tcx.hir() methods

Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
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 ago(Partially) Revert "HACK: Move buggy lints to nursery"
flip1995 [Thu, 5 May 2022 14:20:07 +0000 (15:20 +0100)]
(Partially) Revert "HACK: Move buggy lints to nursery"

This reverts commit bb01aca86f66954b80798213711e8eadc4b26902.

Partial: Keep regression tests

2 years agoMerge commit '7c21f91b15b7604f818565646b686d90f99d1baf' into clippyup
flip1995 [Thu, 5 May 2022 14:12:52 +0000 (15:12 +0100)]
Merge commit '7c21f91b15b7604f818565646b686d90f99d1baf' into clippyup

2 years agoBless clippy error msg
Gary Guo [Thu, 5 May 2022 13:27:11 +0000 (14:27 +0100)]
Bless clippy error msg

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 agoidentity_op: add parenthesis to suggestions where required
Alex Macleod [Wed, 4 May 2022 17:13:06 +0000 (18:13 +0100)]
identity_op: add parenthesis to suggestions where required

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