]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoAuto merge of #6704 - rust-lang:flip1995-patch-1, r=phansch
bors [Tue, 9 Feb 2021 15:47:30 +0000 (15:47 +0000)]
Auto merge of #6704 - rust-lang:flip1995-patch-1, r=phansch

Rename "good first issue" back to "good-first-issue"

changelog: none

3 years agoRename "good first issue" back to "good-first-issue"
Philipp Krones [Tue, 9 Feb 2021 09:29:00 +0000 (10:29 +0100)]
Rename "good first issue" back to "good-first-issue"

3 years agoRename HIR UnOp variants
Ömer Sinan Ağacan [Tue, 9 Feb 2021 08:15:53 +0000 (11:15 +0300)]
Rename HIR UnOp variants

This renames the variants in HIR UnOp from

    enum UnOp {
        UnDeref,
        UnNot,
        UnNeg,
    }

to

    enum UnOp {
        Deref,
        Not,
        Neg,
    }

Motivations:

- This is more consistent with the rest of the code base where most enum
  variants don't have a prefix.

- These variants are never used without the `UnOp` prefix so the extra
  `Un` prefix doesn't help with readability. E.g. we don't have any
  `UnDeref`s in the code, we only have `UnOp::UnDeref`.

- MIR `UnOp` type variants don't have a prefix so this is more
  consistent with MIR types.

- "un" prefix reads like "inverse" or "reverse", so as a beginner in
  rustc code base when I see "UnDeref" what comes to my mind is
  something like "&*" instead of just "*".

3 years agoFix collapsible_if false positive with attributes
Cameron Steffen [Mon, 8 Feb 2021 17:00:30 +0000 (11:00 -0600)]
Fix collapsible_if false positive with attributes

3 years agoSimplify if_chain
Cameron Steffen [Mon, 8 Feb 2021 16:51:40 +0000 (10:51 -0600)]
Simplify if_chain

3 years agoFix missing_panics_doc warning on `unreachable!`.
daxpedda [Mon, 8 Feb 2021 16:25:10 +0000 (17:25 +0100)]
Fix missing_panics_doc warning on `unreachable!`.

3 years agoUse path_to_local_id
Cameron Steffen [Mon, 8 Feb 2021 15:50:13 +0000 (09:50 -0600)]
Use path_to_local_id

3 years agoRefactor out UnusedSelfVisitor
Cameron Steffen [Wed, 3 Feb 2021 17:45:16 +0000 (11:45 -0600)]
Refactor out UnusedSelfVisitor

3 years agoEnhance LocalUsedVisitor to check closure bodies
Cameron Steffen [Wed, 3 Feb 2021 17:35:16 +0000 (11:35 -0600)]
Enhance LocalUsedVisitor to check closure bodies

3 years agoFix vec_init_then_push FP
Cameron Steffen [Fri, 5 Feb 2021 22:28:13 +0000 (16:28 -0600)]
Fix vec_init_then_push FP

3 years agoUse id instead of name
Cameron Steffen [Fri, 5 Feb 2021 22:27:23 +0000 (16:27 -0600)]
Use id instead of name

3 years agoAuto merge of #6696 - dtolnay-contrib:regex, r=Manishearth
bors [Mon, 8 Feb 2021 06:02:29 +0000 (06:02 +0000)]
Auto merge of #6696 - dtolnay-contrib:regex, r=Manishearth

Downgrade trivial_regex to nursery

See #6690. I think there is still value in a trivial_regex lint, but only if clippy can tell that the regex is only ever constructed and applied to a single input.

```rust
let regex = Regex::new("trivial_regex")?;
println!("{}", regex.is_match(s));
// `regex` never used again
```

---

changelog: remove `trivial_regex` from default set of enabled lints

3 years agoDowngrade trivial_regex to nursery
David Tolnay [Mon, 8 Feb 2021 00:54:09 +0000 (16:54 -0800)]
Downgrade trivial_regex to nursery

3 years agoAuto merge of #6694 - matthiaskrgr:lintcheck-cfg, r=Manishearth
bors [Sun, 7 Feb 2021 19:04:00 +0000 (19:04 +0000)]
Auto merge of #6694 - matthiaskrgr:lintcheck-cfg, r=Manishearth

lintcheck: add a cmdline option --crates-toml <TOML PATH> to override crate sources file to use.

Fixes #6691

changelog: lintcheck: add --crates-toml  cmdline option to override default crates.toml file.

3 years agoadd a new lint `bytes_nth`
Takayuki Maeda [Sun, 7 Feb 2021 16:34:59 +0000 (01:34 +0900)]
add a new lint `bytes_nth`

3 years agolintcheck: add a cmdline option --crates-toml <TOML PATH> to override crate sources...
Matthias Krüger [Sun, 7 Feb 2021 15:12:21 +0000 (16:12 +0100)]
lintcheck: add a cmdline option --crates-toml <TOML PATH> to override crate sources file to use.

Fixes #6691

3 years agoAuto merge of #6686 - matthiaskrgr:lintcheck_git, r=flip1995
bors [Sun, 7 Feb 2021 13:25:00 +0000 (13:25 +0000)]
Auto merge of #6686 - matthiaskrgr:lintcheck_git, r=flip1995

lintcheck: support git sources

This adds support for git sources in `cargo dev-lintcheck`

You can add a git source to `clippy_dev/lintcheck_crates.toml` by having a `git_url` and a `git_hash` key instead of the `versions` array.
The repo will the be cloned and checked out to the requested commit before checking it with clippy.

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

changelog: lintcheck: support git sources

3 years agoAuto merge of #6674 - phlip9:disallowed_functions, r=llogiq
bors [Sun, 7 Feb 2021 11:15:44 +0000 (11:15 +0000)]
Auto merge of #6674 - phlip9:disallowed_functions, r=llogiq

disallowed_methods: Support functions in addition to methods

## Context:

Hey all! I have a particular use case where I'd like to ban certain functions in a code base I work on. For example, I want to ban `Instant::now()` (among others) as we have a time service for mocking time in deterministic simulation tests. Obviously, it doesn't make sense to include a lint like this for all clippy users. Imagine my excitement when I spotted the new `disallowed_methods` lint in clippy--perfect! Unfortunately, after playing around with it for a bit, I was frustrated to realize that it didn't support functions like `Instant::now()`, so I've added support for them in this PR.

It might also make sense to rename the lint from `disallowed_methods` -> `disallowed_functions`, though I've held off from including that rename in this change, since I'm unsure of clippy's breaking change policy.

## Change

Support functions in addition to methods. In other words, support:

`disallowed_methods = ["alloc::vec::Vec::new"]` (a function) in addition to
`disallowed_methods = ["alloc::vec::Vec::leak"]` (a method).

Improve the documentation to clarify that users must specify the full qualified path for each disallowed function, which can be confusing for reexports. Include an example `clippy.toml`.

Simplify the actual lint pass so we can reuse `utils::fn_def_id`.

changelog: disallowed_method: Now supports functions in addition to methods

3 years agoAuto merge of #6685 - magurotuna:filter_map_identity, r=phansch
bors [Sun, 7 Feb 2021 09:55:32 +0000 (09:55 +0000)]
Auto merge of #6685 - magurotuna:filter_map_identity, r=phansch

Add new lint `filter_map_identity`

<!--
Thank you for making Clippy better!

We're collecting our changelog from pull request descriptions.
If your PR only includes internal changes, you can just write
`changelog: none`. Otherwise, please write a short comment
explaining your change.

If your PR fixes an issue, you can add "fixes #issue_number" into this
PR description. This way the issue will be automatically closed when
your PR is merged.

If you added a new lint, here's a checklist for things that will be
checked during review or continuous integration.

- \[x] Followed [lint naming conventions][lint_naming]
- \[x] Added passing UI tests (including committed `.stderr` file)
- \[x] `cargo test` passes locally
- \[x] Executed `cargo dev update_lints`
- \[x] Added lint documentation
- \[x] Run `cargo dev fmt`

[lint_naming]: https://rust-lang.github.io/rfcs/0344-conventions-galore.html#lints

Note that you can skip the above if you are just opening a WIP PR in
order to get feedback.

Delete this line and everything above before opening your PR.
-->

This commit adds a new lint named filter_map_identity.
This lint is the same as `flat_map_identity` except that it checks for the usage of `filter_map`.

---

Closes #6643

changelog: Added a new lint: `filter_map_identity`

3 years agoSimplify DefaultNumericFallback
Yoshitomo Nakanishi [Sun, 7 Feb 2021 09:00:08 +0000 (18:00 +0900)]
Simplify DefaultNumericFallback

