]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoAdd lint to detect `allow` attributes without reason
xFrednet [Thu, 3 Mar 2022 22:57:35 +0000 (23:57 +0100)]
Add lint to detect `allow` attributes without reason

2 years agoAuto merge of #8474 - Alexendoo:paths, r=Manishearth
bors [Fri, 25 Feb 2022 16:07:59 +0000 (16:07 +0000)]
Auto merge of #8474 - Alexendoo:paths, r=Manishearth

Replace some more paths with diagnostic items

cc #5393

Replaces the macro & mem paths, and catches a couple others that were unused

changelog: none

2 years agoAuto merge of #8472 - Mastermindaxe:#8152_new-without-default_should_not_trigger_on_d...
bors [Fri, 25 Feb 2022 15:51:37 +0000 (15:51 +0000)]
Auto merge of #8472 - Mastermindaxe:#8152_new-without-default_should_not_trigger_on_doc_hidden_items, r=flip1995

Disable ``[`new-without-default`]`` for new() methods that are marked…

… with '#[doc(hidden)]'

Fixes #8152

changelog: Disable ``[`new-without-default`]`` for new() methods that are marked with `#[doc(hidden)]`

2 years agoReplace some more paths with diagnostic items
Alex Macleod [Fri, 25 Feb 2022 15:38:06 +0000 (15:38 +0000)]
Replace some more paths with diagnostic items

2 years agoDisable ``[`new-without-default`]`` for new() methods that are marked with '#[doc...
Florian Nagel [Fri, 25 Feb 2022 13:36:23 +0000 (14:36 +0100)]
Disable ``[`new-without-default`]`` for new() methods that are marked with '#[doc(hidden)]'

Fixes issue #8152

2 years agoAuto merge of #8468 - flip1995:rustup, r=flip1995
bors [Thu, 24 Feb 2022 18:37:57 +0000 (18:37 +0000)]
Auto merge of #8468 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: none

2 years agoBump nightly version -> 2022-02-24
flip1995 [Thu, 24 Feb 2022 18:33:10 +0000 (19:33 +0100)]
Bump nightly version -> 2022-02-24

2 years agoBump Clippy Version -> 0.1.61
flip1995 [Thu, 24 Feb 2022 18:32:47 +0000 (19:32 +0100)]
Bump Clippy Version -> 0.1.61

2 years agoMerge remote-tracking branch 'upstream/master' into rustup
flip1995 [Thu, 24 Feb 2022 18:32:17 +0000 (19:32 +0100)]
Merge remote-tracking branch 'upstream/master' into rustup

2 years agoAuto merge of #8466 - tamaroning:fix_reduntant_closure, r=Manishearth
bors [Wed, 23 Feb 2022 18:26:30 +0000 (18:26 +0000)]
Auto merge of #8466 - tamaroning:fix_reduntant_closure, r=Manishearth

False positive redundant_closure when using ref pattern in closure params

