]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoTrigger `wrong_self_convention` only if it has implicit self
ThibsG [Thu, 13 May 2021 08:24:29 +0000 (10:24 +0200)]
Trigger `wrong_self_convention` only if it has implicit self

3 years agoFix test comment for `while_let_on_iterator`
Jason Newcomb [Thu, 13 May 2021 01:41:59 +0000 (21:41 -0400)]
Fix test comment for `while_let_on_iterator`

3 years agoCleanup of `while_let_on_iterator`
Jason Newcomb [Tue, 13 Apr 2021 13:30:01 +0000 (09:30 -0400)]
Cleanup of `while_let_on_iterator`

3 years agoImprovements to `while_let_on_iterator`
Jason Newcomb [Wed, 24 Mar 2021 13:32:29 +0000 (09:32 -0400)]
Improvements to `while_let_on_iterator`

* Suggest `&mut iter` when the iterator is used after the loop.
* Suggest `&mut iter` when the iterator is a field in a struct.
* Don't lint when the iterator is a field in a struct, and the struct is
used in the loop.
* Lint when the loop is nested in another loop, but suggest `&mut iter`
unless the iterator is from a local declared inside the loop.

3 years agomatch_single_binding: Fix invalid suggestion when match scrutinee has side effects
Yoshitomo Nakanishi [Fri, 16 Apr 2021 07:07:20 +0000 (16:07 +0900)]
match_single_binding: Fix invalid suggestion when match scrutinee has side effects

3 years agoAdded `cargo collect-metadata` as a alias for the metadata collection lint
xFrednet [Wed, 12 May 2021 23:41:22 +0000 (01:41 +0200)]
Added `cargo collect-metadata` as a alias for the metadata collection lint

3 years agoShow macro name in 'this error originates in macro' message
Aaron Hill [Sat, 13 Feb 2021 19:52:25 +0000 (14:52 -0500)]
Show macro name in 'this error originates in macro' message

When there are multiple macros in use, it can be difficult to tell
which one was responsible for producing an error.

3 years agoMetadata collection collecting configuration deprecation reason
xFrednet [Wed, 12 May 2021 16:47:32 +0000 (18:47 +0200)]
Metadata collection collecting configuration deprecation reason

3 years agoMetadata collection clarifying default configuration values
xFrednet [Wed, 12 May 2021 15:30:04 +0000 (17:30 +0200)]
Metadata collection clarifying default configuration values

3 years agoMetadata formatting the configuration section
xFrednet [Tue, 11 May 2021 19:47:10 +0000 (21:47 +0200)]
Metadata formatting the configuration section

3 years agoMetadata collection monster searching for configurations
xFrednet [Tue, 11 May 2021 18:23:52 +0000 (20:23 +0200)]
Metadata collection monster searching for configurations

3 years agoUse () for inherent_impls.
Camille GILLOT [Tue, 11 May 2021 11:39:19 +0000 (13:39 +0200)]
Use () for inherent_impls.

3 years agoUse () for entry_fn.
Camille GILLOT [Tue, 11 May 2021 10:00:59 +0000 (12:00 +0200)]
Use () for entry_fn.

3 years agoUse () for HIR queries.
Camille GILLOT [Tue, 11 May 2021 09:42:01 +0000 (11:42 +0200)]
Use () for HIR queries.

3 years agoAuto merge of #83813 - cbeuw:remap-std, r=michaelwoerister
bors [Wed, 12 May 2021 11:05:56 +0000 (11:05 +0000)]
Auto merge of #83813 - cbeuw:remap-std, r=michaelwoerister

Fix `--remap-path-prefix` not correctly remapping `rust-src` component paths and unify handling of path mapping with virtualized paths

This PR fixes #73167 ("Binaries end up containing path to the rust-src component despite `--remap-path-prefix`") by preventing real local filesystem paths from reaching compilation output if the path is supposed to be remapped.

`RealFileName::Named` introduced in #72767 is now renamed as `LocalPath`, because this variant wraps a (most likely) valid local filesystem path.

`RealFileName::Devirtualized` is renamed as `Remapped` to be used for remapped path from a real path via `--remap-path-prefix` argument, as well as real path inferred from a virtualized (during compiler bootstrapping) `/rustc/...` path. The `local_path` field is now an `Option<PathBuf>`, as it will be set to `None` before serialisation, so it never reaches any build output. Attempting to serialise a non-`None` `local_path` will cause an assertion faliure.

When a path is remapped, a `RealFileName::Remapped` variant is created. The original path is preserved in `local_path` field and the remapped path is saved in `virtual_name` field. Previously, the `local_path` is directly modified which goes against its purpose of "suitable for reading from the file system on the local host".