3 years agoAuto merge of #6681 - 1c3t3a:1c3t3a-issue-6467, r=xFrednet,flip1995,phansch
bors [Sun, 7 Feb 2021 08:53:52 +0000 (08:53 +0000)]
Auto merge of #6681 - 1c3t3a:1c3t3a-issue-6467, r=xFrednet,flip1995,phansch

Adds a new lint that checks if there is a semicolon on the last block statement if it returns nothing

changelog: Added a new lint: `SEMICOLON_IF_NOTHING_RETURNED`
fixes #6467
Adds the `SEMICOLON_IF_NOTHING_RETURNED` lint and therefore closes #6467.

3 years agoAuto merge of #6660 - camsteffen:path-to-local, r=llogiq
bors [Sun, 7 Feb 2021 08:40:41 +0000 (08:40 +0000)]
Auto merge of #6660 - camsteffen:path-to-local, r=llogiq

Cleanup path-to-local checks

changelog: none

It seemed like too much ceremony going on to check if an expression matches a variable. So I created two util functions `path_to_local(Expr) -> Option<HirId>` and `path_to_local_id(Expr, HirId) -> bool` to make this easier, and used them wherever applicable.

I changed logic in a few places to use `HirId` instead of `Symbol` where it was easy to do so. I believe this is more correct and may even fix some bugs.

I also removed some calls to `qpath_res`. This is not needed if you are only looking for a `Res::Local`.

As a note, I wanted to name the util functions in a way that encourages understanding of the HIR.

3 years agoAuto merge of #6688 - rust-lang:triagebot_update, r=phansch
bors [Sun, 7 Feb 2021 08:24:50 +0000 (08:24 +0000)]
Auto merge of #6688 - rust-lang:triagebot_update, r=phansch

Update triagebot.toml to new label names

changelog: none

3 years agoAuto merge of #6682 - camsteffen:let-underscore-ref, r=llogiq
bors [Sun, 7 Feb 2021 08:13:42 +0000 (08:13 +0000)]
Auto merge of #6682 - camsteffen:let-underscore-ref, r=llogiq

Fix let_underscore_drop FP

changelog: Fix let_underscore_drop false positives and negatives

Fixes #6633

3 years agoUpdate triagebot.toml to new label names
Philipp Krones [Sat, 6 Feb 2021 22:56:08 +0000 (23:56 +0100)]
Update triagebot.toml to new label names

3 years agoEat dogfood
Cameron Steffen [Fri, 5 Feb 2021 20:55:09 +0000 (14:55 -0600)]
Eat dogfood

3 years agoFixed suggestion in macro invocations
Bastian Kersting [Sat, 6 Feb 2021 19:05:51 +0000 (20:05 +0100)]
Fixed suggestion in macro invocations

3 years agoStabilize workspace wrapper.
Eric Huss [Sat, 6 Feb 2021 18:38:27 +0000 (10:38 -0800)]
Stabilize workspace wrapper.

3 years agolintcheck: avoid dbg!() calls
Matthias Krüger [Sat, 6 Feb 2021 18:12:28 +0000 (19:12 +0100)]
lintcheck: avoid dbg!() calls

3 years agoConfused about my own explanation.
daxpedda [Sat, 6 Feb 2021 17:29:07 +0000 (18:29 +0100)]
Confused about my own explanation.

3 years agoDocument condition.
daxpedda [Sat, 6 Feb 2021 17:24:08 +0000 (18:24 +0100)]
Document condition.

3 years agoFux `toml_unknown_key` test.
daxpedda [Sat, 6 Feb 2021 17:21:03 +0000 (18:21 +0100)]
Fux `toml_unknown_key` test.

3 years agoPick up `clippy.toml` in `ui-cargo` tests.
daxpedda [Sat, 6 Feb 2021 16:57:31 +0000 (17:57 +0100)]
Pick up `clippy.toml` in `ui-cargo` tests.

3 years agoAdd back `publish = false` to the old test.
daxpedda [Sat, 6 Feb 2021 16:52:41 +0000 (17:52 +0100)]
Add back `publish = false` to the old test.

3 years agoAdd test for `publish = true`.
daxpedda [Sat, 6 Feb 2021 16:38:30 +0000 (17:38 +0100)]
Add test for `publish = true`.