fixes #8460
Fixed [redundant_closure] so that closures of which params bound as `ref` or `ref mut ` doesn't trigger the lint.
(e.g. `|ref x| some_expr` doesn't trigger the lint.)
changelog: none

2 years agofix typo
tamaron [Wed, 23 Feb 2022 15:25:07 +0000 (00:25 +0900)]
fix typo

2 years agofix
tamaron [Wed, 23 Feb 2022 15:16:24 +0000 (00:16 +0900)]
fix

2 years agoAuto merge of #8451 - matthiaskrgr:ui_speedup, r=llogiq
bors [Tue, 22 Feb 2022 21:58:24 +0000 (21:58 +0000)]
Auto merge of #8451 - matthiaskrgr:ui_speedup, r=llogiq

tests: default to more threads for ui-tests

Benchmarks (tested on i5-7200U, 2 cores, 4 threads)

```
master branch:

cargo test // prime caches
cargo --color=always test  70,39s user 21,91s system 180% cpu 51,035 total
cargo --color=always test  70,77s user 22,13s system 180% cpu 51,579 total
cargo --color=always test  70,97s user 22,12s system 180% cpu 51,673 total

cargo --color=always nextest run  78,74s user 22,27s system 220% cpu 45,829 total
cargo --color=always nextest run  78,46s user 21,92s system 224% cpu 44,674 total
cargo --color=always nextest run  78,31s user 22,21s system 228% cpu 43,909 total

Patched (ui_speedup branch):

cargo test // prime cache
cargo --color=always test  97,51s user 32,02s system 288% cpu 44,905 total
cargo --color=always test  99,19s user 31,91s system 276% cpu 47,436 total
cargo --color=always test  98,47s user 31,84s system 284% cpu 45,744 total

cargo --color=always nextest run  102,18s user 30,80s system 350% cpu 37,902 total
cargo --color=always nextest run  99,75s user 29,86s system 350% cpu 36,935 total
cargo --color=always nextest run  100,36s user 29,93s system 351% cpu 37,061 total
```

changelog: use more threads for running clippys ui-tests for ~10% walltime speedup

2 years agoAuto merge of #8443 - Jarcho:match_cfg_arm, r=flip1995
bors [Mon, 21 Feb 2022 08:46:42 +0000 (08:46 +0000)]
Auto merge of #8443 - Jarcho:match_cfg_arm, r=flip1995

Don't lint `match` expressions with `cfg`ed arms

Somehow there are no open issues related to this for any of the affected lints. At least none that I could fine from a quick search.

changelog: Don't lint `match` expressions with `cfg`ed arms in many cases

2 years agoupdate clippy
lcnr [Mon, 7 Feb 2022 15:06:55 +0000 (16:06 +0100)]
update clippy

2 years agotests: default to more threads for ui-tests
Matthias Krüger [Sun, 20 Feb 2022 12:45:37 +0000 (13:45 +0100)]
tests: default to more threads for ui-tests

Benchmarks (tested on i5-7200U, 2 core 4 threads)

```
master branch:

cargo test // prime caches
cargo --color=always test  70,39s user 21,91s system 180% cpu 51,035 total
cargo --color=always test  70,77s user 22,13s system 180% cpu 51,579 total
cargo --color=always test  70,97s user 22,12s system 180% cpu 51,673 total

cargo --color=always nextest run  78,74s user 22,27s system 220% cpu 45,829 total
cargo --color=always nextest run  78,46s user 21,92s system 224% cpu 44,674 total
cargo --color=always nextest run  78,31s user 22,21s system 228% cpu 43,909 total

Patched (ui_speedup branch)

cargo test // prime cache
cargo --color=always test  97,51s user 32,02s system 288% cpu 44,905 total
cargo --color=always test  99,19s user 31,91s system 276% cpu 47,436 total
cargo --color=always test  98,47s user 31,84s system 284% cpu 45,744 total

cargo --color=always nextest run  102,18s user 30,80s system 350% cpu 37,902 total
cargo --color=always nextest run  99,75s user 29,86s system 350% cpu 36,935 total
cargo --color=always nextest run  100,36s user 29,93s system 351% cpu 37,061 total
```

2 years agoAuto merge of #8440 - Jarcho:transmute_undefined, r=Manishearth
bors [Fri, 18 Feb 2022 22:48:23 +0000 (22:48 +0000)]
Auto merge of #8440 - Jarcho:transmute_undefined, r=Manishearth

Some more fixes for `transmute_undefined_repr`

changelog: Fix transmuting a struct containing a pointer into a pointer in `transmute_undefined_repr`
changelog: Allow various forms of type erasure in `transmute_undefined_repr`

2 years agoClarify `cfg` detection process in `matches.rs`
Jason Newcomb [Fri, 18 Feb 2022 20:41:46 +0000 (15:41 -0500)]
Clarify `cfg` detection process in `matches.rs`

2 years agoFix `transmute_undefined_repr` when converting between a fat pointer and a type conta...
Jason Newcomb [Wed, 16 Feb 2022 19:59:04 +0000 (14:59 -0500)]
Fix `transmute_undefined_repr` when converting between a fat pointer and a type containing a fat pointer

2 years agoAllow transmuting fat pointers to some types in `transmute_undefined_repr`
Jason Newcomb [Wed, 16 Feb 2022 15:45:49 +0000 (10:45 -0500)]
Allow transmuting fat pointers to some types in `transmute_undefined_repr`

2 years agoAllow various type erasure patterns in `transmute_undefined_repr`
Jason Newcomb [Tue, 15 Feb 2022 19:51:57 +0000 (14:51 -0500)]
Allow various type erasure patterns in `transmute_undefined_repr`

2 years agoAdd some comments to `transmute_undefined_repr`
Jason Newcomb [Tue, 15 Feb 2022 16:39:19 +0000 (11:39 -0500)]
Add some comments to `transmute_undefined_repr`

2 years agoFix `transmute_undefined_repr` when converting between a pointer and a type containin...
Jason Newcomb [Tue, 15 Feb 2022 16:29:02 +0000 (11:29 -0500)]
Fix `transmute_undefined_repr` when converting between a pointer and a type containing a pointer

2 years agoAuto merge of #8381 - Jarcho:cast_possible_truncation_542, r=Manishearth
bors [Fri, 18 Feb 2022 19:31:10 +0000 (19:31 +0000)]
Auto merge of #8381 - Jarcho:cast_possible_truncation_542, r=Manishearth

Lint enum-to-int casts with `cast_possible_truncation`

fixes: #542

~~This will not lint casting a specific variant to an integer. That really should be a new lint as it's definitely a truncation (other than `isize`/`usize` values).~~

changelog: Lint enum-to-int casts with `cast_possible_truncation`
changelog: New lint `cast_enum_truncation`

2 years agoExtract some util functions
Jason Newcomb [Fri, 18 Feb 2022 14:10:48 +0000 (09:10 -0500)]
Extract some util functions

2 years agoNew lint `cast_enum_truncation`
Jason Newcomb [Tue, 1 Feb 2022 02:22:47 +0000 (21:22 -0500)]
New lint `cast_enum_truncation`

2 years agoLint enum-to-int casts with `cast_possible_truncation`
Jason Newcomb [Mon, 31 Jan 2022 20:45:49 +0000 (15:45 -0500)]
Lint enum-to-int casts with `cast_possible_truncation`

2 years agoAuto merge of #8419 - flip1995:await_parking_alot, r=llogiq
bors [Fri, 18 Feb 2022 10:55:05 +0000 (10:55 +0000)]
Auto merge of #8419 - flip1995:await_parking_alot, r=llogiq

Fix `await_holding_lock` not linting `parking_lot` Mutex/RwLock

This adds tests for `RwLock` and `parking_lot::{Mutex, RwLock}`, which were added before in https://github.com/rust-lang/rust-clippy/commit/2dc8c083f54454ca87bb09d691577eada2d23539, but never tested in UI tests. I noticed this while reading [fasterthanli.me](https://fasterthanli.me/articles/a-rust-match-made-in-hell) latest blog post, complaining that Clippy doesn't catch this for `parking_lot`. (Too many people read his blog, he's too powerful)

Some more things:
- Adds a test for #6446
- Improves the lint message

changelog: [`await_holding_lock`]: Now also lints for `parking_lot::{Mutex, RwLock}`

2 years agoAuto merge of #94088 - oli-obk:revert, r=jackh726
bors [Fri, 18 Feb 2022 07:35:37 +0000 (07:35 +0000)]
Auto merge of #94088 - oli-obk:revert, r=jackh726

Revert #91403

fixes #94004

r? `@pnkfelix` `@cjgillot`

2 years agoAuto merge of #8442 - rsmantini:issue-8120-fix, r=Manishearth
bors [Thu, 17 Feb 2022 22:57:23 +0000 (22:57 +0000)]
Auto merge of #8442 - rsmantini:issue-8120-fix, r=Manishearth

trigger  `ptr_as_ptr` inside macros

This PR makes `ptr_as_ptr` trigger inside macros

Fixes issue #8120

changelog: ``[`ptr_as_ptr`]`` is now triggered inside macros

r? `@llogiq`

2 years agoRemove hack testing for `cfg` attribute in `match_single_binding`
Jason Newcomb [Thu, 17 Feb 2022 19:16:21 +0000 (14:16 -0500)]
Remove hack testing for `cfg` attribute in `match_single_binding`

2 years agotrigger ptr_as_ptr inside macros
Rodrigo Mantini [Thu, 17 Feb 2022 00:08:53 +0000 (01:08 +0100)]
trigger ptr_as_ptr inside macros

2 years agoCheck for `cfg` attrubutes before linting `match` expressions
Jason Newcomb [Thu, 17 Feb 2022 18:43:59 +0000 (13:43 -0500)]
Check for `cfg` attrubutes before linting `match` expressions

2 years agoMove await_holding_* lints to suspicious and improve doc
flip1995 [Thu, 17 Feb 2022 16:57:39 +0000 (17:57 +0100)]
Move await_holding_* lints to suspicious and improve doc

Even though the FP for that the lints were moved to pedantic isn't fixed
yet, running the lintcheck tool over the most popular 279 crates didn't
trigger this lint once. I would say that this lint is valuable enough,
despite the known FP, to be warn-by-default. Especially since a pretty
nice workaround exists.

2 years agoAdd test for drop-before-await FP
flip1995 [Sat, 12 Feb 2022 10:30:03 +0000 (11:30 +0100)]
Add test for drop-before-await FP

2 years agoActually lint parking_lot in await_holding_lock
flip1995 [Sat, 12 Feb 2022 09:32:44 +0000 (10:32 +0100)]
Actually lint parking_lot in await_holding_lock

This adapts the paths for the parking_lot mutex guards, so that
parking_lot mutexes and RwLocks actually get linted. This is now also
tested.

2 years agoImprove lint message of await_holding_*
flip1995 [Sat, 12 Feb 2022 09:23:07 +0000 (10:23 +0100)]
Improve lint message of await_holding_*

Improves the message of the lints await_holding_lock and
await_holding_refcell_ref. Now also actually tests RwLock.

2 years agoAuto merge of #8218 - Jarcho:redundant_slicing_deref, r=camsteffen
bors [Thu, 17 Feb 2022 16:08:45 +0000 (16:08 +0000)]
Auto merge of #8218 - Jarcho:redundant_slicing_deref, r=camsteffen

Improve `redundant_slicing` lint

fixes #7972
fixes #7257

This can supersede #7976

changelog: Fix suggestion for `redundant_slicing` when re-borrowing for a method call
changelog: New lint `deref_as_slicing`

2 years agoRevert "Auto merge of #91403 - cjgillot:inherit-async, r=oli-obk"
Oli Scherer [Thu, 17 Feb 2022 16:00:04 +0000 (16:00 +0000)]
Revert "Auto merge of #91403 - cjgillot:inherit-async, r=oli-obk"

This reverts commit 3cfa4def7c87d571bd46d92fed608edf8fad236e, reversing
changes made to 5d8767cb229b097fedb1dd4bd9420d463c37774f.

2 years agoAuto merge of #8441 - Jarcho:needless_borrow_temp, r=flip1995
bors [Thu, 17 Feb 2022 15:51:30 +0000 (15:51 +0000)]
Auto merge of #8441 - Jarcho:needless_borrow_temp, r=flip1995

Don't lint `needless_borrow` in method receiver positions

fixes #8408
fixes #8407
fixes #8391
fixes #8367
fixes #8380

This is a temporary fix for `needless_borrow`. The proper fix is included in #8355.

This should probably be merged into rustc before beta branches on Friday. This issue has been reported six or seven times in the past couple of weeks.

changelog: Fix various issues with `needless_borrow` n´. Note to changelog writer: those issues might have been introduced in this release cycle, so this might not matter in the changelog.

2 years agoRemove some redundant checks in various matches lints
Jason Newcomb [Thu, 17 Feb 2022 15:48:24 +0000 (10:48 -0500)]
Remove some redundant checks in various matches lints

2 years agoDon't lint `needless_borrow` in method receiver positions
Jason Newcomb [Thu, 17 Feb 2022 04:14:39 +0000 (23:14 -0500)]
Don't lint `needless_borrow` in method receiver positions

2 years agoAuto merge of #8433 - hellow554:update_default_trait, r=flip1995
bors [Thu, 17 Feb 2022 09:13:30 +0000 (09:13 +0000)]
Auto merge of #8433 - hellow554:update_default_trait, r=flip1995

Don't lint Default::default if it is the udpate syntax base

changelog: Don't lint `Default::default` it is part of the update syntax

Current clippy warns about this:

```
warning: calling `Foo::default()` is more clear than this expression
  --> src/main.rs:12:11
   |
12 |         ..Default::default()
   |           ^^^^^^^^^^^^^^^^^^ help: try: `Foo::default()`
   |
```

With these changes, it will not lint that particular expression anymore.

2 years agoDon't lint Default::default if it is the udpate syntax base
Marcel Hellwig [Mon, 14 Feb 2022 12:22:36 +0000 (13:22 +0100)]
Don't lint Default::default if it is the udpate syntax base

An Update Syntax looks like this:

   Foo {
      a: 3,
      ..Default::default()
    }

Don't lint `Default::default` here

2 years agoRollup merge of #94030 - ChayimFriedman2:issue-94010, r=petrochenkov
Matthias Krüger [Thu, 17 Feb 2022 05:30:02 +0000 (06:30 +0100)]
Rollup merge of #94030 - ChayimFriedman2:issue-94010, r=petrochenkov

Correctly mark the span of captured arguments in `format_args!()`

It should not include the braces, or misspelling suggestions will be wrong.

Fixes #94010.

2 years agoMove some cases from `redundant_slicing` to `deref_by_slicing`
Jason Newcomb [Sun, 13 Feb 2022 23:43:19 +0000 (18:43 -0500)]
Move some cases from `redundant_slicing` to `deref_by_slicing`

2 years agoSplit off new lint `deref_by_slicing` from `redundant_slicing`
Jason Newcomb [Tue, 11 Jan 2022 17:41:15 +0000 (12:41 -0500)]
Split off new lint `deref_by_slicing` from `redundant_slicing`

2 years agoAccount for auto-borrows and precedence in `redundant_slicing` lint
Jason Newcomb [Tue, 4 Jan 2022 01:35:32 +0000 (20:35 -0500)]
Account for auto-borrows and precedence in `redundant_slicing` lint

2 years agoImprove `redundant_slicing` lint
Jason Newcomb [Mon, 3 Jan 2022 20:25:00 +0000 (15:25 -0500)]
Improve `redundant_slicing` lint

* Lint when slicing triggers auto-deref
* Lint when slicing returns the same type as dereferencing

2 years agoDon't lint `needless_borrow` in method receiver positions
Jason Newcomb [Thu, 17 Feb 2022 04:14:39 +0000 (23:14 -0500)]
Don't lint `needless_borrow` in method receiver positions

2 years agoAuto merge of #8188 - jamesmcm:recursive_display_impl, r=camsteffen
bors [Wed, 16 Feb 2022 22:01:49 +0000 (22:01 +0000)]
Auto merge of #8188 - jamesmcm:recursive_display_impl, r=camsteffen

new lint: `recursive_format_impl`

The to_string_in_display lint is renamed to recursive_format_impl
A check is added for the use of self formatted with Display or Debug inside any format string in the same impl
The to_string_in_display check is kept as is - like in the format_in_format_args lint

This is my first contribution so please check it for better / more idiomatic checks + error messages. Note the format macro paths are shared with the `format_in_format_args` lint - maybe those could be moved to clippy utils too.

This relates to issues #2691 and #7830

------

changelog: Renamed `to_string_in_display` lint to [`recursive_format_impl`] with new check for any use of self as Display or Debug inside the same format trait impl.

2 years agoCorrectly mark the span of captured arguments in `format_args!()`
Chayim Refael Friedman [Wed, 16 Feb 2022 00:38:04 +0000 (00:38 +0000)]
Correctly mark the span of captured arguments in `format_args!()`

It should only include the identifier, or misspelling suggestions will be wrong.

2 years agoRollup merge of #94014 - flip1995:clippy_transmute_lint_regroup, r=dtolnay
Matthias Krüger [Tue, 15 Feb 2022 15:02:37 +0000 (16:02 +0100)]
Rollup merge of #94014 - flip1995:clippy_transmute_lint_regroup, r=dtolnay

Move transmute_undefined_repr back to nursery

There's still open discussion if this lint is ready to be enabled by
default. We want to give us more time to figure this out and prevent
this lint from getting to stable as an enabled-by-default lint.

cc https://github.com/rust-lang/rust-clippy/pull/8432

r? `@Manishearth` `@dtolnay`

I think this is the way to go here. We can re-enable this lint with the next sync, if we should decide to do so. But I would hold of for this release.

We have until Friday (beta branching) to decide if we want to merge this.

2 years agoMove transmute_undefined_repr back to nursery
flip1995 [Tue, 15 Feb 2022 09:54:38 +0000 (10:54 +0100)]
Move transmute_undefined_repr back to nursery

There's still open discussion if this lint is ready to be enabled by
default. We want to give us more time to figure this out and prevent
this lint from getting to stable as an enabled-by-default lint.

2 years agoOverhaul `Const`.
Nicholas Nethercote [Wed, 2 Feb 2022 03:24:45 +0000 (14:24 +1100)]
Overhaul `Const`.

Specifically, rename the `Const` struct as `ConstS` and re-introduce `Const` as
this:
```
pub struct Const<'tcx>(&'tcx Interned<ConstS>);
```
This now matches `Ty` and `Predicate` more closely, including using
pointer-based `eq` and `hash`.

Notable changes:
- `mk_const` now takes a `ConstS`.
- `Const` was copy, despite being 48 bytes. Now `ConstS` is not, so need a
  we need separate arena for it, because we can't use the `Dropless` one any
  more.
- Many `&'tcx Const<'tcx>`/`&Const<'tcx>` to `Const<'tcx>` changes
- Many `ct.ty` to `ct.ty()` and `ct.val` to `ct.val()` changes.
- Lots of tedious sigil fiddling.

2 years agoOverhaul `RegionKind` and `Region`.
Nicholas Nethercote [Fri, 28 Jan 2022 00:25:15 +0000 (11:25 +1100)]
Overhaul `RegionKind` and `Region`.

Specifically, change `Region` from this:
```
pub type Region<'tcx> = &'tcx RegionKind;
```
to this:
```
pub struct Region<'tcx>(&'tcx Interned<RegionKind>);
```

This now matches `Ty` and `Predicate` more closely.

Things to note
- Regions have always been interned, but we haven't been using pointer-based
  `Eq` and `Hash`. This is now happening.
- I chose to impl `Deref` for `Region` because it makes pattern matching a lot
  nicer, and `Region` can be viewed as just a smart wrapper for `RegionKind`.
- Various methods are moved from `RegionKind` to `Region`.
- There is a lot of tedious sigil changes.
- A couple of types like `HighlightBuilder`, `RegionHighlightMode` now have a
  `'tcx` lifetime because they hold a `Ty<'tcx>`, so they can call `mk_region`.
- A couple of test outputs change slightly, I'm not sure why, but the new
  outputs are a little better.

2 years agoOverhaul `TyS` and `Ty`.
Nicholas Nethercote [Tue, 25 Jan 2022 03:13:38 +0000 (14:13 +1100)]
Overhaul `TyS` and `Ty`.

Specifically, change `Ty` from this:
```
pub type Ty<'tcx> = &'tcx TyS<'tcx>;
```
to this
```
pub struct Ty<'tcx>(Interned<'tcx, TyS<'tcx>>);
```
There are two benefits to this.
- It's now a first class type, so we can define methods on it. This
  means we can move a lot of methods away from `TyS`, leaving `TyS` as a
  barely-used type, which is appropriate given that it's not meant to
  be used directly.
- The uniqueness requirement is now explicit, via the `Interned` type.
  E.g. the pointer-based `Eq` and `Hash` comes from `Interned`, rather
  than via `TyS`, which wasn't obvious at all.

Much of this commit is boring churn. The interesting changes are in
these files:
- compiler/rustc_middle/src/arena.rs
- compiler/rustc_middle/src/mir/visit.rs
- compiler/rustc_middle/src/ty/context.rs
- compiler/rustc_middle/src/ty/mod.rs

Specifically:
- Most mentions of `TyS` are removed. It's very much a dumb struct now;
  `Ty` has all the smarts.
- `TyS` now has `crate` visibility instead of `pub`.
- `TyS::make_for_test` is removed in favour of the static `BOOL_TY`,
  which just works better with the new structure.
- The `Eq`/`Ord`/`Hash` impls are removed from `TyS`. `Interned`s impls
  of `Eq`/`Hash` now suffice. `Ord` is now partly on `Interned`
  (pointer-based, for the `Equal` case) and partly on `TyS`
  (contents-based, for the other cases).
- There are many tedious sigil adjustments, i.e. adding or removing `*`
  or `&`. They seem to be unavoidable.

2 years agoAdd recursive_format_impl lint
James McMurray [Tue, 28 Dec 2021 18:27:11 +0000 (19:27 +0100)]
Add recursive_format_impl lint

The to_string_in_display lint is renamed to recursive_format_impl
A check is added for the use of self formatted with Display or Debug
inside any format string in the same impl
The to_string_in_display check is kept as is - like in the
format_in_format_args lint

For now only Display and Debug are checked
This could also be extended to other Format traits (Binary, etc.)

2 years agoAuto merge of #93938 - BoxyUwU:fix_res_self_ty, r=lcnr
bors [Mon, 14 Feb 2022 12:26:43 +0000 (12:26 +0000)]
Auto merge of #93938 - BoxyUwU:fix_res_self_ty, r=lcnr

Make `Res::SelfTy` a struct variant and update docs

I found pattern matching on a `(Option<DefId>, Option<(DefId, bool)>)` to not be super readable, additionally the doc comments on the types in a tuple variant aren't visible anywhere at use sites as far as I can tell (using rust analyzer + vscode)

The docs incorrectly assumed that the `DefId` in `Option<(DefId, bool)>` would only ever be for an impl item and I also found the code examples to be somewhat unclear about which `DefId` was being talked about.

r? `@lcnr` since you reviewed the last PR changing these docs

2 years agoAuto merge of #8425 - Jarcho:transmute_8417, r=giraffate
bors [Mon, 14 Feb 2022 06:58:51 +0000 (06:58 +0000)]
Auto merge of #8425 - Jarcho:transmute_8417, r=giraffate

Fix `transmute_undefined_repr` with single field `#[repr(C)]` structs

Fixes: #8417
The description has also been made more precise.

changelog: Fix `transmute_undefined_repr` with single field `#[repr(C)]` structs
changelog: Move `transmute_undefined_repr` back to `correctness`

2 years agoAuto merge of #8427 - Jarcho:merge_cargo_passes, r=llogiq
bors [Mon, 14 Feb 2022 06:14:02 +0000 (06:14 +0000)]
Auto merge of #8427 - Jarcho:merge_cargo_passes, r=llogiq

Merge cargo lints

changelog: None

2 years agoAuto merge of #8429 - nsunderland1:master, r=llogiq
bors [Mon, 14 Feb 2022 05:55:34 +0000 (05:55 +0000)]
Auto merge of #8429 - nsunderland1:master, r=llogiq

Document `pub` requirement for `new_without_default` lint

fixes #8415

Also adds some UI tests that ensure that `pub` is required on both the struct _and_ the field. The only thing I'm not sure about is that the lint actually [checks](https://github.com/rust-lang/rust-clippy/blob/master/clippy_lints/src/new_without_default.rs#L102) if `new` is _reachable_, not _public_. To the best of my understanding, both the struct and the method need to be public for the method to be reachable for external crates (I certainly didn't manage to craft a counterexample).

