Skip to content

refactor(lading): convert structural-infallible .expect() to unreachable!()#1896

Draft
goxberry wants to merge 1 commit into
goxberry/expect-cleanup-lading-capturefrom
goxberry/expect-cleanup-lading-cat3
Draft

refactor(lading): convert structural-infallible .expect() to unreachable!()#1896
goxberry wants to merge 1 commit into
goxberry/expect-cleanup-lading-capturefrom
goxberry/expect-cleanup-lading-cat3

Conversation

@goxberry
Copy link
Copy Markdown
Contributor

@goxberry goxberry commented May 23, 2026

Summary

Mechanical Cat-3 conversions: replace .expect("...") with .unwrap_or_else(|| unreachable!("...")) (or |_| for Result) at sites where the surrounding code guarantees the invariant holds. No behavior change, no #[expect] annotations, no quarantine drops.

Examples of patterns converted:

  • NonZeroU16::new(1).expect(...) on a literal nonzero constant
  • "...".parse::<IpAddr>().expect(...) on a hard-coded valid string literal
  • Response::builder().body(full(...)).expect(...) after a successful builder chain
  • process tree/file_tree iterators known to be non-empty

This is the foundation of the stacked cleanup that eventually drops the four crate-level #![allow(clippy::expect_used)] quarantines on the lading crate.

Test plan

  • `./ci/validate` passes
  • CI green on this PR

…ble!()

Replace .expect("...") at structural-infallible sites in the lading crate
with .unwrap_or_else(|| unreachable!("...")). These are Cat-3 sites where
the invariant is guaranteed by the surrounding code: NonZero* on literal
nonzero constants, parse() on hard-coded valid strings, hyper Response
::builder().body() after a successful builder, and similar.

No behavioural change, no fn-level annotations, no quarantine drops.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor Author

goxberry commented May 23, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@datadog-official
Copy link
Copy Markdown

Pipelines

Fix all issues with BitsAI

⚠️ Warnings

🚦 1 Pipeline job failed

Changelog Check | changelog-check   View in Datadog   GitHub Actions

🛟 This job is unlikely to succeed on retry. Please review your pipeline configuration. No changes to CHANGELOG.md detected. Add 'no-changelog' label if this is intentional.

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: ec0151e | Docs | Datadog PR Page | Give us feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant