refactor(lowering): Made function not return Maybe and possibly hide diags.#9916
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
PR SummaryMedium Risk Overview Call sites are updated to stop propagating/unwrap’ing this query ( Reviewed by Cursor Bugbot for commit c2d068e. Bugbot is set up for automated code reviews on this repo. Configure here. |
dd3b75b to
bb24961
Compare
74c9f4a to
e1b9767
Compare
bb24961 to
e340c25
Compare
TomerStarkware
left a comment
There was a problem hiding this comment.
@TomerStarkware reviewed 2 files and all commit messages, and made 1 comment.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on orizi).
e1b9767 to
8ce771c
Compare
e340c25 to
c2d068e
Compare

Summary
function_with_body_lowering_diagnosticsnow returnsDiagnosticsdirectly instead ofMaybe<Diagnostics>. Thein_cycleerror case is handled inline usingmatches!(..., Ok(true))rather than propagating via?, allowing the function to be infallible. All call sites are updated to remove.unwrap_or_default()and?unwrapping accordingly.Type of change
Please check one:
Why is this change needed?
function_with_body_lowering_diagnosticswas returningMaybe<Diagnostics>despite having no meaningful failure path — the only?usage was ondb.in_cycle(...), which on error would silently swallow all diagnostics collected up to that point. This meant a query failure could cause legitimate diagnostics to be lost rather than reported.What was the behavior or documentation before?
If
db.in_cycle(function_id, DependencyType::Cost)returned anErr, the function would early-returnErr, discarding any diagnostics already accumulated in the builder. Call sites used.unwrap_or_default()to recover, silently dropping those diagnostics.What is the behavior or documentation after?
The function is now infallible and always returns a
Diagnosticsvalue. Thein_cycleresult is checked withmatches!(..., Ok(true)), so errors are treated as "not in cycle" without aborting diagnostic collection. All diagnostics gathered before the cycle check are preserved and returned regardless of whetherin_cyclesucceeds.Related issue or discussion (if any)
Additional context
The test helper in
block_generator_test.rsis also updated to remove the now-unnecessary.unwrap()call.