changelog: Document `pub` requirement for ``[`new_without_default`]`` lint.

2 years agoDocument `pub` requirement for `new_without_default` lint
nsunderland1 [Mon, 14 Feb 2022 01:07:14 +0000 (17:07 -0800)]
Document `pub` requirement for `new_without_default` lint

2 years agoMerge cargo lints
Jason Newcomb [Sun, 13 Feb 2022 21:54:33 +0000 (16:54 -0500)]
Merge cargo lints

2 years agoFix `transmute_undefined_repr` with single field `#[repr(C)]` structs
Jason Newcomb [Sun, 13 Feb 2022 18:22:17 +0000 (13:22 -0500)]
Fix `transmute_undefined_repr` with single field `#[repr(C)]` structs

2 years agoAuto merge of #8421 - Alexendoo:paths, r=llogiq
bors [Sat, 12 Feb 2022 17:24:57 +0000 (17:24 +0000)]
Auto merge of #8421 - Alexendoo:paths, r=llogiq

Replace a few paths with diagnostic items

A fairly small change towards #5393

changelog: none

2 years agoReplace a few paths with diagnostic items
Alex Macleod [Sat, 12 Feb 2022 11:44:28 +0000 (11:44 +0000)]
Replace a few paths with diagnostic items

2 years agochange to a struct variant
Ellen [Wed, 9 Feb 2022 11:03:27 +0000 (11:03 +0000)]
change to a struct variant

2 years agoAuto merge of #8418 - dtolnay-contrib:transmuteundefinedrepr, r=llogiq
bors [Sat, 12 Feb 2022 07:22:13 +0000 (07:22 +0000)]
Auto merge of #8418 - dtolnay-contrib:transmuteundefinedrepr, r=llogiq

Downgrade transmute_undefined_repr to nursery

Reason: #8417. I am skeptical of this lint but maybe there is a narrower subset of types on which it is useful, so keeping it for now but moving to nursery for further development.

---

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

changelog: Remove [`transmute_undefined_repr`] from default set of enabled lints

2 years agoDowngrade transmute_undefined_repr lint to nursery
David Tolnay [Sat, 12 Feb 2022 03:40:07 +0000 (19:40 -0800)]
Downgrade transmute_undefined_repr lint to nursery

2 years agoBless clippy test.
Camille GILLOT [Fri, 28 Jan 2022 17:14:18 +0000 (18:14 +0100)]
Bless clippy test.

2 years agoAuto merge of #93893 - oli-obk:sad_revert, r=oli-obk
bors [Fri, 11 Feb 2022 17:39:34 +0000 (17:39 +0000)]
Auto merge of #93893 - oli-obk:sad_revert, r=oli-obk

Revert lazy TAIT PR

Revert https://github.com/rust-lang/rust/pull/92306 (sorry `@Aaron1011,` will include your changes in the fix PR)
Revert https://github.com/rust-lang/rust/pull/93783
Revert https://github.com/rust-lang/rust/pull/92007