3 years agoChange clippy configuration option.
daxpedda [Sat, 6 Feb 2021 16:38:14 +0000 (17:38 +0100)]
Change clippy configuration option.

3 years agoHide clippy configuration option.
daxpedda [Sat, 6 Feb 2021 15:51:51 +0000 (16:51 +0100)]
Hide clippy configuration option.

Co-authored-by: Philipp Krones <hello@philkrones.com>
3 years agoImplement `_cargo_ignore_publish`.
daxpedda [Wed, 3 Feb 2021 18:19:30 +0000 (19:19 +0100)]
Implement `_cargo_ignore_publish`.

3 years agoTest names were flipped.
daxpedda [Wed, 3 Feb 2021 17:01:18 +0000 (18:01 +0100)]
Test names were flipped.

3 years agoFix cargo_common_metadata warning on `publish = false`.
daxpedda [Fri, 29 Jan 2021 13:03:26 +0000 (14:03 +0100)]
Fix cargo_common_metadata warning on `publish = false`.

3 years agoChanged lint level to `restriction`
Bastian Kersting [Sat, 6 Feb 2021 16:06:06 +0000 (17:06 +0100)]
Changed lint level to `restriction`

3 years agoRollup merge of #81680 - camsteffen:primty, r=oli-obk
Jonas Schievink [Sat, 6 Feb 2021 16:01:45 +0000 (17:01 +0100)]
Rollup merge of #81680 - camsteffen:primty, r=oli-obk

Refactor `PrimitiveTypeTable` for Clippy

I removed `PrimitiveTypeTable` and added `PrimTy::ALL` and `PrimTy::from_name` in its place. This allows Clippy to use `PrimTy::from_name` for the `builtin_type_shadow` lint, and a `const` list of primitive types is deleted from Clippy code (the goal). All changes should be a little faster, if anything.

3 years agoSwitched to `snippet_with_macro_callsite`
Bastian Kersting [Sat, 6 Feb 2021 15:56:18 +0000 (16:56 +0100)]
Switched to `snippet_with_macro_callsite`

3 years agoRevert "Fixed for loop problem, corrected all occurences that got linted"
Bastian Kersting [Sat, 6 Feb 2021 15:44:57 +0000 (16:44 +0100)]
Revert "Fixed for loop problem, corrected all occurences that got linted"

This reverts commit 6626295fbc747d04f1a8d14f19ee48c789b90e50.

3 years agoAuto merge of #6684 - matthiaskrgr:versiontest_dont_break_upstream, r=flip1995
bors [Sat, 6 Feb 2021 13:38:36 +0000 (13:38 +0000)]
Auto merge of #6684 - matthiaskrgr:versiontest_dont_break_upstream, r=flip1995

tests: ignore check_that_clippy_has_the_same_major_version_as_rustc()inside the rustc repo

Do not check if clippy version matches rustc version when runnning tests inside the rustc repo.
This makes sure that upstream rustc maintainers do not have to deal with our test failing/mismatching versions
when the rustc version bump is happening.
cc #6683

We already do the "don't run inside the rustc-repo" workaround for the dogfood test:
https://github.com/rust-lang/rust-clippy/blob/a507c27660d05f37307369d30bee9e82ce3a11e1/tests/dogfood.rs#L16

changelog: None

3 years agoFixed for loop problem, corrected all occurences that got linted
Bastian Kersting [Sat, 6 Feb 2021 13:07:49 +0000 (14:07 +0100)]
Fixed for loop problem, corrected all occurences that got linted

3 years agolintcheck: cleanup, fix --only for git crates, better error msgs
Matthias Krüger [Sat, 6 Feb 2021 11:04:31 +0000 (12:04 +0100)]
lintcheck: cleanup, fix --only for git crates, better error msgs

3 years agolintcheck: add git source as an example and update logs
Matthias Krüger [Sat, 6 Feb 2021 10:36:06 +0000 (11:36 +0100)]
lintcheck: add git source as an example and update logs

3 years agoimplement the download_and_extract() step for git sources
Matthias Krüger [Sat, 6 Feb 2021 11:02:42 +0000 (12:02 +0100)]
implement the download_and_extract() step for git sources

