Skip to content

breaking: remove redundant MockExt trait - #285

Merged
alexliesenfeld merged 4 commits into
httpmock:masterfrom
danieleades:agent/clippy-new-ret-no-self
Sep 3, 2026
Merged

alexliesenfeld merged 4 commits into
httpmock:masterfrom
danieleades:agent/clippy-new-ret-no-self

Conversation

@danieleades

@danieleades danieleades commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

What changed

  • remove the MockExt trait
  • keep mock reconstruction on the inherent Mock::new(id, &server) constructor
  • add Mock::id() and make the id field private
  • remove clippy::new_ret_no_self from the temporary allow list

Why

The duplication came from two 2021 changes that were later combined. One added MockRefExt to expose reconstruction and ID access, the other independently added MockRef::new and made the ID public. Once both landed there were two ways to build a mock handle, one inherent and one through an extension trait.

Mock should own its constructor and ID accessor. Dropping the trait leaves one way to do it, puts the field back behind an accessor, and lets Clippy catch future new methods that return something other than Self.

Breaking changes

  • MockExt imports, trait bounds and implementations need removing
  • mock.id becomes mock.id()
  • reconstruction still goes through Mock::new(id, &server)

Runtime behavior is unchanged.

Validation

  • cargo +stable clippy --all-targets --all-features
  • cargo +stable test --all-features --lib
  • cargo +stable fmt --all -- --check
  • all doctests compile
  • git diff --check

@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@danieleades
danieleades marked this pull request as ready for review August 12, 2026 19:25
@danieleades
danieleades force-pushed the agent/clippy-new-ret-no-self branch 4 times, most recently from 7f6946b to 0f62600 Compare August 16, 2026 12:41
@danieleades
danieleades force-pushed the agent/clippy-new-ret-no-self branch from 0f62600 to 6d02436 Compare August 17, 2026 18:50
@danieleades

Copy link
Copy Markdown
Contributor Author

@FalkWoldmann this is good to go, despite the CI failure (it's unrelated).

I'm seeing a lot of flaky tests- some kind of race condition / filename collision? Is there a tracking issue for this already?

@alexliesenfeld
alexliesenfeld merged commit b28b8fe into httpmock:master Sep 3, 2026
12 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