fixes https://github.com/rust-lang/rust/issues/93788
fixes https://github.com/rust-lang/rust/issues/93794
fixes https://github.com/rust-lang/rust/issues/93821
fixes https://github.com/rust-lang/rust/issues/93831
fixes https://github.com/rust-lang/rust/issues/93841

2 years agoAuto merge of #8411 - Alexendoo:dbg_macro, r=flip1995
bors [Fri, 11 Feb 2022 16:39:00 +0000 (16:39 +0000)]
Auto merge of #8411 - Alexendoo:dbg_macro, r=flip1995

Migrate `dbg_macro` to late pass

changelog: Make `dbg_macro` work with crate level attributes and inside macro calls

One down for #6610, fixes #7275

Also fixes #7274, and adds parenthesis around the suggestion for `dbg!(1, 2, 3)` as it expands to a tuple

2 years agoMigrate `dbg_macro` to late pass
Alex Macleod [Fri, 11 Feb 2022 14:45:56 +0000 (14:45 +0000)]
Migrate `dbg_macro` to late pass

2 years agoRevert "Auto merge of #92007 - oli-obk:lazy_tait2, r=nikomatsakis"
Oli Scherer [Fri, 11 Feb 2022 07:18:06 +0000 (07:18 +0000)]
Revert "Auto merge of #92007 - oli-obk:lazy_tait2, r=nikomatsakis"

This reverts commit e7cc3bddbe0d0e374d05e7003e662bba1742dbae, reversing
changes made to 734368a200904ef9c21db86c595dc04263c87be0.

2 years agoClippy: Fix botstrap fallout
flip1995 [Thu, 10 Feb 2022 18:52:01 +0000 (19:52 +0100)]
Clippy: Fix botstrap fallout

2 years agoMerge commit '57b3c4b90f4346b3990c1be387c3b3ca7b78412c' into clippyup
flip1995 [Thu, 10 Feb 2022 17:40:06 +0000 (18:40 +0100)]
Merge commit '57b3c4b90f4346b3990c1be387c3b3ca7b78412c' into clippyup

2 years agoAuto merge of #8409 - flip1995:rustup, r=flip1995
bors [Thu, 10 Feb 2022 17:14:39 +0000 (17:14 +0000)]
Auto merge of #8409 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: none

2 years agoBump nightly version -> 2022-02-10
flip1995 [Thu, 10 Feb 2022 17:11:49 +0000 (18:11 +0100)]
Bump nightly version -> 2022-02-10

2 years agoMerge remote-tracking branch 'upstream/master' into rustup
flip1995 [Thu, 10 Feb 2022 17:11:27 +0000 (18:11 +0100)]
Merge remote-tracking branch 'upstream/master' into rustup

