Skip to content

Conversation

mikavilpas
Copy link
Contributor

I started reading the codebase and noticed cargo clippy suggests some refactorings that can be done. If these seem like a good idea, they can be included (most are basically autofixes)

image

Running cargo clippy suggested using the matches! macro in various places. There are many other fixes, but this commit focuses on just using the matches! macro.

92  warning: match expression looks like `matches!` macro
   --> crates/emmylua_parser/src/grammar/lua/stat.rs:33:5
    |
 33 | /     match p.current_token() {
 34 | |         LuaTokenKind::TkElse
 35 | |         | LuaTokenKind::TkElseIf
 36 | |         | LuaTokenKind::TkEnd
 ...  |
 39 | |         _ => false,
 40 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_like_matches_macro
    = note: `#[warn(clippy::match_like_matches_macro)]` on by default
 help: try
    |
 33 ~     matches!(p.current_token(), LuaTokenKind::TkElse
 34 +         | LuaTokenKind::TkElseIf
 35 +         | LuaTokenKind::TkEnd
 36 +         | LuaTokenKind::TkEof
 37 +         | LuaTokenKind::TkUntil)
    |

Running `cargo clippy` suggested using the `matches!` macro in various
places. There are many other fixes, but this commit focuses on just
using the `matches!` macro.

```rs
92  warning: match expression looks like `matches!` macro
   --> crates/emmylua_parser/src/grammar/lua/stat.rs:33:5
    |
 33 | /     match p.current_token() {
 34 | |         LuaTokenKind::TkElse
 35 | |         | LuaTokenKind::TkElseIf
 36 | |         | LuaTokenKind::TkEnd
 ...  |
 39 | |         _ => false,
 40 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_like_matches_macro
    = note: `#[warn(clippy::match_like_matches_macro)]` on by default
 help: try
    |
 33 ~     matches!(p.current_token(), LuaTokenKind::TkElse
 34 +         | LuaTokenKind::TkElseIf
 35 +         | LuaTokenKind::TkEnd
 36 +         | LuaTokenKind::TkEof
 37 +         | LuaTokenKind::TkUntil)
    |
```
@CppCXY CppCXY merged commit 0658443 into EmmyLuaLs:main Jul 12, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants