Commit graph

6231 commits

Author SHA1 Message Date
Alex Macleod
52a68dc097 lint nested patterns and slice patterns in needless_borrowed_reference 2022-10-01 22:31:10 +00:00
Alex Macleod
5a54db1286 Remove unused .fixed files 2022-10-01 22:24:48 +00:00
bors
64243c6f99 Auto merge of #9484 - Xaeroxe:clamping-without-clamp, r=Alexendoo
Implement `manual_clamp` lint

Fixes #9477
Fixes #6751

Identifies common patterns where usage of the `clamp` function would be more succinct and clear, and suggests using the `clamp` function instead.

changelog: [`manual_clamp`]: Implement manual_clamp lint
2022-10-01 20:55:20 +00:00
Jacob Kiesel
b221184572 Implement manual_clamp lint 2022-10-01 13:58:41 -06:00
Nilstrieb
b91dc03510
Add as_ptr_cast_mut lint
This lint detects calls to a `&self`-taking `as_ptr` method, where
the result is then immediately cast to a `*mut T`. Code like this
is probably invalid, as that pointer will not have write permissions,
and `*mut T` is usually used to write through.
2022-10-01 19:23:53 +02:00
Andre Bogus
3757a0e903 avoid doc-link-with-quotes in code blocks 2022-10-01 15:25:37 +02:00
Maybe Waffle
8dfbad9e49 bless clippy 2022-10-01 10:03:06 +00:00
Caio
4876882b29 Fix #9544 2022-09-30 15:30:40 -03:00
bors
a78551bb14 Auto merge of #9556 - evantypanski:et/issue-9369, r=Alexendoo
[`redundant_closure`] Fix suggestion causes error for `impl FnMut`

Fixes #9369

changelog: [`redundant_closure`] Fix suggestion causes error with `impl FnMut` types
2022-09-30 16:42:55 +00:00
Evan Typanski
dbadf37336 Add test case where FnMut used once needs &mut 2022-09-30 11:38:12 -04:00
Evan Typanski
416da1264c [redundant_closure] Add &mut to more cases 2022-09-29 19:35:04 -04:00
kraktus
6ec7759c3b [unnecessary_lazy_eval] Do not lint in external macros 2022-09-29 13:48:50 +02:00
bors
e43f5a17d4 Auto merge of #9516 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2022-09-29 10:04:13 +00:00
kraktus
314d57a790 [unnecessary_lazy_evaluations] Do not suggest switching to early evaluation when type has custom Drop 2022-09-28 22:46:05 +02:00
bors
8845f82142 Auto merge of #9490 - kraktus:needless_borrow, r=Jarcho
fix [`needless_borrow`], [`explicit_auto_deref`] FPs on unions

fix https://github.com/rust-lang/rust-clippy/issues/9383

changelog: fix [`needless_borrow`] false positive on unions
changelog: fix [`explicit_auto_deref`] false positive on unions

Left a couple debug derived impls on purpose I needed to debug as I don't think it's noise
2022-09-28 14:58:07 +00:00
Philipp Krones
bbcde66685
Merge remote-tracking branch 'upstream/master' into rustup 2022-09-28 14:27:32 +02:00
bors
0f6932a1f7 Auto merge of #9546 - kraktus:default_not_default_trait, r=xFrednet
[`should_implement_trait`] Also lint `default` method

close https://github.com/rust-lang/rust-clippy/issues/8550

changelog: FP: [`should_implement_trait`]: Now also works for `default` methods
2022-09-28 11:00:37 +00:00
kraktus
7289835542 [should_implement_trait] Also lint default method 2022-09-28 08:42:01 +02:00
bors
35b7ce5ca9 Auto merge of #9545 - Alexendoo:std-instead-of-core-unstable, r=Manishearth
Don't lint unstable moves in `std_instead_of_core`

Fixes #9515

changelog: [`std_instead_of_core`]: No longer suggests unstable modules such as `core::error`
2022-09-27 20:11:34 +00:00
kraktus
14ba4fba11 fix [needless_borrow] and [explicit_auto_deref] false positive on unions 2022-09-27 21:30:32 +02:00
bors
672fb8e42e Auto merge of #9491 - kraktus:drop_copy, r=Jarcho
[`drop_copy`]: Do not lint idiomatic in match arm

close https://github.com/rust-lang/rust-clippy/issues/9482

