Commit Graph

4339 Commits

Author SHA1 Message Date
Samuel E. Moelius III
ff157ae1f4 Improve tests 2021-02-23 18:50:30 -05:00
bors
a2c25fa9f0 Auto merge of #6573 - Jarcho:option_match_map, r=llogiq
New lint: option_manual_map

fixes: #6
changelog: Added lint: `match_map`
2021-02-23 21:56:25 +00:00
bors
fe01ddc8bc Auto merge of #6769 - Y-Nak:inconsistent-struct-constructor, r=matthiaskrgr
Inconsistent struct constructor

fixes: #6352
r? `@matthiaskrgr`

I added the lint that checks for the struct constructors where the order of the field init shorthands is inconsistent with that in the struct definition.

changelog: Add style lint: `inconsistent_struct_constructor`
2021-02-22 09:29:20 +00:00
Jason Newcomb
23aa2f880c
Fix dogfood errors 2021-02-21 23:15:28 -05:00
Jason Newcomb
efe33f9fe4
Add: option_manual_map lint 2021-02-21 22:06:03 -05:00
bors
728f3976f0 Auto merge of #6771 - MortenLohne:master, r=flip1995
Fix FP in inherent_to_string when the function has generic parameters

Minimal example of the false positive:
````
struct G;

impl G {
    fn to_string<const _N: usize>(&self) -> String {
        "G.to_string()".to_string()
    }
}

fn main() {
    let g = G;
    g.to_string::<1>();
}
````
Clippy emits an `inherent_to_string` warning, and suggests that we implement `Display` for `G` instead. However, this is not possible, since the generic parameter _N only exists in this function, not in `G` itself. This particular example uses const generics, which is where the issue is most likely to come up, but this PR skips the lint if the `to_string` function has any kind of generic parameters.

changelog: Fix FP in `inherent_to_string`
2021-02-21 16:10:03 +00:00
bors
208e95781b Auto merge of #6770 - ThibsG:PostfixEnumVariant, r=flip1995
Fix camel case postfix for `enum_variant_names` lint

Fix camel case postfix

Fixes: #4639

changelog: none
2021-02-21 15:58:47 +00:00
bors
d2ddf9c796 Auto merge of #6754 - camsteffen:spanlesseq-res, r=flip1995
Teach SpanlessEq binding IDs

changelog: Fix collapsible_match false positive

Fixes #6740

This PR changes the way `SpanlessEq` determines whether two local variables are the same. Instead of checking that the names match, it checks that the `HirId`s match. If local bindings are declared within the expressions that are being compared, `SpanlessEq` will remember bindings that correspond to each other in a `FxHashMap<HirId, HirId>`. This makes `SpanlessEq` more flexible while also fixing false positives.

Example: `{ let x = 1; x + 2 }` is equal to `{ let y = 1; y + 2 }`.

CC `@xFrednet` I think this will resolve some concerns in #6463
2021-02-21 15:22:35 +00:00
Morten Lohne
19a377510c Fix FP in inherent_to_string when the function has generic parameters 2021-02-21 00:11:17 +01:00
Yoshitomo Nakanishi
d23038944a New lint: inconsistent_struct_constructor 2021-02-21 05:05:11 +09:00
ThibsG
5af6f96c8f Fix camel case postfix for enum_variant_names lint 2021-02-20 19:48:04 +01:00
bors
67087a1b4e Auto merge of #6717 - booleancoercion:master, r=llogiq
Add the from_str_radix_10 lint

changelog: added the new `from_str_radix_10` which sometimes replaces calls to `primitive::from_str_radix` to `str::parse`

This is ready to be merged, although maybe the category should be `pedantic` instead of `style`? I'm not sure where it fits better.

