Repository navigation
refactor: match where a combinator's fallback is itself a branch - #16686
Conversation
…efault `map_or` evaluates its default argument whether or not the option holds a value, so both `Duration` constructors ran on every renderer build even when `throttleProgress` was set. A `match` builds only the arm it takes, the nested `if`/`else` flattens into a guard arm, and the chosen value now reads ahead of its fallback. Left alone in this file: the `map_or_else` in `renderer_width`. It belongs to the default-first `map_or_else` sweep, not to this eager-default shape, so it is converted in that commit instead. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01RNxMkLRG8CRDPwe5vcd28n
`unwrap_or` evaluates its argument unconditionally, so the inner match over
`packageManager.onFail` ran even when `pmOnFail` was configured and decided the
result. Matching on both values at once keeps the configured setting first and
reaches the manifest only when there is no setting.
The inner match also had two arms with the same body, `Some("download") | None`
and `Some(_)`, which collapse into the single catch-all the enum's default
already needs. `PmOnFail` is `Copy`, so the configured value is returned by
value rather than cloned.
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RNxMkLRG8CRDPwe5vcd28n
Two `unwrap_or_else` calls wrapped a whole branch in their closure, so the fallback came before the value it falls back to and the branch sat one level down inside an argument. As sibling match arms the value leads and the branch becomes a guard or a second arm. In the audit renderer this also drops the clone of the `Option` wrapper: only the `String` that is actually returned is cloned now. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01RNxMkLRG8CRDPwe5vcd28n
`tarball_filename` nested one `map_or_else` inside another's closure, so both levels put their failure arm ahead of their success arm and the reader met two fallbacks before either value. An early return for the basename, then a `match` on the parsed name, reads top to bottom. The early return keeps the laziness the nesting provided: the package name is still parsed only when the URL carries no basename. Folding both into one match over a tuple would parse it every time, so it is deliberately not done that way. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01RNxMkLRG8CRDPwe5vcd28n
Across the Rust crates, 41 `map_or_else` calls were written with the default closure on its own line, so the fallback appeared before the value it stands in for and both arms were closures rather than arms. A `match` puts the value first, drops the closures, and lets the fallback read as the sibling it is. A few sites needed more than the mechanical swap: - Where the scrutinee was itself a chain, the chain is bound to a local first so the match reads against a name. - `renderer_width`, `lockfile_path`, and the reporter-flag scan carried an `if`/`else` inside the default closure; those branches are now guard arms. - `project_anchor_importers` and `update_actions_root` nested one option test inside another, so they match over a tuple of both. - `selected_prune_importer_ids` took its outer option with `?` instead of wrapping the body in a `map` closure. - The `json!` argument in `read_archive_by_custom_fetcher` is bound to a local, because a match block inside the macro's value position would be read as an object. Laziness is unchanged everywhere: no arm's work is done unless that arm is taken. Not converted: single-line `map_or` and `map_or_else` calls that already read cleanly, the `unwrap_or` and `unwrap_or_default` calls whose default is a literal or `Default::default()`, and `is_some_and`, which is the idiomatic spelling of that test. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01RNxMkLRG8CRDPwe5vcd28n
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing (1)
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (38)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe PR rewrites optional-value selection across pnpm and pnpr Rust code with explicit matches and early returns. It also constructs package metadata separately before adding it to fetcher options. The summaries report existing fallback outcomes as retained. ChangesOptional-value branch refactors
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Refactor Possibly related PRs
Suggested labels: Suggested reviewers: Merge Risk: ⚪ Minimal · up to No merge-blocking issue is identified; the refactor appears ready to merge after normal checks. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Option combinators into match
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #16686 +/- ##
=======================================
Coverage 92.36% 92.36%
=======================================
Files 1593 1593
Lines 210328 210323 -5
=======================================
- Hits 194268 194266 -2
+ Misses 16060 16057 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Micro-Benchmark ResultsLinux |
Same-run regression checkHEAD and main are measured on the same runner. The tolerance is 5% of the main median or 2 ms, whichever is larger. A regression requires both the median slowdown and the gap between the fastest retained HEAD sample and slowest retained main sample to exceed this tolerance, after trimming up to 10% from each tail. Suspected regressions are rerun once with target order reversed and only fail if reproduced. This conservative noise guard is not a statistical confidence interval. Inconclusive rows do not fail the check. They remain visible for performance review. Bencher retains absolute minimum timings for historical tracking; historical alerts do not gate this PR. Sequential measurements can still be affected by runner drift.
Integrated-Benchmark Report (Linux)Commit: Regular scenarios report direct and pnpr installs. The peer-heavy resolver scenario compares current Rust, main Rust, and TypeScript pnpm; the linked-workspace scenario compares current Rust against main Rust. Bencher consumes pacquet@HEAD and pnpr@HEAD. The tables below show mean ± σ. Bencher tracks absolute minimum latency; PR regression checks compare HEAD and main samples from the same runner. Historical timing alerts do not gate PRs. Scenario: Isolated linker: fresh restore, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.49100647732,
"stddev": 0.13713347265695194,
"median": 2.48068216532,
"user": 1.6172762999999997,
"system": 1.6746125999999997,
"min": 2.31326491932,
"max": 2.7103204133200003
},
{
"command": "pacquet@main",
"mean": 2.44961727342,
"stddev": 0.14950402208525423,
"median": 2.3713987433200003,
"user": 1.6027286999999997,
"system": 1.5249932000000002,
"min": 2.29353079432,
"max": 2.66766831632
},
{
"command": "pnpr@HEAD",
"mean": 1.44462022952,
"stddev": 0.12857720598484698,
"median": 1.42568678632,
"user": 1.2670006999999999,
"system": 1.2993594000000002,
"min": 1.30264913732,
"max": 1.6499068053200001
},
{
"command": "pnpr@main",
"mean": 1.45742092832,
"stddev": 0.15778273995392122,
"median": 1.40906357732,
"user": 1.3948268,
"system": 1.4555108999999997,
"min": 1.31376308632,
"max": 1.76158540132
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.23786372509999998,
"stddev": 0.009447732639834281,
"median": 0.23960793230000002,
"user": 0.26449858000000004,
"system": 0.56869218,
"min": 0.2158816543,
"max": 0.2516934483
},
{
"command": "pacquet@main",
"mean": 0.30575256069999995,
"stddev": 0.06276365332843277,
"median": 0.3274553673,
"user": 0.36047288,
"system": 0.69809728,
"min": 0.2278066323,
"max": 0.38144051630000003
},
{
"command": "pnpr@HEAD",
"mean": 0.27881420300000004,
"stddev": 0.016807056848771134,
"median": 0.2766462363,
"user": 0.31272158,
"system": 0.61635858,
"min": 0.2591021643,
"max": 0.30288726130000004
},
{
"command": "pnpr@main",
"mean": 0.28536443510000004,
"stddev": 0.03754794877538022,
"median": 0.27478997980000003,
"user": 0.32330087999999996,
"system": 0.60091428,
"min": 0.24092894830000003,
"max": 0.3601790253
}
]
}Scenario: Isolated linker: repeat install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.011464647261298698,
"stddev": 0.001166941328511187,
"median": 0.011421758560000002,
"user": 0.006488352294372293,
"system": 0.006226717402597403,
"min": 0.009243438560000001,
"max": 0.01549123856
},
{
"command": "pacquet@main",
"mean": 0.011172954602735045,
"stddev": 0.0012171502285113125,
"median": 0.01090075356,
"user": 0.005913069743589742,
"system": 0.006501152307692307,
"min": 0.00854862856,
"max": 0.016800999559999998
},
{
"command": "pnpr@HEAD",
"mean": 0.011657263997499995,
"stddev": 0.0013576254306379972,
"median": 0.01152438956,
"user": 0.0062475034375,
"system": 0.006796624687499998,
"min": 0.008855968560000002,
"max": 0.015499948560000002
},
{
"command": "pnpr@main",
"mean": 0.011692556582123894,
"stddev": 0.0012057887140972568,
"median": 0.011557726060000002,
"user": 0.006634143716814155,
"system": 0.006450482300884955,
"min": 0.00932898956,
"max": 0.01672549856
}
]
}Scenario: Isolated linker: repeat install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.00972328574844037,
"stddev": 0.0007716939813362509,
"median": 0.00967778712,
"user": 0.006056297522935784,
"system": 0.004483743211009175,
"min": 0.007895137120000001,
"max": 0.01186864412
},
{
"command": "pacquet@main",
"mean": 0.010129772530377354,
"stddev": 0.0009205958329661252,
"median": 0.01002583462,
"user": 0.005397681037735848,
"system": 0.005659528962264151,
"min": 0.00848854012,
"max": 0.013892201120000001
},
{
"command": "pnpr@HEAD",
"mean": 0.010446986132145751,
"stddev": 0.0022570253849984157,
"median": 0.009740360120000001,
"user": 0.006119296599190285,
"system": 0.005168261052631575,
"min": 0.007397632120000001,
"max": 0.018506941120000002
},
{
"command": "pnpr@main",
"mean": 0.010483254709843749,
"stddev": 0.0025090564673970125,
"median": 0.009557721620000001,
"user": 0.006279451093749998,
"system": 0.005085121171874998,
"min": 0.00788554912,
"max": 0.019332611120000003
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.6908664325599996,
"stddev": 0.1207034814365407,
"median": 2.67800584936,
"user": 2.41844576,
"system": 1.87816698,
"min": 2.54921316036,
"max": 2.93292892436
},
{
"command": "pacquet@main",
"mean": 2.6836701007599997,
"stddev": 0.053128743681709924,
"median": 2.69257177386,
"user": 2.42486606,
"system": 1.8676004800000001,
"min": 2.58219684436,
"max": 2.7556315373599998
},
{
"command": "pnpr@HEAD",
"mean": 1.6095060990599996,
"stddev": 0.12004488231025434,
"median": 1.6149440423599999,
"user": 1.56119486,
"system": 1.55291368,
"min": 1.4599687693599999,
"max": 1.79188428336
},
{
"command": "pnpr@main",
"mean": 1.63063132296,
"stddev": 0.11451136450648307,
"median": 1.59928825986,
"user": 1.54203736,
"system": 1.5530158799999998,
"min": 1.4706027653599998,
"max": 1.87342608736
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.7121767859400001,
"stddev": 0.13028325830136464,
"median": 0.7294876597400001,
"user": 1.04152494,
"system": 1.25458968,
"min": 0.56601074924,
"max": 0.8863113242400001
},
{
"command": "pacquet@main",
"mean": 0.5806715976400001,
"stddev": 0.02309597125921881,
"median": 0.5850031812400001,
"user": 0.8088052400000001,
"system": 1.0557551799999998,
"min": 0.5487601012400001,
"max": 0.61476164324
},
{
"command": "pnpr@HEAD",
"mean": 0.35745800934,
"stddev": 0.006063394943430232,
"median": 0.35589815674,
"user": 0.33653314,
"system": 0.7742754800000001,
"min": 0.34791360324,
"max": 0.36650886224
},
{
"command": "pnpr@main",
"mean": 0.36548160164,
"stddev": 0.016071955797736157,
"median": 0.36377181024,
"user": 0.36762083999999995,
"system": 0.77878658,
"min": 0.33714464824,
"max": 0.38612949524
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.67292786374,
"stddev": 0.07155745204726886,
"median": 1.6590007719400002,
"user": 1.0431306,
"system": 1.00804152,
"min": 1.5937824359400001,
"max": 1.83746775794
},
{
"command": "pacquet@main",
"mean": 1.7211535905400002,
"stddev": 0.06163032787065593,
"median": 1.7192816434400002,
"user": 1.1979827,
"system": 1.0416436199999999,
"min": 1.6422958129400003,
"max": 1.82719919394
},
{
"command": "pnpr@HEAD",
"mean": 0.34533286253999995,
"stddev": 0.024757027471709166,
"median": 0.34983525744,
"user": 0.3196844,
"system": 0.6702439200000001,
"min": 0.30528282494000003,
"max": 0.38832328294
},
{
"command": "pnpr@main",
"mean": 0.35170540464,
"stddev": 0.027540296424328356,
"median": 0.35485486944,
"user": 0.34123729999999997,
"system": 0.67875602,
"min": 0.30368343594,
"max": 0.38756309794000005
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.25351213862727273,
"stddev": 0.02230302344244113,
"median": 0.2645159939,
"user": 0.2406716290909091,
"system": 0.09173407636363637,
"min": 0.2050498509,
"max": 0.27423135090000006
},
{
"command": "pacquet@main",
"mean": 0.24454665250000002,
"stddev": 0.018026256859207807,
"median": 0.2438519744,
"user": 0.23056201999999998,
"system": 0.08473094,
"min": 0.21710556890000002,
"max": 0.2716433139
},
{
"command": "pnpr@HEAD",
"mean": 0.09644029764193551,
"stddev": 0.0036149557374942506,
"median": 0.09642058590000001,
"user": 0.03448359096774193,
"system": 0.017011569032258065,
"min": 0.0910104439,
"max": 0.10464584190000001
},
{
"command": "pnpr@main",
"mean": 0.09609270227931033,
"stddev": 0.0027131097376168396,
"median": 0.0963504749,
"user": 0.039611788965517244,
"system": 0.013481493793103448,
"min": 0.0896124559,
"max": 0.10036957190000001
}
]
}Scenario: Isolated linker: peer-heavy resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.28804434430222225,
"stddev": 0.020565245493821455,
"median": 0.28460635008,
"user": 0.3005267555555555,
"system": 0.06809686,
"min": 0.26326941508,
"max": 0.32825722208
},
{
"command": "pacquet@main",
"mean": 0.2890650854133333,
"stddev": 0.019539100157769277,
"median": 0.29013308608,
"user": 0.30679108888888884,
"system": 0.06398430444444445,
"min": 0.25547578108,
"max": 0.31733755908
},
{
"command": "pnpm@HEAD",
"mean": 4.509833009635555,
"stddev": 0.11145734742560601,
"median": 4.5103122120800005,
"user": 6.996419644444444,
"system": 0.4601397488888888,
"min": 4.365785279080001,
"max": 4.703663807080001
}
]
}Scenario: Isolated linker: linked-workspace resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.22966346287333336,
"stddev": 0.007856637007252412,
"median": 0.22943895904000003,
"user": 0.18762307,
"system": 0.0844026,
"min": 0.22026467904000002,
"max": 0.24493335804000002
},
{
"command": "pacquet@main",
"mean": 0.2927942138092307,
"stddev": 0.05602793556939292,
"median": 0.30054074304,
"user": 0.23760170461538457,
"system": 0.11020256153846154,
"min": 0.21970896304,
"max": 0.38561192704
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.4812079339,
"stddev": 0.1156052079669101,
"median": 4.4400602783,
"user": 1.6295722199999996,
"system": 1.5854153800000002,
"min": 4.3662111242999995,
"max": 4.6876631323
},
{
"command": "pacquet@main",
"mean": 4.5100424684,
"stddev": 0.11459069303355668,
"median": 4.491473793299999,
"user": 1.5081669199999996,
"system": 1.4584331799999999,
"min": 4.3615167483,
"max": 4.7097631162999996
},
{
"command": "pnpr@HEAD",
"mean": 3.7007083976000006,
"stddev": 0.2330454152146913,
"median": 3.6432445208,
"user": 1.8026383199999998,
"system": 1.7229300799999998,
"min": 3.4838225313000004,
"max": 4.3084841383
},
{
"command": "pnpr@main",
"mean": 3.618734766,
"stddev": 0.11797652105192409,
"median": 3.6313147538,
"user": 1.6510962200000001,
"system": 1.51555848,
"min": 3.4351086973,
"max": 3.8309685483
}
]
}Scenario: GVS linker: fresh restore, hot cache + hot storeSame install as the isolated fresh-restore hot/hot scenario, into the shared virtual store, the layout pnpm 12 installs into by default. Scenarios run on separate machines, so compare main and branch within each table.
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.15885745841058824,
"stddev": 0.015034574714050234,
"median": 0.15287322094,
"user": 0.1994143552941177,
"system": 0.14329597058823532,
"min": 0.14192622894,
"max": 0.19884690794
},
{
"command": "pacquet@main",
"mean": 0.15403424778210528,
"stddev": 0.007849559844949498,
"median": 0.15489287694,
"user": 0.19449296210526312,
"system": 0.14726165789473683,
"min": 0.13579238193999998,
"max": 0.17219936993999999
},
{
"command": "pnpr@HEAD",
"mean": 0.16677365774,
"stddev": 0.01823994672927464,
"median": 0.17492460094,
"user": 0.20277451999999999,
"system": 0.13752949999999997,
"min": 0.13932310694,
"max": 0.19292307494
},
{
"command": "pnpr@main",
"mean": 0.15058230077333337,
"stddev": 0.00999099529531467,
"median": 0.14877480444,
"user": 0.17045345333333334,
"system": 0.13299394444444446,
"min": 0.13610601094,
"max": 0.17458030394
}
]
} |
KSXGitHub
left a comment
There was a problem hiding this comment.
Some comments/reviews.
… reached The default-first `map_or_else` sites were selected by a regex matching on where rustfmt put a line break. Those calls nest nothing, evaluate nothing early, and invert no logic, so the selector measured a formatting habit rather than finding a defect. Its output was a survey, not a work list. Four conditions disqualify such a site, each of which the sweep had already failed somewhere: - The rewrite has to invent a name whose only job is to be matched on one line later. That moves a level out of the expression and into the enclosing block instead of removing it. - The first closure diverges, so there is no default value to put second. `unwrap_or_else` and `expect` already read as "this must be Some". - The call sits in a macro's value position, where a match block does not parse as a value, so the field ends up lines away from what fills it. - It is test code, read only when it fails, where churn costs review and blame and returns nothing. Twelve files go back to their base state on those grounds, including both `tests/suite` helpers, which were also the two diverging sites, and four of the seven invented bindings. No file under `tests/` is modified by this branch any more. The conversions that remain were each reviewed on their own merits and kept at the reviewer's request for reading better than what they replaced, independently of the sweep that found them. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01RNxMkLRG8CRDPwe5vcd28n
Review preference: the match reads as a statement whose arms each advance the cursor, rather than as an expression whose value is added to it. The arms evaluate to `()`, so the match is a statement and takes no trailing semicolon; `clippy::unnecessary_semicolon` rejects one. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01RNxMkLRG8CRDPwe5vcd28n
Option combinators into match
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
Fourteen commits. The two refactors in them, #16686 and #16700, touch no file this branch changes, so their shapes come through untouched. #16694 reaches `default-reporter`'s lifecycle rendering, where this branch replaced `Frame::emit`'s `fixed: bool`. Both sides add a name to the same `use super::` list; the merge keeps `printable_script_line` beside `BlockPlacement`, and each side's call sites stand. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QYTBQo8HY7xD2iz6hjo1CW
Summary
Five sites where the fallback argument of an
Option/Resultcombinator contains a branch of its own, plus a reduced subset of a wider sweep that is kept at the reviewer's request.The five argued sites
In each case the branch becomes a sibling arm of a
match, so the value is read before the fallback and the nesting goes away.Two of them also stop doing work that was never needed:
map_orandunwrap_orevaluate their default unconditionally, so a branching default was being computed even when the option wasSome. This is the wartclippy::or_fun_callexists for.napi/native_reporter.rs— a two-wayDurationdefault built on every call; now two guard arms.cli/pre_command/pin.rs— a five-armmatchevaluated even whenpm_on_failis set; now one match over both, with a redundant arm pair collapsed.PmOnFailisCopy, so the configured value is returned by value rather than cloned.cli/pre_command/input/reporter_flags.rsandcli/audit/render.rs— anif/matchinside anunwrap_or_elseclosure; now guard arms. The audit one also stops cloning anOptionwrapper to return theStringinside it.pnpr/resolver/wire/tarball_router.rs—map_or_elseinside anothermap_or_else's closure, so the failure arm preceded the success arm twice. An early return keeps the package name from being parsed when the basename is already present.Each is a pure refactor. Laziness is preserved everywhere, including the tarball case, where a single flat
matchover a tuple would have changed the work done.The narrowed sweep
An earlier revision also converted the default-first
map_or_elsecalls that this selector finds:That matches on where rustfmt put a line break. Those calls nest nothing, evaluate nothing early and invert no logic, so the selector measured a formatting habit rather than finding a defect, and its 41 hits were a survey rather than a work list.
Twelve files are back at their base state, on four tests where any single one disqualifies a site:
unwrap_or_elseandexpectalready read as "this must beSome".matchblock is not a value, so the field ends up lines away from what fills it.git blameand returns nothing.No file under
tests/is modified by this branch, and four of the seven invented bindings are gone. The selector now reports 12, against 41 at the base commit.The conversions in the files that remain were each reviewed individually and kept because they read better than what they replaced, not because they fix a defect. That is a style call for pnpm to confirm or revert, and each is a self-contained single-site change, so any subset can be dropped without touching the five above.
Not included: the other
map_or/map_or_elsecall sites in these crates — 226 and 119 respectively, bygrepon the current head. Those were not examined individually, so this PR makes no claim about them. A meaningful share aremap_or(false, …)predicates whose better destination isis_some_andrather than amatch, whichclippy::unnecessary_map_oralready reports atwarn. Worth a separate pass;pnpm/tasksis the place for it.Review round
Seven findings on
b849bd5. One was applied: thereporter_flags.rsmatch-statement suggestion.The other six asked for
.map(…).unwrap_or_else(…). That form cannot be used in this workspace:Cargo.tomlsetspedantic = { level = "warn", priority = -1 }under[workspace.lints.clippy], soclippy::map_unwrap_orfires and-D warningsmakes it an error. Clippy's own suggested fix ismap_or_else(fallback, value), the default-first spelling this PR removes. I implemented all six and confirmed each one fails the gate; tests are not exempt (that exemption belongs to perfectionist, not clippy), and a divergingpanic!fallback is not either. Those threads are left open for a decision between an#[allow]per site and relaxing the lint. Five of the six sites revert to base here regardless, so thematchthey objected to is gone from them.One fragility worth recording: the rewrites in this PR pass clippy only because
clippy::option_if_let_elseis nursery rather than pedantic. That lint is described as "reimplementation ofOption::map_or" and rewrites amatchback into one. If it ever joinedpedantic, this PR's style and the original would both be unlintable.Verification
Run locally against this head:
node pnpm/scripts/rustfmt.mjs --all -- --check— no diffcargo clippy --locked --workspace --all-targets -- --deny warnings— exit 0RUSTFLAGS="-D warnings" cargo dylint --all -- --all-targets --workspace— exit 0, sooverly_long_method_chainand the rest of perfectionist passcargo nextest runover the nine affected crates — 8233 of 8256 passed, 23 failed, 17 skippedAll 23 failures are environmental, each traced to a specific missing prerequisite rather than assumed pre-existing:
chmod 0o555paths that uid 0 bypasses (dlx×4,cache×2,task_run_state,version_flag_reports_a_pin_it_cannot_record,frozen_store_installs_against_a_read_only_global_virtual_store, and onepnpm-configcase)cas_linkerneeds Node.js^24.18.0 || >=26.2.0; the sandbox has 22.22.0pnpm_compatibilityneeds the TypeScript v11 bundle builtpnprcompiler_cacheneedssccacheonPATHThe
pnpm-configfailure was checked specifically, becauseconfig/src/defaults.rsis one of the files this PR changes. It fails identically with that file reverted to its base content, and the changed hunk is inside the"windows"arm ofmatch env::consts::OS, which is unreachable on Linux. CI's Windows job is what actually exercises that arm.Not run locally: the stricter rustdoc that
pre-push:rustuses,RUSTDOCFLAGS="-D warnings" cargo doc --all-features --document-private-items. No doc comments are touched, but it is unverified here and left to CI.Squash Commit Body
Checklist
are implemented in every affected version.
pnpm changeset) if this PR changes any publishedpackage. Keep it short and written for pnpm users — it becomes a release note.
On the two unchecked items:
pacquet,@pnpm/napi,@pnpm/pnpr), but nothing a user can observe changes, so there is no release note to write. The two most recentrefactor(...)commits onmaincarry none either.The template's first item is removed: this PR references no issue.
Written by an agent (Claude Code, claude-opus-5).
🤖 Generated with Claude Code
https://claude.ai/code/session_01RNxMkLRG8CRDPwe5vcd28n