3 years agolintcheck: make TomlCrate also accept git-data from lintcheck_crates.toml
Matthias Krüger [Fri, 5 Feb 2021 22:13:59 +0000 (23:13 +0100)]
lintcheck: make TomlCrate also accept git-data from lintcheck_crates.toml

3 years agolintcheck: update logs
Matthias Krüger [Sat, 6 Feb 2021 10:59:34 +0000 (11:59 +0100)]
lintcheck: update logs

3 years agoUse flatten instead of filter_map
Yusuke Tanaka [Sat, 6 Feb 2021 09:06:58 +0000 (18:06 +0900)]
Use flatten instead of filter_map

3 years agoAdd new lint `filter_map_identity`
Yusuke Tanaka [Wed, 3 Feb 2021 14:24:06 +0000 (23:24 +0900)]
Add new lint `filter_map_identity`

This commit adds a new lint named `filter_map_identity`. This lint is
the same as `flat_map_identity` except that it checks for `filter_map`.

Closes #6643

3 years agotests: ignore check_that_clippy_has_the_same_major_version_as_rustc() inside the...
Matthias Krüger [Fri, 5 Feb 2021 23:56:54 +0000 (00:56 +0100)]
tests: ignore check_that_clippy_has_the_same_major_version_as_rustc() inside the rustc repo.

Do not check if clippy version matches rustc version when runnning tests inside the rustc repo.
This makes sure that upstream rustc maintainers do not have to deal with our test failing/mismatching versions
when the rustc version bump is happening.
cc #6683

3 years agoBump clippy version
Mark Rousskov [Fri, 5 Feb 2021 23:29:05 +0000 (18:29 -0500)]
Bump clippy version

3 years agoFix let_underscore_drop implements Drop logic
Cameron Steffen [Fri, 5 Feb 2021 20:45:24 +0000 (14:45 -0600)]
Fix let_underscore_drop implements Drop logic

This fixes false positives and false negatives.

3 years agoFixed macro edge case for `semicolon_if_nothing_returned lint`
Bastian Kersting [Fri, 5 Feb 2021 17:54:13 +0000 (18:54 +0100)]
Fixed macro edge case for `semicolon_if_nothing_returned lint`

3 years agoAdded documentation
Bastian Kersting [Mon, 21 Dec 2020 17:24:08 +0000 (18:24 +0100)]
Added documentation

3 years agoFirst version of the lint
Bastian Kersting [Sun, 20 Dec 2020 10:48:56 +0000 (11:48 +0100)]
First version of the lint

3 years agoAuto merge of #6679 - flip1995:ra_setup_abs_path, r=Manishearth
bors [Fri, 5 Feb 2021 17:48:46 +0000 (17:48 +0000)]
Auto merge of #6679 - flip1995:ra_setup_abs_path, r=Manishearth

Use absolute path to Rust repo in ra_setup

This will convert the path to the Rust repo to an absolute path. This is
important for the clippy_lints/Cargo.toml file. Otherwise if a relative
path is passed, rst-analyzer won't find the Rust repo, because it starts
the relative path search from the clippy_lints dir, not the
rust-clippy dir where the ra_setup command was run from.

changelog: none

3 years agoAuto merge of #6678 - TaKO8Ki:fix-typo, r=flip1995
bors [Fri, 5 Feb 2021 17:16:50 +0000 (17:16 +0000)]
Auto merge of #6678 - TaKO8Ki:fix-typo, r=flip1995

Fix typo

This patch fixes a typo.

changelog: none

3 years agoCleanup path to local checks
Cameron Steffen [Tue, 2 Feb 2021 01:22:31 +0000 (19:22 -0600)]
Cleanup path to local checks

3 years agoUse absolute path to Rust repo in ra_setup
flip1995 [Fri, 5 Feb 2021 16:23:04 +0000 (17:23 +0100)]
Use absolute path to Rust repo in ra_setup

This will convert the path to the Rust repo to an absolute path. This is
important for the clippy_lints/Cargo.toml file. Otherwise if a relative
path is passed, rst-analyzer won't find the Rust repo, because it starts
the relative path search from the clippy_lints dir, not the
rust-clippy dir where the ra_setup command was run from.

3 years agofix typo
Takayuki Maeda [Fri, 5 Feb 2021 15:10:52 +0000 (00:10 +0900)]
fix typo

3 years agoSupport free functions in disallowed-methods lint
Philip Hayes [Sat, 30 Jan 2021 06:18:56 +0000 (22:18 -0800)]
Support free functions in disallowed-methods lint