2 years agoAuto merge of #8404 - camsteffen:rm-ui-test, r=flip1995
bors [Wed, 9 Feb 2022 09:09:58 +0000 (09:09 +0000)]
Auto merge of #8404 - camsteffen:rm-ui-test, r=flip1995

Factor out ui_test suite

changelog: none

2 years agoRollup merge of #93746 - cjgillot:nodefii, r=nikomatsakis
Yuki Okushi [Wed, 9 Feb 2022 05:12:22 +0000 (14:12 +0900)]
Rollup merge of #93746 - cjgillot:nodefii, r=nikomatsakis

Remove defaultness from ImplItem.

This information is not really used anywhere, except HIR pretty-printing. This makes ImplItem and TraitItem more similar.

2 years agoFactor out ui_test suite
Cameron Steffen [Tue, 8 Feb 2022 16:45:52 +0000 (10:45 -0600)]
Factor out ui_test suite

2 years agoAuto merge of #8374 - Alexendoo:bless-revisions, r=camsteffen
bors [Tue, 8 Feb 2022 20:50:41 +0000 (20:50 +0000)]
Auto merge of #8374 - Alexendoo:bless-revisions, r=camsteffen

Support `cargo dev bless` for tests with revisions

changelog: internal: Support `cargo dev bless` for tests with revisions

Previously bless wouldn't pick up the saved stderr from `target/debug/tests/manual_assert.stage-id.edition2021.stderr` or `target/debug/tests/manual_assert.stage-id.edition2018.stderr` due to there being multiple revisions of the test output

This tweaks compile-test so the built files end up in e.g. `target/debug/tests/ui`, `target/debug/tests/ui-cargo` rather than share the `tests` dir. `cargo dev bless` then uses that to update all the `.stdout/stdout/fixed` files it can find

Also removes an empty file I found, and the logic to remove empty outputs as compiletest doesn't produce empty `.stdout/stderr` files

2 years agoAuto merge of #8400 - Jarcho:split_matches, r=Manishearth
bors [Mon, 7 Feb 2022 20:10:07 +0000 (20:10 +0000)]
Auto merge of #8400 - Jarcho:split_matches, r=Manishearth

Split matches

Part of #6680

changelog: None

2 years agoSplit out `wild_in_or_pats`
Jason Newcomb [Mon, 7 Feb 2022 18:00:19 +0000 (13:00 -0500)]
Split out `wild_in_or_pats`

2 years agoSplit out `rest_pat_in_fully_bound_struct`
Jason Newcomb [Mon, 7 Feb 2022 17:57:02 +0000 (12:57 -0500)]
Split out `rest_pat_in_fully_bound_struct`

2 years agoSplit out `infalliable_detructuring_match`
Jason Newcomb [Mon, 7 Feb 2022 17:28:57 +0000 (12:28 -0500)]
Split out `infalliable_detructuring_match`

2 years agoSplit out `match_ref_pats`
Jason Newcomb [Sun, 6 Feb 2022 21:44:52 +0000 (16:44 -0500)]
Split out `match_ref_pats`

2 years agoSplit out `match_single_binding`
Jason Newcomb [Sun, 6 Feb 2022 21:38:34 +0000 (16:38 -0500)]
Split out `match_single_binding`

2 years agoSplit out `match_as_ref`
Jason Newcomb [Sun, 6 Feb 2022 21:24:14 +0000 (16:24 -0500)]
Split out `match_as_ref`

2 years agoSplit out `wildcard_enum_match_arm` and `match_wildcard_for_single_variants`
Jason Newcomb [Sun, 6 Feb 2022 21:18:05 +0000 (16:18 -0500)]
Split out `wildcard_enum_match_arm` and `match_wildcard_for_single_variants`

2 years agoSplit out `match_wild_err_arm`
Jason Newcomb [Sun, 6 Feb 2022 21:08:05 +0000 (16:08 -0500)]
Split out `match_wild_err_arm`

2 years agoSplit out `overlapping_arms`
Jason Newcomb [Sun, 6 Feb 2022 19:36:24 +0000 (14:36 -0500)]
Split out `overlapping_arms`

2 years agoSplit out `match_bool`
Jason Newcomb [Sun, 6 Feb 2022 19:25:53 +0000 (14:25 -0500)]
Split out `match_bool`

2 years agoSplit out `single_match`
Jason Newcomb [Sun, 6 Feb 2022 19:18:00 +0000 (14:18 -0500)]
Split out `single_match`

2 years agoSplit out `redundant_pattern_match`
Jason Newcomb [Sun, 6 Feb 2022 19:03:45 +0000 (14:03 -0500)]
Split out `redundant_pattern_match`

2 years agoSplit out `match_same_arms`
Jason Newcomb [Sun, 6 Feb 2022 18:53:51 +0000 (13:53 -0500)]
Split out `match_same_arms`

2 years agoSplit out `match_like_matches_macro`
Jason Newcomb [Sun, 6 Feb 2022 18:42:17 +0000 (13:42 -0500)]
Split out `match_like_matches_macro`

2 years agoMove `matches.rs` to `mod.rs`
Jason Newcomb [Sun, 6 Feb 2022 18:35:57 +0000 (13:35 -0500)]
Move `matches.rs` to `mod.rs`