Skip to content

Conversation

@sasezaki
Copy link
Contributor

@sasezaki sasezaki commented Dec 20, 2025

📌 What Does This PR Do?

The printer logic was using is_some() followed by unwrap(), which triggered a clippy::unnecessary_unwrap warning.

🔍 Context & Motivation

just check raises below error.

error: called `unwrap` on `group.expanded_states` after checking its variant with `is_some`
   --> crates/formatter/src/internal/printer/mod.rs:498:51
    |
497 |                     if group.expanded_states.is_some() && group_mode.is_break() {
    |                        ------------------------------- the check is happening here
498 |                         if let Some(last_state) = group.expanded_states.as_ref().unwrap().last() {
    |                                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: try using `if let` or `match`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_unwrap
    = note: `-D clippy::unnecessary-unwrap` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::unnecessary_unwrap)]`

error: could not compile `mago-formatter` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error: could not compile `mago-formatter` (lib test) due to 1 previous error

🛠️ Summary of Changes

  • Refactor: refactors the code to use if let for safe and idiomatic pattern matching on the Option type.

📂 Affected Areas

  • Linter
  • Formatter
  • CLI
  • Composer Plugin
  • Dependencies
  • Documentation
  • Other (please specify):

🔗 Related Issues or PRs

📝 Notes for Reviewers

With this PR, just check would be passed.

2025-12-20T04:40:45.904904Z DEBUG main mago::config: Configuration specifies a stack size of 12582912 bytes.
2025-12-20T04:40:46.675013Z  INFO main mago::service: No issues found.
cargo +nightly fmt --all -- --check --unstable-features
cargo +nightly clippy --workspace --all-targets --all-features -- -D warnings
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.21s
cargo +nightly check --workspace --locked
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.16s

@sasezaki sasezaki marked this pull request as ready for review December 20, 2025 04:52
@azjezz azjezz merged commit c09257b into carthage-software:main Dec 23, 2025
6 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