In other words, support:

`disallowed_methods = ["alloc::vec::Vec::new"]` (a free function) in
addition to
`disallowed_methods = ["alloc::vec::Vec::leak"]` (a method).

Improve the documentation to clarify that users must specify the full
qualified path for each disallowed function, which can be confusing for
reexports. Include an example `clippy.toml`.

Simplify the actual lint pass so we can reuse `utils::fn_def_id`.

3 years agoSet turbofish for every sugg and add more test cases
ThibsG [Thu, 4 Feb 2021 18:08:08 +0000 (19:08 +0100)]
Set turbofish for every sugg and add more test cases

3 years agoFix enclosing_body_owner_opt and rename it to enclosing_body_opt
Yoshitomo Nakanishi [Thu, 4 Feb 2021 13:57:03 +0000 (22:57 +0900)]
Fix enclosing_body_owner_opt and rename it to enclosing_body_opt

3 years agoAuto merge of #6646 - nahuakang:for_loops_over_options_or_results, r=flip1995
bors [Thu, 4 Feb 2021 10:03:45 +0000 (10:03 +0000)]
Auto merge of #6646 - nahuakang:for_loops_over_options_or_results, r=flip1995

New Lint: Manual Flatten

This is a draft PR for [Issue 6564](https://github.com/rust-lang/rust-clippy/issues/6564).

r? `@camsteffen`

- \[x] Followed [lint naming conventions][lint_naming]
- \[x] Added passing UI tests (including committed `.stderr` file)
- \[x] `cargo test` passes locally
- \[x] Executed `cargo dev update_lints`
- \[x] Added lint documentation
- \[x] Run `cargo dev fmt`

---

*Please write a short comment explaining your change (or "none" for internal only changes)*
changelog: Add new lint [`manual_flatten`] to check for loops over a single `if let` expression with `Result` or `Option`.

3 years agoImprove lint message; add note for future autofixable updates
nahuakang [Thu, 4 Feb 2021 09:51:40 +0000 (10:51 +0100)]
Improve lint message; add note for future autofixable updates

3 years agoNew lint: default_numeric_fallback
Yoshitomo Nakanishi [Tue, 2 Feb 2021 03:26:20 +0000 (12:26 +0900)]
New lint: default_numeric_fallback

3 years agoSuggest panic!("{}", ..) instead of panic!(..) clippy::expect_fun_call.
Mara Bos [Wed, 3 Feb 2021 09:55:33 +0000 (10:55 +0100)]
Suggest panic!("{}", ..) instead of panic!(..) clippy::expect_fun_call.

3 years agoFix/allow non_fmt_panic in clippy tests.
Mara Bos [Tue, 2 Feb 2021 19:24:42 +0000 (20:24 +0100)]
Fix/allow non_fmt_panic in clippy tests.

3 years agoAdd additional test cases and improve span lint
nahuakang [Wed, 3 Feb 2021 18:45:58 +0000 (19:45 +0100)]
Add additional test cases and improve span lint

3 years agoAuto merge of #6669 - magurotuna:fix-test-name, r=flip1995
bors [Wed, 3 Feb 2021 15:39:37 +0000 (15:39 +0000)]
Auto merge of #6669 - magurotuna:fix-test-name, r=flip1995

Fix file names of flat_map_identity test

This patch fixes the file names of the `flat_map_identity` test.
Previously, their names were started with `unnecessary_flat_map` even though the lint rule name is `flat_map_identity`. This inconsistency happened probably because the rule name was changed during the discussion in the PR where this rule was introduced.

ref: https://github.com/rust-lang/rust-clippy/pull/4231

changelog: none

3 years agoFix file names of flat_map_identity test
Yusuke Tanaka [Wed, 3 Feb 2021 15:06:26 +0000 (00:06 +0900)]
Fix file names of flat_map_identity test

This commit fixes the file names of the `flat_map_identity` test.
Previously, their names were started with `unnecessary_flat_map` even
though the lint rule name is `flat_map_identity`. This inconsistency
happened probably because the rule name was changed during the
discussion in the PR where this rule was introduced.

ref: https://github.com/rust-lang/rust-clippy/pull/4231

3 years agoUse PrimTy in builtin type shadow lint
Cameron Steffen [Tue, 2 Feb 2021 18:28:58 +0000 (12:28 -0600)]
Use PrimTy in builtin type shadow lint

3 years agoAdd additional check on if arg type has iter method
nahuakang [Wed, 3 Feb 2021 08:39:35 +0000 (09:39 +0100)]
Add additional check on if arg type has iter method

3 years agoMerge commit '3e4179766bcecd712824da04356621b8df012ea4' into sync-from-clippy
Manish Goregaokar [Wed, 3 Feb 2021 04:43:30 +0000 (20:43 -0800)]
Merge commit '3e4179766bcecd712824da04356621b8df012ea4' into sync-from-clippy

3 years agoAuto merge of #6667 - Manishearth:rustup, r=Manishearth
bors [Wed, 3 Feb 2021 04:09:03 +0000 (04:09 +0000)]
Auto merge of #6667 - Manishearth:rustup, r=Manishearth

Rustup

Pulling in AST changes

changelog: none

3 years agoMerge branch 'sync-from-rust3' into rustup
Manish Goregaokar [Wed, 3 Feb 2021 03:57:31 +0000 (19:57 -0800)]
Merge branch 'sync-from-rust3' into rustup

3 years agoRun rustfmt
Manish Goregaokar [Wed, 3 Feb 2021 03:57:08 +0000 (19:57 -0800)]
Run rustfmt

3 years agoRustup
Manish Goregaokar [Wed, 3 Feb 2021 01:35:39 +0000 (17:35 -0800)]
Rustup

3 years agoMerge remote-tracking branch 'origin/master' into rustup
Manish Goregaokar [Wed, 3 Feb 2021 00:46:12 +0000 (16:46 -0800)]
Merge remote-tracking branch 'origin/master' into rustup

3 years agoFixed test
Pierre-Andre Gagnon [Wed, 3 Feb 2021 00:14:13 +0000 (19:14 -0500)]
Fixed test

3 years agoFix for issue 6640
Pierre-Andre Gagnon [Tue, 2 Feb 2021 23:39:23 +0000 (18:39 -0500)]
Fix for issue 6640

3 years agoEnhance manual flatten
nahuakang [Tue, 2 Feb 2021 18:04:20 +0000 (19:04 +0100)]
Enhance manual flatten

3 years agoRollup merge of #81260 - vn971:restore-editorconfig, r=Mark-Simulacrum
Jack Huey [Tue, 2 Feb 2021 21:01:33 +0000 (16:01 -0500)]
Rollup merge of #81260 - vn971:restore-editorconfig, r=Mark-Simulacrum

Add .editorconfig

This adds a .editorconfig file to rust-lang/rust, matching Clippy's. It's not clear that this will benefit many people, but the cost is low and the rewards are potentially meaningful.

3 years agoAuto merge of #6639 - xFrednet:0000-configuration-documentation-some-nits, r=flip1995
bors [Tue, 2 Feb 2021 18:05:35 +0000 (18:05 +0000)]
Auto merge of #6639 - xFrednet:0000-configuration-documentation-some-nits, r=flip1995

Updated some NITs in the documentation from #6630

I've implemented the two suggestions from #6630 that were added after the merge. This PR also changes the example code to use `register_*_pass` instead of `register_late_pass`. I'm not sure if this is better or worse, but it makes it clearer in my opinion. Let me know if I should change it back.

---

changelog: none

r? `@flip1995`

3 years agoUpdated the list of active mentors
xFrednet [Tue, 2 Feb 2021 17:53:15 +0000 (18:53 +0100)]
Updated the list of active mentors

3 years agoAuto merge of #81405 - bugadani:ast, r=cjgillot
bors [Tue, 2 Feb 2021 17:34:08 +0000 (17:34 +0000)]
Auto merge of #81405 - bugadani:ast, r=cjgillot

Box the biggest ast::ItemKind variants

This PR is a different approach on https://github.com/rust-lang/rust/pull/81400, aiming to save memory in humongous ASTs.

The three affected item kind enums are:
 - `ast::ItemKind` (208 -> 112 bytes)
 - `ast::AssocItemKind` (176 -> 72 bytes)
 - `ast::ForeignItemKind` (176 -> 72 bytes)

3 years agoAdd .editorconfig
Vasili Novikov [Fri, 22 Jan 2021 08:51:23 +0000 (09:51 +0100)]
Add .editorconfig

Editorconfig is a lightweight specification that
helps maintaining consistent coding/formatting style
accross editors, especially those editors
that are not explicitly aware of Rust and rustfmt.

https://editorconfig.org/

3 years agoAuto merge of #6664 - camsteffen:path-to-res, r=Manishearth
bors [Tue, 2 Feb 2021 16:56:39 +0000 (16:56 +0000)]
Auto merge of #6664 - camsteffen:path-to-res, r=Manishearth

Remove Option from `path_to_res` return type

changelog: none

Tiny cleanup for `path_to_res` to return `Res` instead of `Option<Res>`.

3 years agoAuto merge of #6523 - brightly-salty:missing-panic-doc, r=flip1995
bors [Tue, 2 Feb 2021 15:37:24 +0000 (15:37 +0000)]
Auto merge of #6523 - brightly-salty:missing-panic-doc, r=flip1995

Add new lint "missing_panics_doc"

fixes #1974
changelog: Added the "missing_panics_doc" lint which lints when public functions that may panic are missing "# Panics" in their doc comment

3 years agoAdd missing_panics_doc lint
Caden Haustein [Wed, 30 Dec 2020 22:37:59 +0000 (16:37 -0600)]
Add missing_panics_doc lint

3 years agoAuto merge of #6659 - phlip9:let_and_return_fix, r=phansch
bors [Tue, 2 Feb 2021 15:04:35 +0000 (15:04 +0000)]
Auto merge of #6659 - phlip9:let_and_return_fix, r=phansch

Fix let_and_return false positive

The issue:

link: https://play.rust-lang.org/?edition=2018&gist=12cb5d1e7527f8c37743b87fc4a53748
Run the above with clippy to see the following warning:

```
warning: returning the result of a `let` binding from a block
  --> src/main.rs:24:5
   |
23 |     let value = Foo::new(&x).value();
   |     --------------------------------- unnecessary `let` binding
24 |     value
   |     ^^^^^
   |
   = note: `#[warn(clippy::let_and_return)]` on by default
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_and_return
help: return the expression directly
   |
23 |
24 |     Foo::new(&x).value()
   |
```

Implementing the suggested fix, removing the temporary let binding,
yields a compiler error:

```
error[E0597]: `x` does not live long enough
  --> src/main.rs:23:14
   |
23 |     Foo::new(&x).value()
   |     ---------^^-
   |     |        |
   |     |        borrowed value does not live long enough
   |     a temporary with access to the borrow is created here ...
24 | }
   | -
   | |
   | `x` dropped here while still borrowed
   | ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `Foo`
   |
   = note: the temporary is part of an expression at the end of a block;
           consider forcing this temporary to be dropped sooner, before the block's local variables are dropped