changelog: [`drop_copy`]: Do not lint idiomatic in match arm
2022-09-27 19:18:29 +00:00
Alex Macleod
5b0f46a9d9 Don't lint unstable moves in std_instead_of_core
Such as the currently unstable `core::error`
2022-09-27 18:21:14 +00:00
bors
9aa85dc35b Auto merge of #9511 - rust-lang:box-default, r=Alexendoo
add `box-default` lint

This adds a `box-default` lint to suggest using `Box::default()` instead of `Box::new(Default::default())`, which offers less moving parts and potentially better performance according to [the perf book](https://nnethercote.github.io/perf-book/standard-library-types.html#box).

---

changelog: add [`box_default`] lint
2022-09-27 18:14:24 +00:00
bors
47c9145bd0 Auto merge of #9497 - kraktus:needless_return2, r=llogiq
[`needless_return`] Recursively remove unneeded semicolons

fix #8336,
fix #8156,
fix https://github.com/rust-lang/rust-clippy/issues/7358,
fix #9192,
fix https://github.com/rust-lang/rust-clippy/issues/9503

changelog: [`needless_return`] Recursively remove unneeded semicolons

For now the suggestion about removing the semicolons are hidden because they would be very noisy and should be obvious if the user wants to apply the lint manually instead of using `--fix`. This could be an issue for beginner, but haven't found better way to display it.
2022-09-27 14:23:53 +00:00
bors
d31db02e47 Auto merge of #9507 - c410-f3r:arith, r=Alexendoo
[arithmetic-side-effects] Consider references

Takes into consideration integer references like `&i32::MAX` because currently things like `let _ = &1 + 0` trigger the lint.

changelog: FP: [`arithmetic_side_effects`]: Now ignores references
  [9507](https://github.com/rust-lang/rust-clippy/pull/9507)
2022-09-27 14:09:25 +00:00
bors
c153bd6237 Auto merge of #9539 - Jarcho:ice_9445, r=flip1995
Don't lint `*_interior_mutable_const` on unions due to potential ICE.

fixes #9445
cc rust-lang/rust#101113

This started ICE'ing sometime last month due to stricter UB checks. I'm not sure how we could check the value of a union as MIRI doesn't seem to store which field is currently active.

changelog: Don't ICE on const unions containing a `!Freeze` type.
2022-09-27 12:58:41 +00:00
Andre Bogus
63f441ec85 add box-default lint 2022-09-27 13:26:23 +02:00
lcnr
e5ce6d18df rustc_typeck to rustc_hir_analysis 2022-09-27 10:37:23 +02:00
bors
78dc616a7a Auto merge of #9487 - kraktus:question_mark, r=Jarcho
Silence [`question_mark`] in const context

fix https://github.com/rust-lang/rust-clippy/issues/9175

When `const_try` is stabilised can be turned into a MSRV

changelog: Silence [`question_mark`] in const context
2022-09-27 01:12:54 +00:00
fee1-dead
c69edba515 Rollup merge of #102197 - Nilstrieb:const-new-🌲, r=Mark-Simulacrum
Stabilize const `BTree{Map,Set}::new`

The FCP was completed in #71835.

Since `len` and `is_empty` are not const stable yet, this also creates a new feature for them since they previously used the same `const_btree_new` feature.
2022-09-26 13:09:42 +08:00
Yuri Astrakhan
5a71bbdf3f new uninlined_format_args lint to inline explicit arguments
Implement https://github.com/rust-lang/rust-clippy/issues/8368 - a new
lint to inline format arguments such as `print!("{}", var)` into
`print!("{var}")`.

code | suggestion | comment
---|---|---
`print!("{}", var)` | `print!("{var}")` |  simple variables
`print!("{0}", var)` | `print!("{var}")` |  positional variables
`print!("{v}", v=var)` | `print!("{var}")` |  named variables
`print!("{0} {0}", var)` | `print!("{var} {var}")` |  aliased variables
`print!("{0:1$}", var, width)` | `print!("{var:width$}")` |  width
support
`print!("{0:.1$}", var, prec)` | `print!("{var:.prec$}")` |  precision
support
`print!("{:.*}", prec, var)` | `print!("{var:.prec$}")` |  asterisk
support

code | suggestion | comment
---|---|---
`print!("{0}={1}", var, 1+2)` | `print!("{var}={0}", 1+2)` | Format
string uses an indexed argument that cannot be inlined.  Supporting this
case requires re-indexing of the format string.

changelog: [`uninlined_format_args`]: A new lint to inline format
arguments, i.e. `print!("{}", var)` into `print!("{var}")`
2022-09-25 19:53:03 -04:00
Jason Newcomb
b180d954d6 Don't lint *_interior_mutable_const on unions due to potential ICE. 2022-09-25 17:37:56 -04:00
bors
57c9daa09b Auto merge of #9533 - Jarcho:integration-ice-msg, r=llogiq
Fix panic when displaying the backtrace of failing integration tests

changelog: None
2022-09-25 14:33:36 +00:00
Jason Newcomb
84933761f0 Fix panic when displaying the backtrace of failing integration tests 2022-09-25 09:15:29 -04:00
Jason Newcomb
1141c553d8 Fix ICE in needless_pass_by_value with unsized dyn Fn 2022-09-24 17:38:09 -04:00
Nilstrieb
334f4535bd Stabilize const BTree{Map,Set}::new
Since `len` and `is_empty` are not const stable yet, this also
creates a new feature for them since they previously used the same
`const_btree_new` feature.
2022-09-23 20:55:37 +02:00
Yuri Astrakhan
59d0e8caba and a few more from other dirs 2022-09-23 14:25:03 -04:00
Yuri Astrakhan
cb6d1267c4 a few more core lint fixes 2022-09-23 13:55:30 -04:00
Camille GILLOT
781e45c224 Bless clippy. 2022-09-23 18:42:14 +02:00
bors
ff65eec801 Auto merge of #9496 - yotamofek:never_loop_let_else, r=Jarcho
[`never_loop`]: Fix FP with let..else statements.

Fixes #9356

This has been bugging me for a while, so I thought I'd take a stab at it! I'm completely uncertain about the quality of my code, but I think it's an alright start, so opening this PR to get some feedback from more experienced clippy people :)

changelog: [`never_loop`]: Fix FP with let..else statements
2022-09-23 16:06:49 +00:00
Alessandro Decina
49319b4206 uninit_vec: special case set_len(0)
set_len(0) does not create uninitialized elements. Fixes a false positive with
the following pattern:

    fn copy_slice_into_vec(dst: &mut Vec<u8>, src: &[u8]) {
        dst.reserve(src.len().saturating_sub(dst.len()));
        unsafe {
            dst.set_len(0);
            std::ptr::copy_nonoverlapping(src.as_ptr(), dst.as_mut_ptr(), src.len());
            dst.set_len(src.len());
        }
    }
2022-09-23 09:35:47 +01:00
kraktus
b333645971 Add test with unsafe block to check #9503 is fixed too
s
2022-09-22 16:52:25 +02:00
kraktus
a390115c6f [nonstandard_macro_braces] Do not modify macro arguments
Also simplify the lint by not caring about code format which should be `rustfmt` job, and turn the lint into machine Applicable
2022-09-22 16:24:23 +02:00
Caio
4c5f23082a [arithmetic-side-effects] Consider references 2022-09-21 15:02:37 -03:00
David Koloski
4d015293d1 Merge commit '7248d06384c6a90de58c04c1f46be88821278d8b' into sync-from-clippy 2022-09-21 13:13:27 -04:00
bors
7248d06384 Auto merge of #9471 - jplatte:patch-1, r=xFrednet
Add matches! checking to nonstandard_macro_braces

changelog: Enhancement: [`nonstandard_macro_braces`]: Now includes `matches!()` in the default lint config
  [#9471](https://github.com/rust-lang/rust-clippy/pull/9471)
2022-09-21 12:56:19 +00:00
Michael Wright
a783d54207 Fix ICE in unnecessary_to_owned
Fixes #9504

Compiler generated call `into_iter` nodes return empty substs
which we need when checking it's predicates. Handle this by
simply exitting when we encounter one. This change introduces
false negatives in place of the ICEs.
2022-09-21 07:14:04 +02:00
Caio
736d88b549 [arithmetic_side_effects] Add more tests 2022-09-20 12:06:49 -03:00
bors
5c3c6a2de6 Auto merge of #9483 - c410-f3r:arith, r=Jarcho
[arithmetic-side-effects] Finish non-overflowing ops

Extends https://github.com/rust-lang/rust-clippy/pull/9474 to also take into consideration "raw" binary operations. For example, `let a = b / 2` and `let a = 1 * b` won't trigger the lint.

changelog: [arithmetic-side-effects] Finish non-overflowing ops
2022-09-19 14:35:14 +00:00
Jonas Platte
25584c0c67
Add matches! checking to nonstandard_macro_braces 2022-09-19 14:16:59 +02:00
Yotam Ofek
d63aeceaa1 [never_loop]: Fix FP with let..else statements. 2022-09-19 10:57:29 +00:00
kraktus
5c0cb0deaa [needless_return] Recursively remove unneeded semicolons 2022-09-19 12:33:42 +02:00
kraktus
88a57963da [drop_copy]: Do not lint idiomatic in match arm 2022-09-17 15:37:38 +02:00
kraktus
3ca6b9d031 Silence [question_mark] in const context 2022-09-16 22:02:09 +02:00
bors
481dc2e81c Auto merge of #9409 - DesmondWillowbrook:iter_kv_map, r=xFrednet
Add `iter_kv_map` lint

fixes #9376

| before | after |
| -------------- | ------------------------- |
| `hmap.iter().map(\|(key, _)\| key)` | `hmap.keys()` |
| `hmap.iter().map(\|(_, v)\| v + 2)` | `hmap.values().map(\|v\| v + 2)` |
| `hmap.into_iter().map(\|(key, _)\| key)` | `hmap.into_keys()` |

Is `MachineApplicable`

changelog: [`iter_kv_map`]: added lint
2022-09-16 08:44:58 +00:00
Kartavya Vashishtha
c6219b2ece
remove identity function tests 2022-09-16 13:59:51 +05:30
est31
2be8b73328 Fix clippy 2022-09-15 21:21:18 +02:00
Caio
dba5adae6e [arithmetic-side-effects] Finish non-overflowing ops 2022-09-15 13:28:18 -03:00
Kartavya Vashishtha
5004f04ecc
added identity block test
added binding annotations for all lines
2022-09-15 09:46:01 +05:30
Kartavya Vashishtha
5afc261c66
Add iter_kv_map lint 2022-09-15 09:41:06 +05:30
bors
e585b71d9e Auto merge of #9475 - Nemo157:mod-files-remap, r=xFrednet
Make module-style lints resilient to --remap-path-prefix

changelog: [`self_named_module_files`], [`mod_module_files`]: Make module-style lints resilient to `--remap-path-prefix`

Without this if a user has configured `--remap-path-prefix` to be used for a prefix containing the current source directory the lints would silently fail to generate a warning.
2022-09-14 20:09:49 +00:00
Jacob Kiesel
4ffdce09b6 refactor: use clippy_utils::Sugg instead of direct string ops 2022-09-14 13:35:35 -06:00
Jacob Kiesel
9925600870 dogfood inverse bool_to_int_with_if 2022-09-14 13:35:32 -06:00
Jacob Kiesel
1eb41804a2 bool_to_int_with_if inverse case patch 2022-09-14 13:33:13 -06:00
bors
2ddbc86bef Auto merge of #8518 - Alexendoo:write-late-pass, r=flip1995
Migrate write.rs to a late pass

changelog: Migrates write.rs from a pre expansion pass to a late pass
changelog: [`positional_named_format_parameters`] is renamed in favour of the rustc lint `named_arguments_used_positionally`

- Macros are now identified by diagnostic items, so will no longer lint user defined macros named, e.g. a custom `print!`
- `print_literal`/`write_literal` no longer lint no longer lint literals that come from macro expansions, e.g. `env!("FOO")`
- `print_with_newline`/`write_with_newline` no longer lint strings with any internal `\r` or `\n`s

~~A false negative, `print_literal`/`write_literal` don't lint format strings that produce `FormatSpec`s, e.g. ones containing pretty print/width/align specifiers~~

Suggestion changes:
- ~~`print_literal`/`write_literal` no longer have suggestions, as the spans for the `{}`s were not easily obtainable~~
-  `print_with_newline`/`write_with_newline` has a better suggestion for a sole literal newline, but no longer has suggestions for len > 1 strings that end in a literal newline
- ~~`use_debug` spans are less precise, now point to the whole format string~~

The diff for write.rs is pretty unwieldy, other than for the `declare_clippy_lint!`s I think you'd be better off viewing it as a brand new file rather than looking at the diff, as it's mostly written from scratch

cc #6610, fixes #5721, fixes #7195, fixes #8615
2022-09-14 15:58:21 +00:00
bors
9c9aa92898 Auto merge of #9465 - Alexendoo:peekable-fp, r=flip1995
Fix `unused_peekable` closure and `f(&mut peekable)` false positives

changelog: Fix [`unused_peekable`] false positive when peeked in a closure or called as `f(&mut peekable)`

The `return`/`break` changes aren't part of the fix, they allow an earlier return in some cases. `break` is replaced with `return` for style purposes as they do the same thing in this case

Fixes #9456
Fixes #9462
2022-09-14 15:03:39 +00:00
bors
826a8930e6 Auto merge of #9467 - pyhrr0:macro_expansion, r=giraffate
Fix `almost_complete_letter_range` false positive.

changelog: Fix [`almost_complete_letter_range`] false positive in an external macro
2022-09-13 23:45:29 +00:00
Wim Looman
e9722feef3
Make module-style lints resilient to --remap-path-prefix 2022-09-13 21:38:56 +02:00
Caio
611c905482 [arithmetic-side-effects] More non-overflowing ops 2022-09-13 15:50:24 -03:00
kraktus
6f13203b2d Make derivable_impls machine applicable 2022-09-13 17:00:19 +02:00
bors
2e55b42dd7 Auto merge of #9454 - kraktus:use_self, r=flip1995
Do not lint `use_self` in proc macro expansion

fix https://github.com/rust-lang/rust-clippy/issues/9440
fix https://github.com/rust-lang/rust-clippy/issues/8910
fix https://github.com/rust-lang/rust-clippy/issues/6902

changelog: [`use_self`]: Do not lint in proc macro expansion
2022-09-13 12:44:16 +00:00
S. van Dijk
69c7d2cca2
Only ignore external macros. 2022-09-13 10:35:59 +02:00
bors
7b8c4a9e83 Auto merge of #9464 - lukaslueg:issue9463, r=dswij
Don't panic on invalid shift while constfolding

Instead of panicking on invalid shifts while folding constants we simply give up. Fixes #9463

Notice the "attempt to shift right by `1316134912_u32`", which seems weird. AFAICS it comes from rustc itself.

changelog: none
2022-09-12 16:56:53 +00:00
bors
cdf26de6b5 Auto merge of #9466 - lukaslueg:issue9460, r=dswij
Don't lint `large_stack_array` inside static items

We now check if the linted `Expr` is inside an `ItemKind::Static`, which can't take the suggested `Box<[...]`. I _think_ this is the correct fix for #9460

I removed `if_chain` while I was at it.

changelog: Don't lint `large_stack_array` inside static items
2022-09-12 16:35:30 +00:00
bors
5e0663e25c Auto merge of #9469 - Alexendoo:expr-field-visitor, r=giraffate
Fix FormatArgsExpn parsing of FormatSpec positions

Woops, forgot visitors don't walk themselves

Fixes #9468

r? `@giraffate`

changelog: none
2022-09-12 13:58:53 +00:00
Alex Macleod
bd9d375c6b Fix FormatArgsExpn parsing of FormatSpec positions 2022-09-12 11:39:54 +00:00
S. van Dijk
4a6f7abeeb
Add test. 2022-09-12 10:46:29 +02:00
bors
69f6009f85 Auto merge of #9410 - dswij:issue-9375, r=xFrednet
Use macro callsite when creating `Sugg` helper

Closes #9375

changelog: Improvement: [`collapsible_if`]: Suggestions now work with macros, by taking the call site into account.
2022-09-11 15:10:00 +00:00
Lukas Lueg
6f41a44c3e Dont lint large_stack_array inside static items
Fixes #9460
2022-09-11 16:24:33 +02:00
Alex Macleod
86d18b50ed Fix unused_peekable closure and f(&mut peekable) false positives 2022-09-11 12:40:52 +00:00
Lukas Lueg
1e23c65d5e Don't panic on invalid shift while constfolding
Fixes #9463
2022-09-11 12:26:13 +02:00
kraktus
d50f366612 Do not expand macro in nonminimal_bool suggestions 2022-09-10 19:48:14 +02:00
kraktus
c433d542cf Do not lint use_self in proc macro expansion 2022-09-10 11:42:37 +02:00
kraktus
0958f9486b Add manual_filter lint for Option
Share much of its implementation with `manual_map` and should greatly benefit from its previous feedback.
2022-09-10 10:41:55 +02:00
kraktus
cd69d86c89 assertions_on_result_states fix suggestion when assert! not in a statement 2022-09-10 10:30:19 +02:00
bors
5652ccbc0f Auto merge of #9448 - Alexendoo:large-enum-variant-u128, r=Manishearth
Replace u128 with u64 in large_enum_variant uitest

A u128 has [an 8 byte alignment on x86](https://github.com/rust-lang/rust/issues/54341), but a 16 byte alignment on aarch64 which changes the size of the enums due to extra padding. This means the test fails on aarch64

changelog: none
2022-09-09 17:21:53 +00:00
Philipp Krones
98bf99e2f8 Merge commit 'b52fb5234cd7c11ecfae51897a6f7fa52e8777fc' into clippyup 2022-09-09 13:36:26 +02:00
bors
b52fb5234c Auto merge of #9446 - mikerite:fix-9431-2, r=giraffate
Fix `range_{plus,minus}_one` bad suggestions

Fixes #9431.

The current `range_plus_one` and `range_minus_one` suggestions are completely incorrect when macros are involved.

This commit resolves this by disabling the lints for any range expression that is expanded from a macro. The reasons for this are that it is very difficult to create a correct suggestion in this case and that false negatives are less important for pedantic lints.

changelog: Fix `range_{plus,minus}_one` bad suggestions
2022-09-08 23:48:08 +00:00
Alex Macleod
8b25e53d50 Replace u128 with u64 in large_enum_variant uitest
A u128 has an 8 byte alignment on x86, but a 16 byte alignment on
aarch64 which changes the size of the enums due to extra padding
2022-09-08 20:44:32 +00:00
Alex Macleod
6fc6d87fd0 Migrate write.rs to a late pass 2022-09-08 20:18:02 +00:00
Philipp Krones
4ee55c5528
Merge remote-tracking branch 'upstream/auto' into rustup 2022-09-08 21:27:09 +02:00
Michael Wright
a6d8afd958 Fix range_{plus,minus}_one bad suggestions
Fixes #9431.

The current `range_plus_one` and `range_minus_one` suggestions
are completely incorrect when macros are involved.

This commit resolves this by disabling the lints for any range
expression that is expanded from a macro. The reasons for this
are that it is very difficult to create a correct suggestion in
this case and that false negatives are less important for
pedantic lints.
2022-09-08 20:04:43 +02:00
Caio
51d8b6c664 Rename the arithmetic lint 2022-09-08 12:04:55 -03:00
bors
617417e9ad Auto merge of #9365 - c410-f3r:arith, r=Alexendoo
[Arithmetic] Consider literals

Fixes https://github.com/rust-lang/rust-clippy/issues/9307 and makes the `arithmetic` lint behave like `integer_arithmetic`.

It is worth noting that literal integers of a binary operation (`1 + 1`, `i32::MAX + 1`), **regardless if they are in a constant environment**, won't trigger the lint. Assign operations also have similar reasoning.

changelog: Consider literals in the arithmetic lint
2022-09-07 19:55:34 +00:00
Jason Newcomb
15859323ea Fix hang in vec_init_then_push 2022-09-07 15:26:44 -04:00
Caio
0d078c9fd6 [Arithmetic] Consider literals 2022-09-07 10:00:45 -03:00
bors
7babd1b099 Auto merge of #9421 - xphoniex:fix-#9420, r=giraffate
Suggest `unwrap_or_default` when closure returns `"".to_string`

Closes https://github.com/rust-lang/rust-clippy/issues/9420

changelog: [`unwrap_or_else_default`]: suggest `unwrap_or_default()` instead of `unwrap_or_else` with a closure that returns an empty `to_string`.
2022-09-06 23:44:38 +00:00
xphoniex
b21d9d307b
Suggest unwrap_or_default when closure returns "".to_string
Signed-off-by: xphoniex <xphoniex@users.noreply.github.com>
2022-09-06 04:38:29 +00:00
bors
ce339b219a Auto merge of #101241 - camsteffen:refactor-binding-annotations, r=cjgillot
`BindingAnnotation` refactor

* `ast::BindingMode` is deleted and replaced with `hir::BindingAnnotation` (which is moved to `ast`)
* `BindingAnnotation` is changed from an enum to a tuple struct e.g. `BindingAnnotation(ByRef::No, Mutability::Mut)`
* Associated constants added for convenience `BindingAnnotation::{NONE, REF, MUT, REF_MUT}`

One goal is to make it more clear that `BindingAnnotation` merely represents syntax `ref mut` and not the actual binding mode. This was especially confusing since we had `ast::BindingMode`->`hir::BindingAnnotation`->`thir::BindingMode`.

I wish there were more symmetry between `ByRef` and `Mutability` (variant) naming (maybe `Mutable::Yes`?), and I also don't love how long the name `BindingAnnotation` is, but this seems like the best compromise. Ideas welcome.
2022-09-06 03:16:29 +00:00
Takayuki Maeda
4bcaddeeb2 separate the receiver from arguments in HIR under /clippy 2022-09-05 22:25:57 +09:00