Closes #6713.
2021-02-20 09:33:11 +00:00
bool
bf55aee7b1 Updated from_str_radix_10 sugg to be slightly smarter and ran bless 2021-02-19 21:56:21 +02:00
Matthias Krüger
1f4153aa1e collapsible_match: fix lint message capitalization
(see https://rustc-dev-guide.rust-lang.org/diagnostics.html for details)
2021-02-19 10:02:17 +01:00
bors
0f70e88137 Auto merge of #6665 - pag4k:unnecessary_wraps_bug_6640, r=camsteffen
Fix for issue 6640

*Please write a short comment explaining your change (or "none" for internal only changes)*
changelog: unnecessary_wraps will now suggest to remove unnecessary wrapped return unit type, like Option<()>
fixes #6640
2021-02-18 22:47:44 +00:00
Pierre-Andre Gagnon
a78271b861 Changed fn body suggestion msg 2021-02-18 17:32:55 -05:00
Yoshitomo Nakanishi
a87fa0e350 Fix FP of result_unit_err when using type aliases 2021-02-18 18:49:26 +09:00
Pierre-Andre Gagnon
6165cccf7e Added detailled suggs for new case 2021-02-17 16:41:50 -05:00
Cameron Steffen
4ac14f9e63 Teach SpanlessEq binding IDs 2021-02-17 10:47:26 -06:00
bors
e2753f9a7b Auto merge of #6662 - Y-Nak:default-numeric-fallback, r=flip1995
New lint: default_numeric_fallback

fixes #6064
r? `@flip1995`

As we discussed in [here](https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Issue.20.236064/near/224647188) and [here](https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Issue.20clippy.236064/near/224746333),   I start implementing this lint from the strictest version.
In this PR, I'll allow the below two cases to pass the lint to reduce FPs.

1. Appearances of unsuffixed numeric literals in `Local` if `Local` has a type annotation, for example:
```rust
// Good.
let x: i32 = 1;

// Also good.
let x: (i32, i32) = if cond {
   (1, 2)
} else {
   (2, 3)
};
```

2. Appearances of unsuffixed numeric literals in args of `Call` or `MethodCall`  if corresponding arguments of their signature have concrete types, for example:
```rust
fn foo_mono(x: i32) -> i32 {
    x
}

fn foo_poly<T>(t: T) -> t {
    t
}

// Good.
let x = foo_mono(13);

// Still bad.
let x: i32 = foo_poly(13);
```

changelog: Added restriction lint: `default_numeric_fallback`
2021-02-16 09:58:49 +00:00
Yoshitomo Nakanishi
9b0c1ebc18 Change to span_lint_and_sugg from span_lint_and_help 2021-02-16 18:07:09 +09:00
Yoshitomo Nakanishi
1f8ee3cc19 Handle struct ctor case 2021-02-16 11:20:51 +09:00
Philipp Hansch
7226291025
Upgrade compiletest-rs to 0.6 and tester to 0.9
These updates allow us to specify multiple testnames for `TESTNAME`.

The new version of compiletest-rs also includes `bless` support, but is
not enabled with this PR.
2021-02-15 20:13:44 +01:00
Yoshitomo Nakanishi
fb91c76586 Add more tests for default_numeric_fallback 2021-02-15 23:33:27 +09:00
Yoshitomo Nakanishi
93796b2346 Add some restrictions to default_numeric_fallback to avoid FNs 2021-02-15 14:43:37 +09:00
bors
2f19f5f0d7 Auto merge of #6741 - ThibsG:BlockInIfConditions1141, r=flip1995
Do not lint when the closure is called using an iterator

Fix FP when the closure is used in an iterator for `blocks_in_if_conditions` lint

FIxes: #1141

changelog: none
2021-02-14 15:55:12 +00:00
ThibsG
12025506d6 Do not lint when the closure is called using an iterator 2021-02-14 16:21:12 +01:00
bors
9c3b43efdd Auto merge of #6701 - camsteffen:collapsible-if, r=flip1995
Fix collapsible_if with attributes

changelog: Fix collapsible_if FP with attributes

Fixes #6593
2021-02-14 14:43:35 +00:00
bors
eb80ac4e72 Auto merge of #6697 - camsteffen:vec-init-push-fp, r=flip1995
Fix vec_init_then_push false positives

changelog: Fix vec_init_then_push false positives

Fixes #6615
2021-02-14 14:27:13 +00:00
Yoshitomo Nakanishi
87109bb4f5 Add minimal reproducer for ICE in #6179 2021-02-14 01:20:30 +09:00
boolean_coercion
d36fe85569 Made parens addition smarter and added tests with bless 2021-02-13 00:33:08 +02:00
bors
047f3e16bf Auto merge of #6700 - daxpedda:panics-doc-unreachable, r=llogiq
Fix missing_panics_doc warning on `unreachable!`.

Fixes #6699.

Are there any other test-cases I should cover?

changelog: [`missing_panics_doc`](https://rust-lang.github.io/rust-clippy/master/index.html#missing_panics_doc): No longer lints on [`unreachable!`](https://doc.rust-lang.org/std/macro.unreachable.html)
2021-02-12 20:48:05 +00:00
boolean_coercion
642efabfbb Fixed typos and updated to matches! where applicable 2021-02-12 11:54:22 +02:00
boolean_coercion
d1a627ab3b Ran bless and rustfmt 2021-02-12 11:54:22 +02:00
boolean_coercion
0b31b470ad Changed applicability to MaybeIncorrect because of surrounding braces 2021-02-12 11:54:22 +02:00
boolean_coercion
64729390a1 Implemented majority of from_str_radix_10 2021-02-12 11:54:22 +02:00
boolean_coercion
b80ac2af9c Added boilerplate 2021-02-12 11:54:22 +02:00
bors
605e9ba3d7 Auto merge of #6179 - flip1995:rewrite_use_self, r=phansch
Rework use_self impl based on ty::Ty comparison #3410 | Take 2

This builds on top of #5531

I already reviewed and approved the commits by `@montrivo.` So only the review of my commits should be necessary.

I would also appreciate your review `@montrivo,` since you are familiar with the challenges here.

Fixes #3410 and Fixes #4143 (same problem)
Fixes #2843
Fixes #3859
Fixes #4734 and fixes #6221
Fixes #4305
Fixes #5078 (even at expression level now 🎉)
Fixes #3881 and Fixes #4887 (same problem)
Fixes #3909

Not yet: #4140 (test added)

All the credit for the fixes goes to `@montrivo.` I only refactored and copy and pasted his code.

changelog: rewrite [`use_self`] lint and fix multiple (8) FPs. One to go.
2021-02-12 06:09:07 +00:00
flip1995
8b9f4a0d34 Merge commit '70c0f90453701e7d6d9b99aaa1fc6a765937b736' into clippyup 2021-02-11 15:04:38 +01:00
flip1995
00f9981f5c
Merge remote-tracking branch 'upstream/master' into rustup 2021-02-11 14:36:52 +01:00
bors
beb49bad26 Auto merge of #6650 - daxpedda:cargo-common-metadata-publish, r=flip1995
Fix cargo_common_metadata warning on `publish = false`.

I believe `cargo_common_metadata` shouldn't trigger when `publish = false`, not sure if everybody agrees.
Made some tests to handle all edge-cases.

Fixes #6649.

changelog: [`cargo_common_metadata`](https://rust-lang.github.io/rust-clippy/master/index.html#cargo_common_metadata): No longer lints if [`publish = false`](https://doc.rust-lang.org/cargo/reference/manifest.html#the-publish-field) is defined in the manifest
2021-02-11 09:34:44 +00:00
daxpedda
37f978299e
Add test for checking a combination of unreachable and panic. 2021-02-10 20:55:31 +01:00
bors
3784cdf98e Auto merge of #6657 - ThibsG:FromIterParens, r=llogiq
Fix suggestions that need parens in `from_iter_instead_of_collect` lint

Fixes broken suggestions that need parens (i.e.: range)

Fixes: #6648

changelog: none
2021-02-10 19:37:27 +00:00
bors
b5e4389f53 Auto merge of #6695 - TaKO8Ki:add-bytes-nth, r=phansch
New lint: `bytes_nth`

This pull request adds a new lint named `bytes_nth`.

---
closes: https://github.com/rust-lang/rust-clippy/issues/6391

changelog: Added a new lint: `bytes_nth`
2021-02-10 13:54:33 +00:00
flip1995
da65d8166f
Don't trigger use_self in macros 2021-02-10 11:57:28 +01:00
flip1995
bb40db7adc
Update test files 2021-02-10 11:57:28 +01:00
Tim Nielens
fc334fb8f4
use_self - fix issue with hir_ty_to_ty 2021-02-10 11:57:28 +01:00
Tim Nielens
347b01eb1f
rework use_self impl based on ty::Ty comparison 2021-02-10 11:57:27 +01:00
Takayuki Maeda
5996ae1cfc add some test cases 2021-02-10 16:15:29 +09:00
ThibsG
b932587c5d Add better turbofish extractor 2021-02-09 17:43:49 +01:00
Ömer Sinan Ağacan
34b373d309 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 "*".
2021-02-09 11:39:20 +03:00
Cameron Steffen
39ba449c2a Fix collapsible_if false positive with attributes 2021-02-08 11:00:30 -06:00
daxpedda
6c73f989e2
Fix missing_panics_doc warning on unreachable!. 2021-02-08 17:25:10 +01:00
Cameron Steffen
1d30422945 Enhance LocalUsedVisitor to check closure bodies 2021-02-08 08:56:33 -06:00
Cameron Steffen
a42be8589a Fix vec_init_then_push FP 2021-02-08 08:54:04 -06:00
Takayuki Maeda
1c3033d5cf add a new lint bytes_nth 2021-02-08 01:34:59 +09:00
bors
83b7b16330 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
2021-02-07 11:15:44 +00:00
bors
ad9ceeebdc 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`
2021-02-07 09:55:32 +00:00
Yoshitomo Nakanishi
22d4483dee Simplify DefaultNumericFallback 2021-02-07 18:11:31 +09:00
bors
001185d863 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.
2021-02-07 08:53:52 +00:00
bors
d792210c26 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
2021-02-07 08:13:42 +00:00
Bastian Kersting
6b4789d7cf Fixed suggestion in macro invocations 2021-02-06 20:05:51 +01:00
daxpedda
3c8f7542f7
Fux toml_unknown_key test. 2021-02-06 18:21:03 +01:00
daxpedda
e2e33b4d35
Pick up clippy.toml in ui-cargo tests. 2021-02-06 17:57:31 +01:00
daxpedda
cd361a5e64
Add back publish = false to the old test. 2021-02-06 17:52:41 +01:00
daxpedda
8b89087409
Add test for publish = true. 2021-02-06 17:39:19 +01:00
daxpedda
f2391a5569
Change clippy configuration option. 2021-02-06 17:39:18 +01:00
daxpedda
f0d3fd72d7
Implement _cargo_ignore_publish. 2021-02-06 17:39:18 +01:00
daxpedda
d4bc7d2c06
Test names were flipped. 2021-02-06 17:39:17 +01:00
daxpedda
915e9b85a4
Fix cargo_common_metadata warning on publish = false. 2021-02-06 17:39:17 +01:00
Bastian Kersting
85c2b1e5f4 Switched to snippet_with_macro_callsite 2021-02-06 16:56:18 +01:00
Bastian Kersting
cd6748749a Revert "Fixed for loop problem, corrected all occurences that got linted"
This reverts commit 6626295fbc.
2021-02-06 16:44:57 +01:00
Bastian Kersting
6626295fbc Fixed for loop problem, corrected all occurences that got linted 2021-02-06 14:25:40 +01:00
Yusuke Tanaka
a60c143fe0
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
2021-02-06 18:03:14 +09:00
Matthias Krüger
93daf27a40 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
2021-02-06 00:56:54 +01:00
Cameron Steffen
ac5e9c8d26 Fix let_underscore_drop implements Drop logic
This fixes false positives and false negatives.
2021-02-05 14:54:06 -06:00
Bastian Kersting
55bfaa12d3 Fixed macro edge case for semicolon_if_nothing_returned lint 2021-02-05 20:48:46 +01:00
Bastian Kersting
eb9c6698ee First version of the lint 2021-02-05 20:19:22 +01:00
Takayuki Maeda
67d48e1c59 fix typo 2021-02-06 00:10:52 +09:00
Philip Hayes
7b7e3ca511 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`.
2021-02-04 11:28:55 -08:00
ThibsG
233fe11ce9 Set turbofish for every sugg and add more test cases 2021-02-04 19:08:08 +01:00
bors
357c6a7e27 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`.
2021-02-04 10:03:45 +00:00
nahuakang
2f8a8d3468 Improve lint message; add note for future autofixable updates 2021-02-04 10:51:40 +01:00
Yoshitomo Nakanishi
e32e4dedf1 New lint: default_numeric_fallback 2021-02-04 17:26:43 +09:00
Mara Bos
9f7f8b71a6 Suggest panic!("{}", ..) instead of panic!(..) clippy::expect_fun_call. 2021-02-03 23:15:51 +01:00
Mara Bos
0767a0f9c7 Fix/allow non_fmt_panic in clippy tests. 2021-02-03 23:15:51 +01:00
nahuakang
78ef0f2f6c Add additional test cases and improve span lint 2021-02-03 21:54:38 +01:00
bors
876ffa4674 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
2021-02-03 15:39:37 +00:00
Yusuke Tanaka
6396b8fb7f
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
2021-02-04 00:06:26 +09:00
Manish Goregaokar
c8cb90abbd Merge commit '3e4179766bcecd712824da04356621b8df012ea4' into sync-from-clippy 2021-02-02 20:43:30 -08:00
Manish Goregaokar
5c957b8a6f Merge remote-tracking branch 'origin/master' into rustup 2021-02-02 16:46:12 -08:00
Pierre-Andre Gagnon
e0e51e4189 Fixed test 2021-02-02 19:14:13 -05:00
Pierre-Andre Gagnon
bfbc083587 Fix for issue 6640 2021-02-02 18:39:23 -05:00
nahuakang
e07cd5b6fe Enhance manual flatten 2021-02-02 23:43:17 +01:00
Caden Haustein
bde667af7e
Add missing_panics_doc lint 2021-02-02 16:36:32 +01:00
bors
f870876d92 Auto merge of #6659 - phlip9:let_and_return_fix, r=phansch
Fix let_and_return false positive

The issue:

See this Rust playground 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
2021-02-02 15:04:35 +00:00
Philipp Krones
4a13c8c22e
Fix test formatting 2021-02-02 08:59:23 +01:00
Manish Goregaokar
0fb09d6b21 exhaustive_structs: don't trigger for structs with private fields 2021-02-01 18:42:08 -08:00
ThibsG
7825bf36d8 Fix suggestions that need parens 2021-02-01 20:03:40 +01:00
nahuakang
b87e189694 Implement manual flatten lint 2021-02-01 16:58:31 +01:00
nahuakang
3da25ed955 Rename lint 2021-02-01 16:49:53 +01:00
nahuakang
949b125891 Add unit tests for new lint 2021-02-01 16:49:53 +01:00
bors
9607b5c6ac Auto merge of #80851 - m-ou-se:panic-2021, r=petrochenkov
Implement Rust 2021 panic

This implements the Rust 2021 versions of `panic!()`. See https://github.com/rust-lang/rust/issues/80162 and https://github.com/rust-lang/rfcs/pull/3007.

It does so by replacing `{std, core}::panic!()` by a bulitin macro that expands to either `$crate::panic::panic_2015!(..)` or `$crate::panic::panic_2021!(..)` depending on the edition of the caller.

This does not yet make std's panic an alias for core's panic on Rust 2021 as the RFC proposes. That will be a separate change: c5273bdfb2 That change is blocked on figuring out what to do with https://github.com/rust-lang/rust/issues/80846 first.
2021-02-01 10:25:31 +00:00
bors
c5f3f9df3b Auto merge of #6603 - ThibsG:MatchOverlappingArm5986, r=flip1995
Do not lint when range is completely included into another one

This fix has been developed following this [comment](https://github.com/rust-lang/rust-clippy/issues/5986#issuecomment-703313548).
So this will be linted:
```
|----------|
        |-----------|
```
Now this won't be linted:
```
              |---|
|--------------------|
```
and this will still lint:
```
|--------|
|--------------|
```

Fixes: #5986

changelog: Fix FPs in match_overlapping_arm, when first arm is completely included in second arm
2021-01-31 15:09:55 +00:00
Mara Bos
3a0ae08ae2 Update clippy test output for panic macros. 2021-01-30 19:33:21 +01:00
flip1995
ac912be984 Merge commit '95c0459217d1661edfa794c8bb122452b92fb485' into clippyup 2021-01-30 18:06:34 +01:00
flip1995
e2859437f9
Merge remote-tracking branch 'upstream/master' into rustup 2021-01-30 15:51:16 +01:00
Philip Hayes
7f1595e18f Fix let_and_return false positive
The issue:

See this Rust playground 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.
2021-01-29 22:19:09 -08:00
bors
8d57cee9ca Auto merge of #6617 - Manishearth:exhaustive_enums, r=camsteffen
New lint: exhaustive_enums, exhaustive_structs

Fixes #6616

changelog: Added restriction lint: `exhaustive_enums`, `exhaustive_structs`
2021-01-25 23:06:39 +00:00
Manish Goregaokar
3e3dff7135 Add test with attrs 2021-01-25 14:39:03 -08:00
ThibsG
051891173d Add more tests for match_overlapping_arm lint 2021-01-24 12:28:59 +01:00
bors
70386ff352 Auto merge of #6403 - camsteffen:similar-names-underscore, r=Manishearth
Similar names ignore underscore prefixed names

changelog: Ignore underscore-prefixed names for similar_names

IMO, this lint is not very helpful for underscore-prefixed variables. Usually they are unused or are just there to ignore part of a destructuring.
2021-01-22 23:44:12 +00:00
bors
41d750c76c Auto merge of #6619 - camsteffen:collapsible-match, r=camsteffen
Improve collapsible_match

changelog: Fix collapsible_match false negatives

Allow `&` and/or `*` on the binding and make sure the type still matches.
2021-01-22 22:45:43 +00:00
Cameron Steffen
66afdd1f42 Enhance collapsible_match for adjusted bindings 2021-01-22 16:44:47 -06:00
Manish Goregaokar
65d003a112 Clean up suggestion span; clarify help message 2021-01-22 12:08:47 -08:00
Manish Goregaokar
752274eabd Fix indentation of suggestion 2021-01-22 11:59:36 -08:00
Manish Goregaokar
8cb7e85006 Add exhaustive_structs lint 2021-01-22 11:59:36 -08:00
bors
a1b89f07f0 Auto merge of #81135 - jyn514:no-backticks, r=flip1995
Fix formatting for removed lints

- Don't add backticks for the reason a lint was removed. This is almost
never a code block, and when it is the backticks should be in the reason
itself.
- Don't assume clippy is the only tool that needs to be checked for
backwards compatibility

I split this out of https://github.com/rust-lang/rust/pull/80527/ because it kept causing tests to fail, and it's a good change to have anyway.

r? `@flip1995`
2021-01-22 06:13:19 +00:00
Cameron Steffen
a752d31e0a Replace find_map with manual_find_map 2021-01-21 18:18:21 -06:00
Cameron Steffen
c92bdc4dbb Split filter_map into manual_filter_map 2021-01-21 18:18:18 -06:00
Manish Goregaokar
09d4d49299 ExhaustiveEnums -> ExhaustiveItems 2021-01-21 13:39:00 -08:00
Manish Goregaokar
f6cb96ef07 Make exhaustive_enums only warn on exported items 2021-01-21 13:34:44 -08:00
Manish Goregaokar
f1ab3024b2 New lint: exhaustive_enums 2021-01-21 13:31:06 -08:00
bors
043cf97abc Auto merge of #6609 - giraffate:fix_wrong_suggestion_of_ref_in_deref, r=llogiq
Fix a wrong suggestion of `ref_in_deref`

Fix #6358.

changelog: Fix a wrong suggestion of `ref_in_deref`
2021-01-21 19:16:11 +00:00
bors
4d381c3a84 Auto merge of #6605 - kawogi:doc-markdown, r=llogiq
Doc markdown

I added "WebGL" along the lines of the existing "OpenGL" to the whitelist of `doc_markdown` as I found this to be a pretty common term.

(this is a follow-up of the now closed https://github.com/rust-lang/rust-clippy/pull/6388)

changelog: Whitelist "WebGL" in `doc_markdown`.
2021-01-21 19:05:50 +00:00
bors
a982ab4cee Auto merge of #6532 - matthiaskrgr:mlmm, r=llogiq
match_like_matches_macro: strip refs in suggestion

fixes #6503

changelog: match_like_matches_macro: strip refs in suggestion (#6503)
2021-01-21 18:34:55 +00:00
bors
7b50a4ead7 Auto merge of #6408 - pro-grammer1:master, r=oli-obk
Fix false positive in write_literal and print_literal (numeric literals)

changelog: No longer lint numeric literals in [`write_literal`] and [`print_literal`].

Fixes #6335
2021-01-21 14:23:25 +00:00
bors
16d13a5a4b Auto merge of #6611 - pastchick3:master, r=flip1995
Fix the reversed suggestion message of `stable_sort_primitive`.

Now Clippy emits `stable_sort_primitive` warning as follows:

```
warning: used sort instead of sort_unstable to sort primitive type `usize`
  --> src\asm.rs:41:13
   |
41 |             self.successors.sort();
   |             ^^^^^^^^^^^^^^^^^^^^^^ help: try: `self.successors.sort_unstable()`
   |
   = note: `#[warn(clippy::stable_sort_primitive)]` on by default
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#stable_sort_primitive
```

I think the position of `sort` and `sort_unstable` in the first line should be reversed.

changelog: Fix the reversed suggestion message of `stable_sort_primitive`.
2021-01-21 14:12:43 +00:00
pastchick3
e42208f1b7 Improve the suggestion message of stable_sort_primitive. 2021-01-21 20:44:52 +08:00
bors
d990c31990 Auto merge of #6567 - camsteffen:path-to-res-enum, r=Manishearth
Fix path_to_res for enum inherent items

changelog: none

I tried to add `Option::is_some` to the paths but got a false positive from the invalid paths lint. Turns out the `path_to_res` function does not find inherent impls for enums. I fixed this and took the liberty to do some additional cleanup in the method.
2021-01-20 21:35:11 +00:00
Hirochika Matsumoto
ab1da8f865 Add new lint upper_case_acronyms 2021-01-20 18:03:06 +09:00
Hirochika Matsumoto
6c830ff9e4 Run cargo dev new_lint 2021-01-20 18:02:29 +09:00
Marijn Suijten
d4bf59b6ef size_of_in_element_count: Disable lint on division by byte-size
It is fairly common to divide some length in bytes by the byte-size of a
single element before creating a `from_raw_parts` slice or similar
operation. This lint would erroneously disallow such expressions.

Just in case, instead of simply disabling this lint in the RHS of a
division, keep track of the inversion and enable it again on recursive
division.
2021-01-19 20:05:40 +01:00
Marijn Suijten
391bb218b5 size_of_in_element_count: Separate test file in expressions and functions
An upcoming test case for new expresssion variants make the stderr file
go over 200 lines. Split this test case in two to have a clear
distinction between checking whether the lint is still applying on
all the functions with member counts as argument, versus validating
various member-count expressions that may or may not be invalid.
2021-01-19 20:05:39 +01:00
Takayuki Nakata
966320642b Fix a wrong suggestion of ref_in_deref 2021-01-20 00:21:33 +09:00
bors
d71dea40cf Auto merge of #6577 - nahuakang:inspect_then_for_each, r=flip1995
New Lint: inspect_then_for_each

**Work In Progress**

This PR addresses [Issue 5209](https://github.com/rust-lang/rust-clippy/issues/5209) and adds a new lint called `inspect_then_for_each`.

Current seek some guidance.

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

---

changelog: Add [`inspect_for_each`] lint for the use of `inspect().for_each()` on `Iterators`.
2021-01-19 13:12:39 +00:00
nahuakang
3269070261 Create new lint for the usage of inspect for each. 2021-01-19 11:30:20 +01:00
ThibsG
e33ab3fdd8 Add test for needless_return lint 2021-01-18 22:33:25 +01:00
Marc Dominik Migge
eb476c6c70 Split up tests for unit arg expressions 2021-01-18 20:18:56 +01:00
Ashley Mannix
9009f8f031 Rollup merge of #81038 - flip1995:clippyup, r=Manishearth
Update Clippy

Biweekly Clippy update

r? ``@Manishearth``
2021-01-18 21:53:22 +10:00
kai.giebeler
c3244c25ac add test for doc_valid_idents "WebGL" 2021-01-17 22:57:08 +01:00
Joshua Nelson
abb40c965f Fix formatting for removed lints
- Don't add backticks for the reason a lint was removed. This is almost
never a code block, and when it is the backticks should be in the reason
itself.
- Don't assume clippy is the only tool that needs to be checked for
backwards compatibility
2021-01-17 16:18:02 -05:00
ThibsG
70704db36f Do not lint when range is completely included into another one 2021-01-17 21:07:01 +01:00
pro-grammer1
32b2a3f944 Add numeric literals to the write_literal and print_literal tests that shouldn't fail 2021-01-17 19:21:33 +00:00
pro-grammer1
fb2a06dcce Remove numeric literals from print_literal and write_literal tests 2021-01-17 18:55:59 +00:00
bors
990e2b35b2 Auto merge of #6528 - Jarcho:redundant_slicing, r=flip1995
New lint: redundant_slicing

changelog: Added lint: `redundant_slicing`
fixes #6519

This will trigger on any type which implements `Index<RangeFull>` that returns the input type. This would be a false positive if the implementation does something other than return itself, but I'm not sure why you would ever want to do that.
2021-01-17 16:26:28 +00:00
bors
e0d331fbf4 Auto merge of #6582 - rail-rain:ice_6539, r=flip1995
Fix the ICE 6539

Fixes #6539

It happened because `zero_sized_map_values` used `layout_of` with types from type aliases, which is essentially the same as the ICE 4968.

---

changelog: Fix an ICE in `zero_sized_map_values`
2021-01-17 15:38:50 +00:00
Marc Dominik Migge
0c347d3d06 Fix false positive for unit_arg lint 2021-01-17 14:42:36 +01:00
bors
40ce9f83b6 Auto merge of #6549 - ThibsG:FixClosureNeedlessReturn, r=phansch
Fix FP with empty return for `needless_return` lint

This fixes a false positive in `needless_return` lint, when triggered in a closure using `return` statement without value.

Fixes: #6501

changelog: none
2021-01-17 10:29:10 +00:00
flip1995
7449dc96c0 Deprecate unknown_clippy_lints
This is now handled by unknown_lints
2021-01-16 19:44:46 +01:00
Jason Newcomb
837bc99065
Initial implementation of redundant_slicing lint 2021-01-15 16:41:13 -05:00
bors
3577cf79de Auto merge of #6500 - Javier-varez:case_sensitive_file_extensions, r=llogiq
Case sensitive file extensions

Closes #6425

Looks for ends_with methods calls with case sensitive extension comparisons.

changelog: Add new lint that warns about case-sensitive file extension comparisons.
2021-01-15 19:49:39 +00:00
ThibsG
46aa654c2d Fix test due to recent Rustup merge 2021-01-15 18:58:48 +01:00
ThibsG
83f1abff48 Fix FP with empty return for needless_return lint 2021-01-15 18:57:56 +01:00
bors
2d1e129851 Auto merge of #6574 - Jarcho:single_match_eq, r=Manishearth
single_match: suggest `if` over `if let` when possible

fixes: #173
changelog: single_match: suggest `if` over `if let` when possible
2021-01-15 16:25:03 +00:00
flip1995
488153ff2f Merge commit '953f024793dab92745fee9cd2c4dee6a60451771' into clippyup 2021-01-15 10:56:44 +01:00
flip1995
f18cf82ca8
Don't trigger needless_return lint in macros 2021-01-15 10:41:29 +01:00
flip1995
9bd037d0b5
Merge remote-tracking branch 'upstream/master' into rustup 2021-01-15 10:39:53 +01:00
Jason Newcomb
85edd65bf6
Address review comments
Add: attempt to remove address of expressions from the scrutinee expression before adding references to the pattern
2021-01-14 14:26:26 -05:00
rail
feee45c872 Fix the ICE 6539
It happened because `zero_sized_map_values` used `layout_of` with types
from type aliases, which is essentially the same as the ICE 4968.
2021-01-13 12:07:33 +13:00
Cameron Steffen
f2d493504c Similar names ignore underscore prefixed names 2021-01-12 14:21:28 -06:00
bors
7f4599a848 Auto merge of #6557 - rail-rain:extending_cast_ptr_alignment, r=phansch
Catch `pointer::cast` too in `cast_ptr_alignment`

Fixes #4708

Although there were some discussion in the issue, this PR implements the original feature. I think `cast_ptr_alignment` should exist as it is, separated from `ptr_as_ptr`.

---

changelog: Extend `cast_ptr_alignment` lint for the `pointer::cast` method
2021-01-11 22:03:46 +00:00
bors
1eed27f374 Auto merge of #6575 - flip1995:stop_linting_deps, r=Manishearth
Change env var used for testing Clippy

This changes the variable used for testing Clippy in the internal test
suite:

```
CLIPPY_TESTS -> __CLIPPY_INTERNAL_TESTS
```

`CLIPPY_TESTS` is understandably used in environments of Clippy users,
so we shouldn't use it in our test suite.

changelog: Fix oversight which caused Clippy to lint deps in some environments.

Once again fixes https://github.com/rust-lang/rust-clippy/issues/3874
2021-01-11 16:49:32 +00:00
Jason Newcomb
8d7417d807
Add: single_match will suggest using if .. == .. instead of if let when applicable 2021-01-10 23:32:23 -05:00
bors
ee0598e254 Auto merge of #6571 - ThibsG:BoxedLocalTrait, r=phansch
Fix FP for `boxed_local` lint in default trait fn impl

Fix FP on default trait function implementation on `boxed_local` lint.

Maybe I checked too much when looking if `self` is carrying `Self` in its bound type.
I can't find a good test case for this, so it could be too much conservative.
Let me know if you think only detecting `self` parameter is enough.

Fixes: #4804

changelog: none
2021-01-09 13:42:28 +00:00
ThibsG
8a6fea4fb8 Fix FP for boxed_local lint in default trait fn impl 2021-01-09 12:26:24 +01:00
Cameron Steffen
cc26919b4d Add unnecessary symbol string lint 2021-01-08 14:49:59 -06:00
Cameron Steffen
121c65f0cf Add keywords to interning defined symbol lint 2021-01-08 12:13:06 -06:00
Cameron Steffen
24c700b5d7 Use DefId in interning defined symbol lint 2021-01-08 12:13:06 -06:00
Cameron Steffen
8490862cc3 Fix path_to_res for enum inherent items 2021-01-08 11:56:52 -06:00
rail
ee9b47dae6 Move is_hir_ty_cfg_dependant to util,
add stuff on pointer::cast` to the document for `cast_ptr_alignment`
and fix line numbers in the test.
2021-01-08 14:15:12 +13:00
Takayuki Nakata
0e14a75506 Reduce the span in from_over_into to impl header 2021-01-08 09:16:11 +09:00
Caio
7d42172899 Reintroduce hir::ExprKind::If 2021-01-07 18:54:12 -03:00
flip1995
547ce0db27
Change env var used for testing Clippy
This changes the variable used for testing Clippy in the internal test
suite:

```
CLIPPY_TESTS -> __CLIPPY_INTERNAL_TESTS
```

`CLIPPY_TESTS` is understandably used in environments of Clippy users,
so we shouldn't use it in our test suite.
2021-01-07 12:38:10 +01:00
rail
f50ded0592 Catch pointer::cast too in cast_ptr_alignment 2021-01-07 16:56:19 +13:00
Philipp Hansch
92f2bbbe06
Fix macro issues with field_reassign_with_default 2021-01-05 20:31:13 +01:00
Javier Alvarez
1527fb61b9 Fix case-sensitive extension check 2021-01-05 14:22:26 +01:00
Javier Alvarez
61f3d9d46b Add case_sensitive_file_extensions lint
Closes #6425

Looks for ends_with methods calls with case sensitive extensions.
2021-01-05 14:22:26 +01:00
bors
a6b72d378f Auto merge of #6542 - rail-rain:ptr_as_ptr, r=flip1995
Add a new lint `ptr_as_ptr`

This PR adds a new lint `ptr_as_ptr` which checks for `as` casts between raw pointers without changing its mutability and suggest replacing it with `pointer::cast`. Closes #5890.

Open question: should this lint be `pedantic` or `style`? I set it `pedantic` for now because the original post suggests using it, but I think the lint also fits well to `style`.

---

changelog: New lint `ptr_as_ptr`
2021-01-05 09:54:34 +00:00
bors
311186b9bb Auto merge of #6513 - nahuakang:fix/empty_enum_lint_never_type, r=flip1995
Fix: Empty enum never type suggested only if the feature is enabled

This PR addresses [Issue 6422](https://github.com/rust-lang/rust-clippy/issues/6422). Instead of always recommending `never type` for empty enums, Clippy would only recommend [the lint](https://rust-lang.github.io/rust-clippy/master/index.html#empty_enum) if [LatePass.TyCtxt](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html) has `features().never_type` enabled.

- \[ ] 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: Only trigger [`empty_enum`] lint if `never_type` feature is enabled.
2021-01-05 09:37:19 +00:00
rail
dfa5d7e818 Fix the MSRV and add the tests for MSRV 2021-01-05 10:21:55 +13:00
rail
4b478a5731 Add a new lint ptr_as_ptr,
which checks for `as` casts between raw pointers
without changing its mutability
and suggest replacing it with `pointer::cast`.
2021-01-05 10:19:03 +13:00
bors
976850b69b Auto merge of #6538 - Jarcho:vec_init_then_push, r=llogiq
New lint: vec_init_then_push

fixes: #1483

This will trigger on `new`, `default`, and `with_capacity` when the given capacity is less than or equal to the number of push calls. Is there anything else this should trigger on?

changelog: Added lint: `vec_init_then_push`
2021-01-04 20:42:18 +00:00
nahuakang
a8d47b4b78 Run cargo dev fmt 2021-01-04 18:41:42 +01:00
nahuakang
bc97f5d215 Address flip1995's review comments 2021-01-04 18:34:05 +01:00
bors
ae9ae9713c Auto merge of #6507 - bengsparks:lint/issue6410, r=flip1995
Needless Question Mark Lint

Fixes #6410, i.e the needless question mark lint

changelog: [`needless_question_mark`] New lint
2021-01-04 14:17:24 +00:00
Benjamin Sparks
ba87acb440
Implemented needless question mark lint 2021-01-04 14:51:48 +01:00
Matthias Krüger
6dcec6ae86 collapsible_if: split collapsible_else_if into its own lint so we can enable/disable it particularly
This splits up clippy::collapsible_if into collapsible_if for
if x {
  if y { }
}
=>
if x && y { }

and collapsible_else_if for

if x {
} else {
 if y { }
}

=>
if x {

} else if y {

}

so that we can lint for only the latter but not the first if we desire.

changelog: collapsible_if: split up linting for if x {} else { if y {} } into collapsible_else_if lint
2021-01-04 13:34:14 +01:00
Matthias Krüger
39f39d5405 match_like_matches_macro: strip refs in suggestion
fixes #6503

changelog: match_like_matches_macro: strip refs in suggestion (#6503)
2021-01-03 20:28:46 +01:00
bors
a02806e00d Auto merge of #6518 - ThibsG:CopyException, r=ebroto
Ensure `Copy` exception in trait definition for `wrong_self_conventio…

Add a test case to ensure `Copy` exception is preserved also in trait definition, when passing `self` by value.

Follow up of #6316

changelog: none
2021-01-02 23:51:49 +00:00
bors
592f7eb7eb Auto merge of #6531 - matthiaskrgr:6522, r=ebroto
field_reassign_with_default: don't expand macros in suggestion

fixes #6522

changelog: field_reassign_with_default: don't expand macros in lint suggestion (#6522)
2021-01-02 23:38:23 +00:00
Jason Newcomb
9427e0356b
Fix clone_on_copy test 2021-01-02 14:15:11 -05:00
flip1995
053afe4907 Use bootstrap rustc for versioncheck in Clippy 2021-01-02 18:12:28 +01:00
Jason Newcomb
1853f8b228
Add lint 2021-01-02 11:08:56 -05:00
flip1995
ba4bf4f9c5 Merge commit '1fcc74cc9e03bc91eaa80ecf92976b0b14b3aeb6' into clippyup 2021-01-02 16:29:43 +01:00
flip1995
106ca96653
Use rustc --version in versioncheck 2021-01-02 16:20:43 +01:00
flip1995
d93692efa2
Merge remote-tracking branch 'upstream/master' into rustup 2021-01-02 16:03:26 +01:00
Matthias Krüger
5d48b91b40 field_reassign_with_default: don't expand macros in suggestion
fixes #6522

changelog: field_reassign_with_default: don't expand macros in lint suggestion (#6522)
2021-01-01 17:01:09 +01:00
Matthias Krüger
59397d6abb make clippy version number correspond to rustc version number.
clippy 0.1.50 corresponds to rustc 1.50.x

This bumps the clippy version number from 0.0.212 to 0.1.50

Fixes #6499
2020-12-31 16:29:26 +01:00
ThibsG
af480a67be Ensure Copy exception in trait definition for wrong_self_convention lint 2020-12-30 12:02:26 +01:00