]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoSplit out `match_bool`
Jason Newcomb [Sun, 6 Feb 2022 19:25:53 +0000 (14:25 -0500)]
Split out `match_bool`

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

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

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

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

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

2 years agoAuto merge of #8305 - camsteffen:util-cleanup, r=flip1995
bors [Mon, 7 Feb 2022 15:23:23 +0000 (15:23 +0000)]
Auto merge of #8305 - camsteffen:util-cleanup, r=flip1995

Factor out several utils, add `path_def_id`

changelog: none

This is generally an effort to reduce the total number of utils. `path_def_id` is added which I believe is more "cross-cutting" and also complements `path_to_local`. Best reviewed one commit at a time.

Added:
* `path_def_id`
* `path_res`

Removed:
 * `is_qpath_def_path`
 * `match_any_diagnostic_items`
 * `expr_path_res`
 * `single_segment_path`
 * `differing_macro_contexts`
 * `is_ty_param_lang_item`
 * `is_ty_param_diagnostic_item`
 * `get_qpath_generics`

Renamed:
* `path_to_res` to `def_path_res`
* `get_qpath_generic_tys` to `qpath_generic_tys`

CC `@Jarcho` since this relates to some of your work and you may have input.

2 years agoAuto merge of #8326 - matthiaskrgr:warn_on_multi_configs, r=xFrednet
bors [Sun, 6 Feb 2022 17:19:11 +0000 (17:19 +0000)]
Auto merge of #8326 - matthiaskrgr:warn_on_multi_configs, r=xFrednet

warn if we find multiple clippy configs

Fixes #8323

---

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

changelog: warn if we find multiple clippy configs

2 years agoignore test on windows since I don't know why compiletest does not hand paths properl...
Matthias Krüger [Wed, 2 Feb 2022 20:21:20 +0000 (21:21 +0100)]
ignore test on windows since I don't know why compiletest does not hand paths properly there

2 years agoAuto merge of #8398 - Jarcho:unordered_transmute, r=llogiq
bors [Sun, 6 Feb 2022 16:05:00 +0000 (16:05 +0000)]
Auto merge of #8398 - Jarcho:unordered_transmute, r=llogiq

Add lint `transmute_undefined_repr`

Partially implements #3999 and #546

This doesn't consider `enum`s at all right now as those are going to be a pain to deal with. This also allows `#[repr(Rust)]` structs with only one non-zero sized fields. I think those are technically undefined when transmuted.

changelog: Add lint `transmute_undefined_repr`

2 years agoSmall `transmute_float_to_int` cleanup
Jason Newcomb [Sun, 6 Feb 2022 14:42:10 +0000 (09:42 -0500)]
Small `transmute_float_to_int` cleanup

2 years agoAdd lint `transumte_undefined_repr`
Jason Newcomb [Tue, 1 Feb 2022 19:53:12 +0000 (14:53 -0500)]
Add lint `transumte_undefined_repr`

2 years agoAuto merge of #8365 - Alexendoo:explicit-write-suggestion, r=camsteffen
bors [Sat, 5 Feb 2022 17:44:37 +0000 (17:44 +0000)]
Auto merge of #8365 - Alexendoo:explicit-write-suggestion, r=camsteffen

Add `explicit_write` suggestions for `write!`s with format args

changelog: Add [`explicit_write`] suggestions for `write!`s with format args

Fixes #4542

```rust
writeln!(std::io::stderr(), "macro arg {}", one!()).unwrap();
```

Now suggests:

```
error: use of `writeln!(stderr(), ...).unwrap()`
  --> $DIR/explicit_write.rs:36:9
   |
LL |         writeln!(std::io::stderr(), "macro arg {}", one!()).unwrap();
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `eprintln!("macro arg {}", one!())`
```

---------

r? `@camsteffen` (again, sorry 😛) for the `FormatArgsExpn` change

Before this change `inputs_span` returned a span pointing to just `1` in