`rustc_span::SourceFile`'s fields `unmapped_path` (introduced by #44940) and `name_was_remapped` (introduced by #41508 when `--remap-path-prefix` feature originally added) are removed, as these two pieces of information can be inferred from the `name` field: if it's anything other than a `FileName::Real(_)`, or if it is a `FileName::Real(RealFileName::LocalPath(_))`, then clearly `name_was_remapped` would've been false and `unmapped_path` would've been `None`. If it is a `FileName::Real(RealFileName::Remapped{local_path, virtual_name})`, then `name_was_remapped` would've been true and `unmapped_path` would've been `Some(local_path)`.

cc `@eddyb` who implemented `/rustc/...` path devirtualisation

3 years agoAuto merge of #7197 - xFrednet:4310-depreciated-lints-collection, r=flip1995
bors [Wed, 12 May 2021 08:01:10 +0000 (08:01 +0000)]
Auto merge of #7197 - xFrednet:4310-depreciated-lints-collection, r=flip1995

Metadata collection monster eating deprecated lints

This adds the collection of deprecated lints to the metadata collection monster. The JSON output has the same structure with the *new* lint group "DEPRECATED". Here is one of fourteen examples it was able to dig up in Clippy's code:

```JSON
  {
    "id": "assign_op_pattern",
    "id_span": {
      "path": "src/assign_ops.rs",
      "line": 34
    },
    "group": "clippy::style",
    "docs": " **What it does:** Checks for `a = a op b` or `a = b commutative_op a` patterns.\n\n **Why is this bad?** These can be written as the shorter `a op= b`.\n\n **Known problems:** While forbidden by the spec, `OpAssign` traits may have\n implementations that differ from the regular `Op` impl.\n\n **Example:**\n ```rust\n let mut a = 5;\n let b = 0;\n // ...\n // Bad\n a = a + b;\n\n // Good\n a += b;\n ```\n",
    "applicability": {
      "is_multi_part_suggestion": false,
      "applicability": "MachineApplicable"
    }
  }
```

And you! Yes you! Sir or Madam can get all of this **for free** in Clippy if this PR gets merged. (Sorry for the silliness ^^)

---

See: #7172 for the full metadata collection to-do list or to suggest a new feature in connection to it :upside_down_face:

---

changelog: none

r? `@flip1995`

3 years agoImplement span quoting for proc-macros
Aaron Hill [Sun, 2 Aug 2020 23:52:16 +0000 (19:52 -0400)]
Implement span quoting for proc-macros

This PR implements span quoting, allowing proc-macros to produce spans
pointing *into their own crate*. This is used by the unstable
`proc_macro::quote!` macro, allowing us to get error messages like this:

```
error[E0412]: cannot find type `MissingType` in this scope
  --> $DIR/auxiliary/span-from-proc-macro.rs:37:20
   |
LL | pub fn error_from_attribute(_args: TokenStream, _input: TokenStream) -> TokenStream {
   | ----------------------------------------------------------------------------------- in this expansion of procedural macro `#[error_from_attribute]`
...
LL |             field: MissingType
   |                    ^^^^^^^^^^^ not found in this scope
   |
  ::: $DIR/span-from-proc-macro.rs:8:1
   |
LL | #[error_from_attribute]
   | ----------------------- in this macro invocation
```

Here, `MissingType` occurs inside the implementation of the proc-macro
`#[error_from_attribute]`. Previosuly, this would always result in a
span pointing at `#[error_from_attribute]`

This will make many proc-macro-related error message much more useful -
when a proc-macro generates code containing an error, users will get an
error message pointing directly at that code (within the macro
definition), instead of always getting a span pointing at the macro
invocation site.

This is implemented as follows:
* When a proc-macro crate is being *compiled*, it causes the `quote!`
  macro to get run. This saves all of the sapns in the input to `quote!`
  into the metadata of *the proc-macro-crate* (which we are currently
  compiling). The `quote!` macro then expands to a call to
  `proc_macro::Span::recover_proc_macro_span(id)`, where `id` is an
opaque identifier for the span in the crate metadata.
* When the same proc-macro crate is *run* (e.g. it is loaded from disk
  and invoked by some consumer crate), the call to
`proc_macro::Span::recover_proc_macro_span` causes us to load the span
from the proc-macro crate's metadata. The proc-macro then produces a
`TokenStream` containing a `Span` pointing into the proc-macro crate
itself.

The recursive nature of 'quote!' can be difficult to understand at
first. The file `src/test/ui/proc-macro/quote-debug.stdout` shows
the output of the `quote!` macro, which should make this eaier to
understand.

This PR also supports custom quoting spans in custom quote macros (e.g.
the `quote` crate). All span quoting goes through the
`proc_macro::quote_span` method, which can be called by a custom quote
macro to perform span quoting. An example of this usage is provided in
`src/test/ui/proc-macro/auxiliary/custom-quote.rs`

Custom quoting currently has a few limitations:

In order to quote a span, we need to generate a call to
`proc_macro::Span::recover_proc_macro_span`. However, proc-macros
support renaming the `proc_macro` crate, so we can't simply hardcode
this path. Previously, the `quote_span` method used the path
`crate::Span` - however, this only works when it is called by the
builtin `quote!` macro in the same crate. To support being called from
arbitrary crates, we need access to the name of the `proc_macro` crate
to generate a path. This PR adds an additional argument to `quote_span`
to specify the name of the `proc_macro` crate. Howver, this feels kind
of hacky, and we may want to change this before stabilizing anything
quote-related.

Additionally, using `quote_span` currently requires enabling the
`proc_macro_internals` feature. The builtin `quote!` macro
has an `#[allow_internal_unstable]` attribute, but this won't work for
custom quote implementations. This will likely require some additional
tricks to apply `allow_internal_unstable` to the span of
`proc_macro::Span::recover_proc_macro_span`.

3 years agoadded `needless_bitwise_bool` lint
Arya Kumar [Tue, 11 May 2021 19:34:14 +0000 (19:34 +0000)]
added `needless_bitwise_bool` lint

3 years agoUpdate clippy_lints/src/deprecated_lints.rs
Fridtjof Stoldt [Mon, 10 May 2021 10:24:24 +0000 (12:24 +0200)]
Update clippy_lints/src/deprecated_lints.rs

Co-authored-by: Philipp Krones <hello@philkrones.com>
3 years agoAuto merge of #7193 - wchargin:wchargin-inconsistent-struct-constructor-pedantic...
bors [Tue, 11 May 2021 12:44:58 +0000 (12:44 +0000)]
Auto merge of #7193 - wchargin:wchargin-inconsistent-struct-constructor-pedantic, r=camsteffen

Move `inconsistent_struct_constructor` to pedantic

The whole point of named fields is that we don't have to worry about
order. The names, not the position, communicate the information, so
worrying about consistency for consistency's sake is pedantic to a *T*.

Cf. #7192.

changelog: [`inconsistent_struct_constructor`] is moved to pedantic.

wchargin-branch: inconsistent-struct-constructor-pedantic

3 years agoAuto merge of #85109 - RalfJung:remove-const_fn, r=oli-obk
bors [Tue, 11 May 2021 10:25:14 +0000 (10:25 +0000)]
Auto merge of #85109 - RalfJung:remove-const_fn, r=oli-obk

remove const_fn feature gate

Fixes https://github.com/rust-lang/rust/issues/84510
r? `@oli-obk`

3 years agofix clippy test
Ralf Jung [Mon, 10 May 2021 22:40:25 +0000 (00:40 +0200)]
fix clippy test

3 years agoAuto merge of #7203 - flip1995:beta, r=llogiq
bors [Mon, 10 May 2021 10:14:38 +0000 (10:14 +0000)]
Auto merge of #7203 - flip1995:beta, r=llogiq

Backport #7170 to beta

changelog: none (fixes stack overflow, but this was introduced in this release cycle)

3 years agoAuto merge of #85053 - camsteffen:duplicate-lint, r=davidtwco
bors [Mon, 10 May 2021 09:45:28 +0000 (09:45 +0000)]
Auto merge of #85053 - camsteffen:duplicate-lint, r=davidtwco

Fix duplicate unknown lint errors

Fixes rust-lang/rust-clippy#6602

3 years agoAuto merge of #7170 - flip1995:revert_drop_order, r=llogiq
bors [Wed, 5 May 2021 17:33:46 +0000 (17:33 +0000)]
Auto merge of #7170 - flip1995:revert_drop_order, r=llogiq

Fix stack overflow issue in `redundant_pattern_matching`

Fixes #7169

~~cc `@Jarcho` Since tomorrow is release day and we need to get this also fixed in beta, I'll just revert the PR instead of looking into the root issue. Your changes are good, so if you have an idea what could cause this stack overflow and know how to fix it, please open a PR that reverts this revert with a fix.~~

r? `@llogiq`

changelog: none (fixes stack overflow, but this was introduced in this release cycle)

3 years agoMetadata collection monster eating deprecated lints
xFrednet [Sat, 8 May 2021 11:29:59 +0000 (13:29 +0200)]
Metadata collection monster eating deprecated lints

3 years agoMove `inconsistent_struct_constructor` to pedantic
William Chargin [Sat, 8 May 2021 03:24:07 +0000 (20:24 -0700)]
Move `inconsistent_struct_constructor` to pedantic

The whole point of named fields is that we don't have to worry about
order. The names, not the position, communicate the information, so
worrying about consistency for consistency's sake is pedantic to a *T*.

Fixes #7192.

wchargin-branch: inconsistent-struct-constructor-pedantic
wchargin-source: 4fe078a21c77ceb625e58fa3b90b613fc4fa6a76

3 years agoAuto merge of #7165 - camsteffen:question-mark, r=Manishearth
bors [Sat, 8 May 2021 00:04:14 +0000 (00:04 +0000)]
Auto merge of #7165 - camsteffen:question-mark, r=Manishearth

Fix needless_quesiton_mark false positive

changelog: Fix [`needless_question_mark`] false positive where the inner value is implicity dereferenced by the question mark.

Fixes #7107

3 years agoFix duplicate unknown lint errors
Cameron Steffen [Fri, 7 May 2021 19:53:02 +0000 (14:53 -0500)]
Fix duplicate unknown lint errors

3 years agoneedless_collect: Lint `LinkedList` and `BinaryHeap` in direct usage.
Mateusz Gacek [Wed, 5 May 2021 19:17:49 +0000 (12:17 -0700)]
needless_collect: Lint `LinkedList` and `BinaryHeap` in direct usage.

Those two types are supported already when used indirectly.
This commit adds support for direct usage as well.

3 years agoneedless_collect: replace paths with diag items
Mateusz Gacek [Wed, 5 May 2021 19:16:57 +0000 (12:16 -0700)]
needless_collect: replace paths with diag items

Related to: #5393

3 years agoneedless_collect: For `BTreeMap` and `HashMap` lint only `is_empty`
Mateusz Gacek [Wed, 5 May 2021 19:08:24 +0000 (12:08 -0700)]
needless_collect: For `BTreeMap` and `HashMap` lint only `is_empty`

- `len` might produce different results than `count`
- they don't have `contain` but `contains_key` method

3 years agoAuto merge of #7183 - th1000s:write_nl_hint, r=flip1995
bors [Fri, 7 May 2021 12:13:35 +0000 (12:13 +0000)]
Auto merge of #7183 - th1000s:write_nl_hint, r=flip1995

Handle write!(buf, "\n") case better

Make `write!(buf, "\n")` suggest `writeln!(buf)` by removing
the trailing comma from `writeln!(buf, )`.

changelog: [`write_with_newline`] suggestion on only "\n" improved

3 years agoAuto merge of #7182 - mgacek8:wrong_self_convention_to__variant, r=flip1995
bors [Fri, 7 May 2021 08:32:06 +0000 (08:32 +0000)]
Auto merge of #7182 - mgacek8:wrong_self_convention_to__variant, r=flip1995

For `to_*` variant don't lint in trait impl taking `self` when non-`Copy` type

Lint name: `wrong_self_convention`.
It relaxes rules for `to_*` variant, so it doesn't lint in trait definitions and implementations anymore.
Although, non-`Copy` type implementing trait's `to_*` method taking
`self` feels not good (consumes ownership, so should be rather named `into_`), it would be better if this case was a pedantic lint (allow-by-default) instead.
More information in the discussion with `@flip1995` [here](https://github.com/rust-lang/rust-clippy/pull/7002#discussion_r627363450)

changelog: `wrong_self_convention`: For `to_*` variant don't lint in trait impl taking `self` when non-`Copy` type
r? `@flip1995`

3 years agoAuto merge of #7185 - kpreid:patch-1, r=giraffate
bors [Fri, 7 May 2021 02:05:54 +0000 (02:05 +0000)]
Auto merge of #7185 - kpreid:patch-1, r=giraffate

Fix duplicated "Rust 1.52" version section header

The most recent changelog update 037ddf282bbf011babd4b7f9a851f6028fc6fd70 accompanying the 1.52 release added a second "Rust 1.52" section header, with the result that the Rust release announcement https://blog.rust-lang.org/2021/05/06/Rust-1.52.0.html is linking to the "current beta" changelog section for Clippy rather than the stable changelog. I don't know the release process but based on previous changes to this file, I assume the correct thing to do is to mark the topmost section as being for Rust 1.53, not 1.52.

changelog: none

3 years agoFix duplicated "Rust 1.52" version section header
Kevin Reid [Fri, 7 May 2021 00:18:45 +0000 (17:18 -0700)]
Fix duplicated "Rust 1.52" version section header

The most recent changelog update 037ddf282bbf011babd4b7f9a851f6028fc6fd70 accompanying the 1.52 release added a second "Rust 1.52" section header, with the result that the Rust release announcement https://blog.rust-lang.org/2021/05/06/Rust-1.52.0.html is linking to the "current beta" changelog section for Clippy rather than the stable changelog. I don't know the release process but based on previous changes to this file, I assume the correct thing to do is to mark the topmost section as being for Rust 1.53, not 1.52.

3 years agoHandle write!(buf, "\n") case better
Thomas Otto [Thu, 6 May 2021 21:51:01 +0000 (23:51 +0200)]
Handle write!(buf, "\n") case better

Make `write!(buf, "\n")` suggest `writeln!(buf)` by removing
the trailing comma from `writeln!(buf, )`.

changelog: [`write_with_newline`] suggestion on only "\n" improved

3 years agoFix clippy
Scott McMurray [Sat, 1 May 2021 01:40:34 +0000 (18:40 -0700)]
Fix clippy

3 years agowrong_self_convention: For `to_*` variant don't lint in trait impl taking `self`...
Mateusz Gacek [Thu, 6 May 2021 17:49:31 +0000 (10:49 -0700)]
wrong_self_convention: For `to_*` variant don't lint in trait impl taking `self` when non-`Copy` type

It relaxes rules for `to_*` variant, so it doesn't lint in trait definitions
and implementations anymore.
Although, non-`Copy` type implementing trait's `to_*` method taking
`self` feels not good (consumes ownership, so should be rather named `into_`), it would be better if this case was a pedantic lint (allow-by-default) instead.

3 years agoAuto merge of #7180 - flip1995:changelog, r=camsteffen
bors [Thu, 6 May 2021 16:03:45 +0000 (16:03 +0000)]
Auto merge of #7180 - flip1995:changelog, r=camsteffen

Update CHANGELOG.md

This changelog is **big**. :tada:

[Rendered](https://github.com/flip1995/rust-clippy/blob/changelog/CHANGELOG.md)

changelog: none

3 years agoUpdate CHANGELOG.md
flip1995 [Thu, 6 May 2021 13:22:17 +0000 (15:22 +0200)]
Update CHANGELOG.md

3 years agoMerge commit 'b71f3405606d49b9735606b479c3415a0ca9810f' into clippyup
flip1995 [Thu, 6 May 2021 09:51:22 +0000 (11:51 +0200)]
Merge commit 'b71f3405606d49b9735606b479c3415a0ca9810f' into clippyup

3 years agoAuto merge of #7178 - flip1995:rustup, r=flip1995
bors [Thu, 6 May 2021 09:45:37 +0000 (09:45 +0000)]
Auto merge of #7178 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: none

3 years agoBump Clippy version -> 0.1.54
flip1995 [Thu, 6 May 2021 09:32:34 +0000 (11:32 +0200)]
Bump Clippy version -> 0.1.54

3 years agoBump nightly version -> 2021-05-06
flip1995 [Thu, 6 May 2021 09:32:27 +0000 (11:32 +0200)]
Bump nightly version -> 2021-05-06

3 years agoMerge remote-tracking branch 'upstream/master' into rustup
flip1995 [Thu, 6 May 2021 09:22:33 +0000 (11:22 +0200)]
Merge remote-tracking branch 'upstream/master' into rustup

3 years agoAuto merge of #7177 - giraffate:add_a_missing_lint_to_msrv_config_doc, r=flip1995
bors [Thu, 6 May 2021 08:43:36 +0000 (08:43 +0000)]
Auto merge of #7177 - giraffate:add_a_missing_lint_to_msrv_config_doc, r=flip1995

Add a missing lint to MSRV config doc

A follow-up of https://github.com/rust-lang/rust-clippy/pull/6859.

changelog: Add a missing lint to MSRV config doc

3 years agoAuto merge of #7166 - TaKO8Ki:refactor_misc_early_module, r=llogiq
bors [Thu, 6 May 2021 07:46:52 +0000 (07:46 +0000)]
Auto merge of #7166 - TaKO8Ki:refactor_misc_early_module, r=llogiq

Refactor: arrange lints in misc_early module

This PR arranges misc_early lints so that they can be accessed more easily.
Basically, I refactored them following the instruction described in #6680.

cc: `@Y-Nak,` `@flip1995,` `@magurotuna`

changelog: Move lints in misc_early module into their own modules.

3 years agoAdd a missing lint to MSRV config doc
Takayuki Nakata [Thu, 6 May 2021 05:04:50 +0000 (14:04 +0900)]
Add a missing lint to MSRV config doc

3 years agoAuto merge of #7175 - camsteffen:filter-map-none, r=Manishearth
bors [Wed, 5 May 2021 22:57:05 +0000 (22:57 +0000)]
Auto merge of #7175 - camsteffen:filter-map-none, r=Manishearth

Fix unnecessary_filter_map false positive

changelog: Fix an [`unnecessary_filter_map`] false positive

Fixes #6804

3 years agoFix unnecessary_filter_map false positive
Cameron Steffen [Wed, 5 May 2021 21:05:16 +0000 (16:05 -0500)]
Fix unnecessary_filter_map false positive

3 years agoAuto merge of #7174 - camsteffen:eval-order-async, r=flip1995
bors [Wed, 5 May 2021 21:18:05 +0000 (21:18 +0000)]
Auto merge of #7174 - camsteffen:eval-order-async, r=flip1995

Fix eval_order_dependence async false positive

changelog: Fix [`eval_order_dependence`] false positive in async code

Fixes #6925

3 years agoFix eval_order_dependence async false positive
Cameron Steffen [Wed, 5 May 2021 20:02:47 +0000 (15:02 -0500)]
Fix eval_order_dependence async false positive

3 years agoImprove eval_order_dependence output
Cameron Steffen [Wed, 5 May 2021 19:44:32 +0000 (14:44 -0500)]
Improve eval_order_dependence output

3 years agoAuto merge of #7170 - flip1995:revert_drop_order, r=llogiq
bors [Wed, 5 May 2021 17:33:46 +0000 (17:33 +0000)]
Auto merge of #7170 - flip1995:revert_drop_order, r=llogiq

Fix stack overflow issue in `redundant_pattern_matching`

Fixes #7169

~~cc `@Jarcho` Since tomorrow is release day and we need to get this also fixed in beta, I'll just revert the PR instead of looking into the root issue. Your changes are good, so if you have an idea what could cause this stack overflow and know how to fix it, please open a PR that reverts this revert with a fix.~~

r? `@llogiq`

changelog: none (fixes stack overflow, but this was introduced in this release cycle)

3 years agoAuto merge of #6887 - xFrednet:4310-internal-metadata-extraction-lint, r=xFrednet
bors [Wed, 5 May 2021 17:11:14 +0000 (17:11 +0000)]
Auto merge of #6887 - xFrednet:4310-internal-metadata-extraction-lint, r=xFrednet

A metadata collection monster

This PR introduces a metadata collection lint as discussed in #4310. It currently collects:
* The lint ID
* The lint declaration file and location (for #1303)
* The lint group
* The documentation
* The applicability (if resolvable)
* If the suggestion is a multi-part-suggestion

This data has a slightly different structure than the current [lints.json](https://github.com/rust-lang/rust-clippy/blob/gh-pages/master/lints.json) and doesn't include depreciated lints yet. I plan to adapt the website to the new format and include depreciated lints in a follow-up PR :). The current collected json looks like this: [metadata_collection.json](https://gist.github.com/xFrednet/6b9e2c3f725f476ba88db9563f67e119)

The entire implementation is guarded behind the `metadata-collector-lint` feature and the `ENABLE_METADATA_COLLECTION` environment value to prevent default collection. You can test the implementation via:
```sh
$ ENABLE_METADATA_COLLECTION=1 cargo test --test dogfood --all-features
```

changelog: none

---

The size of this PR sadly also grew into a small monster, sorry! I definitely plan to improve on this! And it's totally okay if you take your time with this :)

r? `@phansch`
cc: `@flip1995`

3 years agoApplying PR suggestions (mostly typos)
xFrednet [Wed, 31 Mar 2021 18:03:38 +0000 (20:03 +0200)]
Applying PR suggestions (mostly typos)
Co-authored-by: flip1995 <hello@philkrones.com>
Co-authored-by: phansch <dev@phansch.net>
3 years agoApplying PR suggestions
xFrednet [Fri, 12 Mar 2021 19:59:41 +0000 (20:59 +0100)]
Applying PR suggestions

3 years agoENABLE_METADATA_COLLECTION env-value to disable default metadata collection
xFrednet [Fri, 12 Mar 2021 20:52:01 +0000 (21:52 +0100)]
ENABLE_METADATA_COLLECTION env-value to disable default metadata collection

3 years agoMetadata collection: Rounding up the implementation
xFrednet [Wed, 10 Mar 2021 22:04:12 +0000 (23:04 +0100)]
Metadata collection: Rounding up the implementation

3 years agoMetadata collection: Resolve lint from locals
xFrednet [Sat, 6 Mar 2021 00:11:41 +0000 (01:11 +0100)]
Metadata collection: Resolve lint from locals

3 years agoMetadata collection: Refining the implementation
xFrednet [Mon, 1 Mar 2021 11:25:14 +0000 (12:25 +0100)]
Metadata collection: Refining the implementation

3 years agoMetadata collection: processing emission closures (417/455)
xFrednet [Sun, 28 Feb 2021 15:11:45 +0000 (16:11 +0100)]
Metadata collection: processing emission closures (417/455)

3 years agoMetadata Collection: Collecting direct emission applicabilities (324/455)
xFrednet [Sat, 27 Feb 2021 17:39:02 +0000 (18:39 +0100)]
Metadata Collection: Collecting direct emission applicabilities (324/455)

3 years agoMetadata collection: Collecting Applicability assign values
xFrednet [Sat, 20 Feb 2021 12:50:09 +0000 (13:50 +0100)]
Metadata collection: Collecting Applicability assign values

3 years agoMetadata collection: Some refactoring for readability
xFrednet [Sat, 20 Feb 2021 12:12:30 +0000 (13:12 +0100)]
Metadata collection: Some refactoring for readability

3 years agoMetadata collection: Tracking Applicability mut borrows
xFrednet [Fri, 19 Feb 2021 23:35:28 +0000 (00:35 +0100)]
Metadata collection: Tracking Applicability mut borrows

3 years agoMetadata collection: Collecting Applicability assign values
xFrednet [Thu, 18 Feb 2021 22:40:33 +0000 (23:40 +0100)]
Metadata collection: Collecting Applicability assign values

3 years agoMetadata collection lint: Start Applicability value tracking
xFrednet [Wed, 17 Feb 2021 23:20:19 +0000 (00:20 +0100)]
Metadata collection lint: Start Applicability value tracking

3 years agoMetadata collection lint: Basic applicability collection
xFrednet [Sun, 14 Feb 2021 15:17:07 +0000 (16:17 +0100)]
Metadata collection lint: Basic applicability collection

3 years agoMetadata collection lint: Basic lint collection
xFrednet [Sun, 31 Jan 2021 13:46:09 +0000 (14:46 +0100)]
Metadata collection lint: Basic lint collection

WIP-2021-02-01

WIP-2021-02-01

WIP-2021-02-13

3 years agoAuto merge of #7163 - mgacek8:issue7110_needless_collect_with_type_annotations, r...
bors [Wed, 5 May 2021 15:43:02 +0000 (15:43 +0000)]
Auto merge of #7163 - mgacek8:issue7110_needless_collect_with_type_annotations, r=flip1995

needless_collect: Lint cases with type annotations for indirect usage and recognize `BinaryHeap`

fixes #7110
changelog: needless_collect: Lint cases with type annotations for indirect usage and recognize `BinaryHeap`.

3 years agoUse local and remapped paths where appropriate
Andy Wang [Mon, 19 Apr 2021 22:27:02 +0000 (23:27 +0100)]
Use local and remapped paths where appropriate

3 years agoAuto merge of #84200 - CDirkx:os, r=m-ou-se
bors [Wed, 5 May 2021 14:15:19 +0000 (14:15 +0000)]
Auto merge of #84200 - CDirkx:os, r=m-ou-se

Move all `sys::ext` modules to `os`

This PR moves all `sys::ext` modules to `os`, centralizing the location of all `os` code and simplifying the dependencies between `os` and `sys`.

Because this also removes all uses `cfg_if!` on publicly exported items, where after #81969 there were still a few left, this should properly work around https://github.com/rust-analyzer/rust-analyzer/issues/6038.

`@rustbot` label: +T-libs-impl

3 years agoAdd regression test for stack overflow in redundant_pattern_matching
flip1995 [Wed, 5 May 2021 13:35:14 +0000 (15:35 +0200)]
Add regression test for stack overflow in redundant_pattern_matching

3 years agoFix stack overflow in `redundant_pattern_matching`
Cameron Steffen [Wed, 5 May 2021 13:57:09 +0000 (08:57 -0500)]
Fix stack overflow in `redundant_pattern_matching`

3 years agoneedless_collect: use `node_type_opt` instead of `node_type`
Mateusz Gacek [Wed, 5 May 2021 11:52:03 +0000 (04:52 -0700)]
needless_collect: use `node_type_opt` instead of `node_type`

It may prevent future ICEs.

3 years agoAuto merge of #7167 - camsteffen:unused-unit-macro, r=flip1995
bors [Wed, 5 May 2021 11:45:34 +0000 (11:45 +0000)]
Auto merge of #7167 - camsteffen:unused-unit-macro, r=flip1995

Fix unused_unit macro false positive

changelog: Fix [`unused_unit`] false positive with macros

Fixes #7055

3 years agoFix unused_unit macro false positive
Cameron Steffen [Tue, 4 May 2021 22:20:15 +0000 (17:20 -0500)]
Fix unused_unit macro false positive

3 years agoreplace lit_snip type with &str
Takayuki [Tue, 4 May 2021 21:53:04 +0000 (06:53 +0900)]
replace lit_snip type with &str

3 years agorefactor unseparated_literal_suffix
Takayuki [Tue, 4 May 2021 21:39:38 +0000 (06:39 +0900)]
refactor unseparated_literal_suffix

3 years agoFix needless_quesiton_mark false positive
Cameron Steffen [Tue, 4 May 2021 21:22:43 +0000 (16:22 -0500)]
Fix needless_quesiton_mark false positive

3 years agomove zero_prefixed_literal to its own module
Takayuki [Tue, 4 May 2021 21:18:58 +0000 (06:18 +0900)]
move zero_prefixed_literal to its own module

3 years agoneedless_collect: Add `BinaryHeap` for indirect usage lint
Mateusz Gacek [Tue, 4 May 2021 19:36:20 +0000 (12:36 -0700)]
needless_collect: Add `BinaryHeap` for indirect usage lint

3 years agoFix copy_iterator uitest
Mateusz Gacek [Tue, 4 May 2021 06:58:41 +0000 (23:58 -0700)]
Fix copy_iterator uitest

3 years agoneedless_collect: Lint cases with type annotations
Mateusz Gacek [Mon, 3 May 2021 20:36:08 +0000 (13:36 -0700)]
needless_collect: Lint cases with type annotations

3 years agomove mixed_case_hex_literals to its own module
Takayuki [Tue, 4 May 2021 17:21:26 +0000 (02:21 +0900)]
move mixed_case_hex_literals to its own module

3 years agomove unseparated_literal_suffix to its own module
Takayuki [Tue, 4 May 2021 17:10:24 +0000 (02:10 +0900)]
move unseparated_literal_suffix to its own module

3 years agomove unneeded_field_pattern to its own module
Takayuki [Tue, 4 May 2021 16:44:38 +0000 (01:44 +0900)]
move unneeded_field_pattern to its own module

3 years agoAuto merge of #7157 - camsteffen:hash-pat, r=flip1995
bors [Tue, 4 May 2021 14:45:43 +0000 (14:45 +0000)]
Auto merge of #7157 - camsteffen:hash-pat, r=flip1995

SpanlessHash add Pat

changelog: none

Closes #7149

3 years agoSpanlessHash Pat
Cameron Steffen [Tue, 4 May 2021 13:43:15 +0000 (08:43 -0500)]
SpanlessHash Pat

3 years agomove unneeded_wildcard_pattern to its own module
Takayuki [Tue, 4 May 2021 10:50:48 +0000 (19:50 +0900)]
move unneeded_wildcard_pattern to its own module

3 years agomove redundant_pattern to its own module
Takayuki [Tue, 4 May 2021 08:28:32 +0000 (17:28 +0900)]
move redundant_pattern to its own module

3 years agomove double_neg to its own module
Takayuki [Tue, 4 May 2021 08:20:22 +0000 (17:20 +0900)]
move double_neg to its own module

3 years agoAuto merge of #83213 - rylev:update-lints-to-errors, r=nikomatsakis
bors [Tue, 4 May 2021 08:09:23 +0000 (08:09 +0000)]
Auto merge of #83213 - rylev:update-lints-to-errors, r=nikomatsakis

Update BARE_TRAIT_OBJECT and ELLIPSIS_INCLUSIVE_RANGE_PATTERNS to errors in Rust 2021

This addresses https://github.com/rust-lang/rust/pull/81244 by updating two lints to errors in the Rust 2021 edition.

r? `@estebank`

3 years agomove builtin_type_shadow to its own module
Takayuki [Tue, 4 May 2021 08:04:10 +0000 (17:04 +0900)]
move builtin_type_shadow to its own module

3 years agomove misc_early to misc_early/mod.rs
Takayuki [Tue, 4 May 2021 07:38:34 +0000 (16:38 +0900)]
move misc_early to misc_early/mod.rs

3 years agoChange `std::sys::unix::ext::fs::PermissionsExt::from_mode` to `std::os::imp::unix...
Christiaan Dirkx [Sun, 25 Apr 2021 11:10:19 +0000 (13:10 +0200)]
Change `std::sys::unix::ext::fs::PermissionsExt::from_mode` to `std::os::imp::unix::fs::PermissionsExt::from_mode` in Clippy

3 years agoAuto merge of #7156 - hellow554:single_char_strip, r=flip1995
bors [Mon, 3 May 2021 14:44:44 +0000 (14:44 +0000)]
Auto merge of #7156 - hellow554:single_char_strip, r=flip1995

[single_char_pattern] add strip_prefix and strip_suffix

Title says it all. Adjusted ui tests.

I added the second commit in case you don't like that I moved that table into `single_char_pattern.rs` directly. I don't see any reason why it shouldn't be in that file. It isn't used anywhere else.

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

changelog: add strip_prefix and strip_suffix to single_char_pattern lint

3 years agomove PATTERN_METHODS table directly into file
Marcel Hellwig [Mon, 3 May 2021 14:21:27 +0000 (16:21 +0200)]
move PATTERN_METHODS table directly into file

also removed rustfmt::skip