help: for example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block
   |
23 |     let x = Foo::new(&x).value(); x
   |     ^^^^^^^                     ^^^
```

The fix:

Of course, clippy looks like it should already handle this edge case;
however, it appears `utils::fn_def_id` is not returning a `DefId` for
`Foo::new`. Changing the `qpath_res` lookup to use the child Path
`hir_id` instead of the parent Call `hir_id` fixes the issue.

changelog: none

3 years agoAuto merge of #6661 - Manishearth:exhaustive-fix, r=flip1995
bors [Tue, 2 Feb 2021 07:59:39 +0000 (07:59 +0000)]
Auto merge of #6661 - Manishearth:exhaustive-fix, r=flip1995

exhaustive_structs: don't trigger for structs with private fields

changelog: Restrict `exhaustive_structs` to structs with all-public
fields

3 years agoFix test formatting
Philipp Krones [Tue, 2 Feb 2021 07:59:23 +0000 (08:59 +0100)]
Fix test formatting

3 years agoexhaustive_structs: don't trigger for structs with private fields
Manish Goregaokar [Tue, 2 Feb 2021 02:38:43 +0000 (18:38 -0800)]
exhaustive_structs: don't trigger for structs with private fields

3 years agoFix suggestions that need parens
ThibsG [Sun, 31 Jan 2021 20:43:35 +0000 (21:43 +0100)]
Fix suggestions that need parens

3 years agoImplement manual flatten lint
nahuakang [Fri, 29 Jan 2021 00:38:34 +0000 (01:38 +0100)]
Implement manual flatten lint