```rust
macro_rules! one {
    () => { 1 };
}

`writeln!(std::io::stderr(), "macro arg {}", one!()).unwrap();`
```

And the `source_callsite` of that span didn't include the format string, it was just `one!()`

2 years agoAuto merge of #8372 - tamaroning:unwrap_used, r=llogiq
bors [Sat, 5 Feb 2022 14:56:42 +0000 (14:56 +0000)]
Auto merge of #8372 - tamaroning:unwrap_used, r=llogiq

make unwrap_used also trigger on .get().unwrap()

fixes #8124
changelog: make the [unwrap_used] lint trigger for code of the form such as `.get(i).unwrap()` and `.get_mut(i).unwrap()`

2 years agoAdd `explicit_write` suggestions for `write!`s with format args
Alex Macleod [Fri, 28 Jan 2022 14:58:14 +0000 (14:58 +0000)]
Add `explicit_write` suggestions for `write!`s with format args

2 years agoUse source callsite in FormatArgsExpn::inputs_span
Alex Macleod [Fri, 28 Jan 2022 14:42:19 +0000 (14:42 +0000)]
Use source callsite in FormatArgsExpn::inputs_span

2 years agoAuto merge of #8376 - dswij:8373, r=camsteffen
bors [Sat, 5 Feb 2022 00:32:10 +0000 (00:32 +0000)]
Auto merge of #8376 - dswij:8373, r=camsteffen

[`chars_next_cmp`] Fix unescaped suggestion

closes #8373

changelog: [`chars_next_cmp`] Fix unescaped suggestion

2 years agoAuto merge of #8382 - tamaroning:suggest_iter_instead_of_into_iter, r=giraffate
bors [Wed, 2 Feb 2022 12:37:18 +0000 (12:37 +0000)]
Auto merge of #8382 - tamaroning:suggest_iter_instead_of_into_iter, r=giraffate

[explicit_counter_loop] suggests `.into_iter()`, despite that triggering [into_iter_on_ref] in some cases

I have modified `fn make_iterator_snippet` in clippy_lints/src/loops/utils.rs ,so this change has some little influence on another lint [manual_flatten] .

fixes #8155

---
changelog: Fix that [`explicit_counter_loop`] suggests `into_iter()` despite that triggering [`into_iter_on_ref`] in some cases

2 years agochore
tamaron [Wed, 2 Feb 2022 02:25:15 +0000 (11:25 +0900)]
chore

2 years agoAuto merge of #8370 - smoelius:master, r=flip1995
bors [Tue, 1 Feb 2022 21:18:45 +0000 (21:18 +0000)]
Auto merge of #8370 - smoelius:master, r=flip1995

Format `if_chain` invocations in clippy_utils

