Commit graph

18 commits

Author SHA1 Message Date
Samuel Tardieu
432a8a7a7c Properly handle expansion in single_match
Having a macro call as the scrutinee is supported. However, the proposed
suggestion must use the macro call itself, not its expansion.

When the scrutinee is a macro call, do not complain about an irrefutable
match, as the user may not be aware of the result of the macro. A
comparaison will be suggested instead, as if we couldn't see the outcome
of the macro.

Similarly, do not accept macro calls as arm patterns.
2025-03-28 22:30:09 +01:00
Samuel Tardieu
a1bdc191ba Reinstate single_match/single_match_else lints with comments
Commit efe3fe9b8c removed the ability for
`single_match` and `single_match_else` to trigger if comments were
present outside of the arms, as those comments would be lost while
rewriting the `match` expression.

This reinstates the lint, but prevents the suggestion from being applied
automatically in the presence of comments by using the `MaybeIncorrect`
applicability. Also, a note is added to the lint message to warn the
user about the need to preserve the comments if acting upon the
suggestion.
2025-03-17 16:14:14 +01:00
Guillaume Gomez
f666fd6417 Update UI tests 2025-02-15 13:38:16 +01:00
lapla-cogito
e38fa00301
address wrong suggestions when using comparing with byte literal string in single_match lint 2024-12-14 02:09:04 +09:00
Guillaume Gomez
efe3fe9b8c Fix single_match lint being emitted when it should not 2024-12-13 16:49:09 +01:00
Philipp Krones
3ab1da8bab
Formatting 2024-09-22 20:52:15 +02:00
WeiTheShinobi
e3ca249e96
fix single_match suggestion 2024-09-06 23:10:42 +08:00
WeiTheShinobi
04d70d04fc
[single_match, single_match_else] fix suggestion when match irrefutable 2024-08-31 05:25:59 +08:00
Jason Newcomb
8bcecfff95 Handle or patterns in single_match and single_match_else 2024-08-07 11:40:15 -04:00
WeiTheShinobi
8e55bbf115 [single_match]: Fix duplicate diagnostics 2024-03-11 01:08:37 +08:00
Guillaume Gomez
b0f358fd3c Update ui test 2024-03-10 01:23:28 +01:00
Alex Macleod
733e1d43c7 Show duplicate diagnostics in UI tests by default 2024-02-28 13:24:14 +00:00
Oli Scherer
3d88fae050 Update ui test crate 2023-08-11 14:02:28 +00:00
Centri3
51b57723d1 new lint redundant_guards 2023-07-22 06:28:05 -05:00
y21
2e856fa99b add test for block comment and add note to description 2023-06-19 20:07:31 +02:00
y21
d7e723441e [single_match]: don't lint if block contains comments 2023-06-19 17:18:27 +02:00
Centri3
26f50395ba Add needless_if lint 2023-06-10 06:51:03 -05:00
Yuri Astrakhan
ed935de087 Run-rustfix 2023-05-22 23:00:28 -04:00