Not realizing it was [already obsolete](https://github.com/rust-lang/rust-clippy/pull/8360), I built a [tool to format inside `if_chain` invocations](https://crates.io/crates/rustfmt_if_chain).

This PR applies the tool to clippy_utils. (If you apply it to clippy_lints, the changes are extensive.)

Anyway, I'm making it known here in case anyone wants to use it while `if-let` chain support is developed for `rustfmt`. (There could be a few Clippy PRs between now and then, and IMHO, the code looks better with the `if_chain` invocations formatted.)

Cheers.

---

changelog: none

2 years agoAuto merge of #8387 - Jarcho:ptr_arg_8386, r=flip1995
bors [Tue, 1 Feb 2022 20:48:07 +0000 (20:48 +0000)]
Auto merge of #8387 - Jarcho:ptr_arg_8386, r=flip1995

Fix ICE in `ptr_arg`

fixes: #8386

changelog: None

2 years agoFix ICE in `ptr_arg`
Jason Newcomb [Tue, 1 Feb 2022 20:05:20 +0000 (15:05 -0500)]
Fix ICE in `ptr_arg`

2 years agoAuto merge of #8330 - flip1995:changelog, r=llogiq
bors [Tue, 1 Feb 2022 19:30:25 +0000 (19:30 +0000)]
Auto merge of #8330 - flip1995:changelog, r=llogiq

Update Changelog

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

changelog: none

2 years agoMinor cleanup on transmute lints
Jason Newcomb [Tue, 1 Feb 2022 15:53:25 +0000 (10:53 -0500)]
Minor cleanup on transmute lints

2 years agoupdate test suites
tamaron [Tue, 1 Feb 2022 04:44:24 +0000 (13:44 +0900)]
update test suites

2 years agofix code
tamaron [Tue, 1 Feb 2022 04:43:39 +0000 (13:43 +0900)]
fix code

2 years agomultiple configs: add tests
Matthias Krüger [Sun, 30 Jan 2022 12:32:35 +0000 (13:32 +0100)]
multiple configs: add tests

2 years agowarn if we find multiple clippy configs
Matthias Krüger [Thu, 20 Jan 2022 22:00:50 +0000 (23:00 +0100)]
warn if we find multiple clippy configs

Fixes #8323

2 years agoAuto merge of #8369 - Jarcho:ptr_arg_8366, r=flip1995
bors [Mon, 31 Jan 2022 15:17:38 +0000 (15:17 +0000)]
Auto merge of #8369 - Jarcho:ptr_arg_8366, r=flip1995

Don't lint `ptr_arg` for `&mut _` types in trait items

fixes #8366

changelog: Don't lint `ptr_arg` for `&mut _` types in trait items

2 years agoFix `chars_next_cmp` suggestion not escaped
dswij [Mon, 31 Jan 2022 05:35:14 +0000 (13:35 +0800)]
Fix `chars_next_cmp` suggestion not escaped

2 years agoAuto merge of #8322 - jubnzv:8282-single-match, r=llogiq
bors [Sun, 30 Jan 2022 22:00:36 +0000 (22:00 +0000)]
Auto merge of #8322 - jubnzv:8282-single-match, r=llogiq

single_match: Don't lint non-exhaustive matches; support tuples

`single_match` lint:
* Don't lint exhaustive enum patterns without a wild.
  Rationale: The definition of the enum could be changed, so the user can get non-exhaustive match after applying the suggested lint (see https://github.com/rust-lang/rust-clippy/issues/8282#issuecomment-1013566068 for context).
* Lint `match` constructions with tuples (as suggested at https://github.com/rust-lang/rust-clippy/issues/8282#issuecomment-1015621148)

Closes #8282

---

changelog: [`single_match`]: Don't lint exhaustive enum patterns without a wild.
changelog: [`single_match`]: Lint `match` constructions with tuples

2 years agoadd attributes
tamaron [Sun, 30 Jan 2022 06:39:47 +0000 (15:39 +0900)]
add attributes

2 years agoupdate get_unwrap.rs
tamaron [Sun, 30 Jan 2022 05:59:46 +0000 (14:59 +0900)]
update get_unwrap.rs

2 years agofix code
tamaron [Sun, 30 Jan 2022 05:59:25 +0000 (14:59 +0900)]
fix code

2 years agoupdate testsuite
tamaron [Sun, 30 Jan 2022 03:58:49 +0000 (12:58 +0900)]
update testsuite

2 years agomodify code
tamaron [Sun, 30 Jan 2022 03:56:07 +0000 (12:56 +0900)]
modify code

2 years agoDon't lint `ptr_arg` for `&mut _` types in trait items
Jason Newcomb [Sat, 29 Jan 2022 14:45:47 +0000 (09:45 -0500)]
Don't lint `ptr_arg` for `&mut _` types in trait items

2 years agoFormat `if_chain` invocations in clippy_utils
Samuel E. Moelius III [Sat, 29 Jan 2022 15:50:18 +0000 (10:50 -0500)]
Format `if_chain` invocations in clippy_utils

2 years agoAuto merge of #8289 - jubnzv:unspecified-layout-union, r=camsteffen
bors [Sat, 29 Jan 2022 10:58:16 +0000 (10:58 +0000)]
Auto merge of #8289 - jubnzv:unspecified-layout-union, r=camsteffen

Add `default_union_representation` lint

Closes #8235

changelog: Added a new lint  [`default_union_representation`]

2 years agoAdd `default_union_representation` lint
Georgy Komarov [Sat, 15 Jan 2022 09:27:24 +0000 (12:27 +0300)]
Add `default_union_representation` lint

Closes #8235

2 years agoFactor out is_qpath_def_path
Cameron Steffen [Thu, 6 Jan 2022 18:41:17 +0000 (12:41 -0600)]
Factor out is_qpath_def_path

2 years agoFactor out match_any_diagnostic_items
Cameron Steffen [Thu, 6 Jan 2022 15:39:46 +0000 (09:39 -0600)]
Factor out match_any_diagnostic_items

2 years agoFactor out expr_path_res
Cameron Steffen [Thu, 6 Jan 2022 15:35:25 +0000 (09:35 -0600)]
Factor out expr_path_res

2 years agoFactor out single_segment_path
Cameron Steffen [Thu, 6 Jan 2022 15:31:38 +0000 (09:31 -0600)]
Factor out single_segment_path

2 years agoFactor out differing_macro_contexts
Cameron Steffen [Tue, 2 Nov 2021 14:43:31 +0000 (09:43 -0500)]
Factor out differing_macro_contexts

2 years agoFactor out some ty param utils
Cameron Steffen [Thu, 6 Jan 2022 02:56:29 +0000 (20:56 -0600)]
Factor out some ty param utils

2 years agoFactor out get_qpath_generics
Cameron Steffen [Mon, 17 Jan 2022 19:39:45 +0000 (13:39 -0600)]
Factor out get_qpath_generics

2 years agoRename qpath_generic_tys
Cameron Steffen [Mon, 17 Jan 2022 18:57:45 +0000 (12:57 -0600)]
Rename qpath_generic_tys

2 years agoAdd path_def_id util
Cameron Steffen [Tue, 4 Jan 2022 23:24:23 +0000 (17:24 -0600)]
Add path_def_id util

2 years agoRename path_to_res to def_path_res
Cameron Steffen [Thu, 6 Jan 2022 02:36:22 +0000 (20:36 -0600)]
Rename path_to_res to def_path_res

2 years agoAuto merge of #8250 - pr2502:fix_repeat_underflow, r=giraffate
bors [Fri, 28 Jan 2022 13:31:51 +0000 (13:31 +0000)]
Auto merge of #8250 - pr2502:fix_repeat_underflow, r=giraffate

Fix underflow in `manual_split_once` lint

Hi, a friend found clippy started crashing on a suspiciously large allocation of `u64::MAX` memory on their code.

The mostly minimized repro is:
```rust
fn _f01(title: &str) -> Option<()> {
    let _ = title[1..].splitn(2, '[').next()?;
    Some(())
}
```

The underflow happens in this case on line 57 of the patch but I've changed the other substraction to saturating as well since it could potentially cause the same issue.

I'm not sure where to put a regression test, or if it's even worth for such a thing.

Aside, has it been considered before to build clippy with overflow checks enabled?

changelog: fix ICE of underflow in `manual_split_once` lint

2 years agoAuto merge of #8354 - dswij:8345, r=giraffate
bors [Fri, 28 Jan 2022 05:11:09 +0000 (05:11 +0000)]
Auto merge of #8354 - dswij:8345, r=giraffate

Update docs for `map_flatten` on `Option` case

closes #8345

changelog: [`map_flatten`] Add docs info for `Option` case

2 years agoUpdate docs for `map_flatten` on `Option`
dswij [Tue, 25 Jan 2022 08:18:32 +0000 (16:18 +0800)]
Update docs for `map_flatten` on `Option`

2 years agofix underflow in `check_manual_split_once` lint
max [Sat, 8 Jan 2022 22:10:20 +0000 (23:10 +0100)]
fix underflow in `check_manual_split_once` lint

2 years agoAuto merge of #8359 - flip1995:rustup, r=flip1995
bors [Thu, 27 Jan 2022 13:48:23 +0000 (13:48 +0000)]
Auto merge of #8359 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: none

2 years agoBump nightly version -> 2022-01-27
flip1995 [Thu, 27 Jan 2022 13:23:42 +0000 (14:23 +0100)]
Bump nightly version -> 2022-01-27

2 years agoMerge remote-tracking branch 'upstream/master' into rustup
flip1995 [Thu, 27 Jan 2022 13:23:31 +0000 (14:23 +0100)]
Merge remote-tracking branch 'upstream/master' into rustup

2 years agoAuto merge of #8350 - dswij:8331, r=Manishearth
bors [Wed, 26 Jan 2022 19:19:28 +0000 (19:19 +0000)]
Auto merge of #8350 - dswij:8331, r=Manishearth

fix bad suggestion on `numeric_literal`

closes #8331

changelog: [`numeric_literal`]  fix suggestion not showing sign

2 years agomatches: Remove extra comment
Georgy Komarov [Wed, 26 Jan 2022 16:09:31 +0000 (19:09 +0300)]
matches: Remove extra comment

2 years agomatches: Restore `match_type` logic; add tests for these cases
Georgy Komarov [Wed, 26 Jan 2022 15:20:35 +0000 (18:20 +0300)]
matches: Restore `match_type` logic; add tests for these cases

2 years agomatches: Improve naming. NFC.
Georgy Komarov [Wed, 26 Jan 2022 15:02:32 +0000 (18:02 +0300)]
matches: Improve naming. NFC.

2 years agomatches: Clarify the behavior of exhaustive check
Georgy Komarov [Wed, 26 Jan 2022 11:46:30 +0000 (14:46 +0300)]
matches: Clarify the behavior of exhaustive check

2 years agoMerge remote-tracking branch 'origin/master' into 8282-single-match
Georgy Komarov [Wed, 26 Jan 2022 11:15:50 +0000 (14:15 +0300)]
Merge remote-tracking branch 'origin/master' into 8282-single-match

2 years agofix bad suggestion on `numeric_literal`
Dharma Saputra Wijaya [Tue, 25 Jan 2022 14:19:19 +0000 (22:19 +0800)]
fix bad suggestion on `numeric_literal`

2 years agoAuto merge of #93095 - Aaron1011:remove-assoc-ident, r=cjgillot
bors [Tue, 25 Jan 2022 18:53:45 +0000 (18:53 +0000)]
Auto merge of #93095 - Aaron1011:remove-assoc-ident, r=cjgillot

Store a `Symbol` instead of an `Ident` in `AssocItem`

This is the same idea as #92533, but for `AssocItem` instead
of `VariantDef`/`FieldDef`.

With this change, we no longer have any uses of
`#[stable_hasher(project(...))]`

2 years agoUpdate Changelog
flip1995 [Fri, 14 Jan 2022 16:29:54 +0000 (17:29 +0100)]
Update Changelog

2 years agoAuto merge of #8343 - robjtede:patch-1, r=giraffate
bors [Tue, 25 Jan 2022 13:08:10 +0000 (13:08 +0000)]
Auto merge of #8343 - robjtede:patch-1, r=giraffate

Autofocus search input

changelog: autofocus filter input on Clippy Lints page

2 years agoAutofocus search input
Rob Ede [Mon, 24 Jan 2022 11:36:15 +0000 (11:36 +0000)]
Autofocus search input

2 years agoAuto merge of #8315 - dswij:8306, r=giraffate
bors [Mon, 24 Jan 2022 00:03:40 +0000 (00:03 +0000)]
Auto merge of #8315 - dswij:8306, r=giraffate

`trait_duplication_in_bounds` checks path segments for trait items

closes #8306

changelog: [`trait_duplication_in_bounds`] Fix FP when path segments exists for trait items

2 years agoAuto merge of #8311 - dswij:8277, r=llogiq
bors [Sun, 23 Jan 2022 12:59:52 +0000 (12:59 +0000)]
Auto merge of #8311 - dswij:8277, r=llogiq

fix `needless_question_mark` not considering async fn

closes #8277

changelog: [`needless_question_mark`] Fix FN on async functions

2 years agofix `needless_question_mark` not considering async fn
dswij [Tue, 18 Jan 2022 10:41:00 +0000 (18:41 +0800)]
fix `needless_question_mark` not considering async fn

2 years agoUpdate clippy
Vadim Petrochenkov [Sat, 4 Dec 2021 15:09:15 +0000 (23:09 +0800)]
Update clippy

2 years agorustc_lint: Reuse the set of registered tools from resolver
Vadim Petrochenkov [Tue, 28 Sep 2021 22:17:54 +0000 (01:17 +0300)]
rustc_lint: Reuse the set of registered tools from resolver

2 years agoAuto merge of #8217 - Jarcho:needless_borrow_8191, r=camsteffen
bors [Sun, 23 Jan 2022 03:01:39 +0000 (03:01 +0000)]
Auto merge of #8217 - Jarcho:needless_borrow_8191, r=camsteffen

Fix `needless_borrow` causing mutable borrows to be moved

fixes #8191

changelog: Fix `needless_borrow` causing mutable borrows to be moved
changelog: Rename `ref_in_deref` to `needless_borrow`
changelog: Suggest removing the borrow on method call receivers in `needless_borrow`

2 years agoSubsume `ref_in_deref` into `needless_borrow`
Jason Newcomb [Wed, 12 Jan 2022 00:44:33 +0000 (19:44 -0500)]
Subsume `ref_in_deref` into `needless_borrow`

2 years agoRemove final reference on fields and method calls in `needless_borrow`
Jason Newcomb [Tue, 11 Jan 2022 19:31:35 +0000 (14:31 -0500)]
Remove final reference on fields and method calls in `needless_borrow`

2 years agoAuto merge of #8278 - Alexendoo:needless-lifetime-explicit-self-ty, r=xFrednet
bors [Sat, 22 Jan 2022 13:00:39 +0000 (13:00 +0000)]
Auto merge of #8278 - Alexendoo:needless-lifetime-explicit-self-ty, r=xFrednet

`needless_lifetimes`: ignore lifetimes in explicit self types

changelog: false positive fix: [`needless_lifetimes`] no longer lints lifetimes in explicit self types

They're not currently elidable (https://github.com/rust-lang/rust/issues/69064)

Fixes #7296

2 years ago`needless_lifetimes`: ignore lifetimes in explicit self types
Alex Macleod [Fri, 14 Jan 2022 14:24:25 +0000 (14:24 +0000)]
`needless_lifetimes`: ignore lifetimes in explicit self types

2 years agoAuto merge of #8332 - Jarcho:clear_test_results, r=camsteffen
bors [Sat, 22 Jan 2022 04:49:41 +0000 (04:49 +0000)]
Auto merge of #8332 - Jarcho:clear_test_results, r=camsteffen

Don't bless outdated files on windows

changelog: None

2 years agoDon't bless outdated files on windows
Jason Newcomb [Sat, 22 Jan 2022 04:11:32 +0000 (23:11 -0500)]
Don't bless outdated files on windows

2 years agoAuto merge of #8271 - Jarcho:ptr_arg_214, r=flip1995
bors [Fri, 21 Jan 2022 15:43:57 +0000 (15:43 +0000)]
Auto merge of #8271 - Jarcho:ptr_arg_214, r=flip1995

Check usages in `ptr_arg`

fixes #214
fixes #1981
fixes #3381
fixes #6406
fixes #6964

This does not take into account the return type of the function currently, so `(&Vec<_>) -> &Vec<_>` functions may still be false positives.

The name given for the type also has to match the real type name, so `type Foo = Vec<u32>` won't trigger the lint, but `type Vec = Vec<u32>` will. I'm not sure if this is the best way to handle this, or if a note about the actual type should be added instead.

changelog: Check if the argument is used in a way which requires the original type in `ptr_arg`
changelog: Lint mutable references in `ptr_arg`

2 years agoFix `needless_borrow` causing mutable borrows to be moved
Jason Newcomb [Mon, 3 Jan 2022 17:44:33 +0000 (12:44 -0500)]
Fix `needless_borrow` causing mutable borrows to be moved

2 years ago`ptr_arg` cleanup
Jason Newcomb [Fri, 21 Jan 2022 14:43:41 +0000 (09:43 -0500)]
`ptr_arg` cleanup

2 years agoRemove a span from hir::ExprKind::MethodCall
Cameron Steffen [Wed, 1 Dec 2021 17:17:50 +0000 (11:17 -0600)]
Remove a span from hir::ExprKind::MethodCall

2 years agoAuto merge of #8329 - Alexendoo:enum-variant-names, r=giraffate
bors [Fri, 21 Jan 2022 13:37:18 +0000 (13:37 +0000)]
Auto merge of #8329 - Alexendoo:enum-variant-names, r=giraffate

Don't suggest an empty variant name in `enum_variant_names`

changelog: false positive fix: [`enum_variant_names`]: No longer suggests an empty variant name

Fixes #8324

2 years agoDon't suggest an empty variant name in `enum_variant_names`
Alex Macleod [Fri, 21 Jan 2022 12:40:33 +0000 (12:40 +0000)]
Don't suggest an empty variant name in `enum_variant_names`

2 years agoAuto merge of #91359 - dtolnay:args, r=Mark-Simulacrum
bors [Fri, 21 Jan 2022 06:20:18 +0000 (06:20 +0000)]
Auto merge of #91359 - dtolnay:args, r=Mark-Simulacrum

Emit simpler code from format_args

I made this PR so that `cargo expand` dumps a less overwhelming amount of formatting-related code.

<br>

`println!("rust")` **Before:**

```rust
{
    ::std::io::_print(::core::fmt::Arguments::new_v1(&["rust\n"],
                                                     &match () {
                                                          _args => [],
                                                      }));
};
```

**After:**

```rust
{ ::std::io::_print(::core::fmt::Arguments::new_v1(&["rust\n"], &[])); };
```

`println!("{}", x)` **Before:**

```rust
{
    ::std::io::_print(::core::fmt::Arguments::new_v1(
        &["", "\n"],
        &match (&x,) {
            _args => [::core::fmt::ArgumentV1::new(
                _args.0,
                ::core::fmt::Display::fmt,
            )],
        },
    ));
};
```

**After:**

```rust
{
    ::std::io::_print(::core::fmt::Arguments::new_v1(
        &["", "\n"],
        &[::core::fmt::ArgumentV1::new(&x, ::core::fmt::Display::fmt)],
    ));
};
```

2 years agomatches: Simplify code
Georgy Komarov [Fri, 21 Jan 2022 04:28:40 +0000 (07:28 +0300)]
matches: Simplify code

2 years ago single_match: Clarify the `don't lint` test case
Georgy Komarov [Fri, 21 Jan 2022 04:24:07 +0000 (07:24 +0300)]
 single_match: Clarify the `don't lint` test case

2 years agosingle_match: Don't lint non-exhaustive matches; support tuples
Georgy Komarov [Thu, 20 Jan 2022 11:50:14 +0000 (14:50 +0300)]
single_match: Don't lint non-exhaustive matches; support tuples

This commit changes the behavior of `single_match` lint.

After that, we won't lint non-exhaustive matches like this:

```rust
match Some(v) {
    Some(a) => println!("${:?}", a),
    None => {},
}
```

The rationale is that, because the type of `a` could be changed, so the
user can get non-exhaustive match after applying the suggested lint (see
https://github.com/rust-lang/rust-clippy/issues/8282#issuecomment-1013566068
for context).

We also will lint `match` constructions with tuples. When we see the
tuples on the both arms, we will check them both at the same time, and
if they form exhaustive match, we could display the warning.

Closes #8282

2 years ago`trait_duplication_in_bounds` checks path segments for trait items
dswij [Thu, 20 Jan 2022 05:38:48 +0000 (13:38 +0800)]
`trait_duplication_in_bounds` checks path segments for trait items

2 years agoStore a `Symbol` instead of an `Ident` in `AssocItem`
Aaron Hill [Thu, 13 Jan 2022 02:15:51 +0000 (21:15 -0500)]
Store a `Symbol` instead of an `Ident` in `AssocItem`

This is the same idea as #92533, but for `AssocItem` instead
of `VariantDef`/`FieldDef`.

With this change, we no longer have any uses of
`#[stable_hasher(project(...))]`

2 years agoAuto merge of #8280 - xFrednet:8276-map-clone-msrv, r=flip1995
bors [Wed, 19 Jan 2022 16:33:10 +0000 (16:33 +0000)]
Auto merge of #8280 - xFrednet:8276-map-clone-msrv, r=flip1995

Add `msrv` config for `map_clone`

Just a small PR to have some fun with Clippy and to clear my head a bit :sweat_smile:

---

changelog: [`map_clone`]: The suggestion takes `msrv` into account
changelog: Track `msrv` attribute for `manual_bits` and `borrow_as_prt`

fixes: #8276

2 years agoAuto merge of #8304 - camsteffen:test-tweaks, r=flip1995
bors [Wed, 19 Jan 2022 08:55:40 +0000 (08:55 +0000)]
Auto merge of #8304 - camsteffen:test-tweaks, r=flip1995

Remove __CLIPPY_INTERNAL_TESTS env var

changelog: none

It doesn't have any effect AFAICT.

2 years agoAuto merge of #8310 - camelid:rm-stringification, r=Manishearth
bors [Wed, 19 Jan 2022 01:23:15 +0000 (01:23 +0000)]
Auto merge of #8310 - camelid:rm-stringification, r=Manishearth

Remove unnecessary `Symbol` stringification

This should (slightly) improve performance and enhance code quality.

changelog: none

2 years agoRemove unnecessary `Symbol` stringification
Noah Lev [Wed, 19 Jan 2022 00:17:43 +0000 (16:17 -0800)]
Remove unnecessary `Symbol` stringification

This should (slightly) improve performance and enhance code quality.

2 years agoAuto merge of #87648 - JulianKnodt:const_eq_constrain, r=oli-obk
bors [Tue, 18 Jan 2022 09:58:39 +0000 (09:58 +0000)]
Auto merge of #87648 - JulianKnodt:const_eq_constrain, r=oli-obk

allow eq constraints on associated constants

Updates #70256

(cc `@varkor,` `@Centril)`

2 years agoAuto merge of #93001 - flip1995:clippyup, r=Manishearth
bors [Tue, 18 Jan 2022 02:32:36 +0000 (02:32 +0000)]
Auto merge of #93001 - flip1995:clippyup, r=Manishearth

Out of cycle Clippy update

I want to do an out-of-cycle sync for rust-lang/rust-clippy#8295, and possibly backport this to stable together with https://github.com/rust-lang/rust/issues/92938. If this doesn't get backported to stable, then I at least want to backport it to beta.

r? `@Manishearth`

2 years agoAuto merge of #8298 - ebobrow:op_ref_fp, r=giraffate
bors [Tue, 18 Jan 2022 00:12:42 +0000 (00:12 +0000)]
Auto merge of #8298 - ebobrow:op_ref_fp, r=giraffate

fix op_ref false positive

fixes #7572

changelog: `op_ref` don't lint for unnecessary reference in BinOp impl if removing the reference will lead to unconditional recursion

2 years agoUpdate w/ comments
kadmin [Tue, 11 Jan 2022 19:18:18 +0000 (19:18 +0000)]
Update w/ comments

Removes uses of ty() where a method is implemented on TypeFoldable, and also directly formats
a Term.