Skip to content

switch_map followed by box_it fails to satisfy CoreObservable - #280

Merged
M-Adoo merged 2 commits into
rxRust:masterfrom
molybdenumsoftware:reproduction
Jun 29, 2026
Merged

M-Adoo merged 2 commits into
rxRust:masterfrom
molybdenumsoftware:reproduction

Conversation

@mightyiam

Copy link
Copy Markdown
Contributor

Hey, this is not a concrete contribution, but an issue reproduction.
I don't suppose you need me to open a corresponding issue, right?
Anyway, @shivaraj-bh and I tried to think how we may be holding it wrong and couldn't.
We added a control group to check our sanity. And variations on what we actually originally hit.
Then we compared between the FlatMap and SwitchMap types and what caught our eye is the sheer
size of the SwitchMap CoreObservable implementation. I remarked "oh, wow. I wouldn't be surprised if an issue was overlooked there".
Anyway, I hope this report is actually useful and suffices for you experts to identify the issue or let us know how we're holding it wrong.
Thank you.

Co-authored-by: Shahar "Dawn" Or <mightyiampresence@gmail.com>
@mightyiam mightyiam changed the title switch_map followed by box_it fail switch_map followed by box_it fails to satisfy CoreObservable Jun 27, 2026
@mightyiam
mightyiam marked this pull request as ready for review June 27, 2026 08:05
@codecov

codecov Bot commented Jun 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.58%. Comparing base (a469003) to head (534c825).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #280      +/-   ##
==========================================
+ Coverage   82.42%   82.58%   +0.16%     
==========================================
  Files          84       84              
  Lines       11756    11929     +173     
==========================================
+ Hits         9690     9852     +162     
- Misses       2066     2077      +11     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Preserve InnerObs on SwitchMapOuterObserver with PhantomData so boxed switch_map keeps the downstream observer relation. Also clean up the reproduction test formatting and unused closure parameters.
@M-Adoo

M-Adoo commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the focused reproduction.

The root cause is that SwitchMapOuterObserver did not carry the inner observable type in its own type identity. InnerObs only appeared in the Observer impl predicates, so when switch_map(...).box_it() went through the boxed CoreObservable path, the compiler could not preserve the relation between the downstream observer and InnerObs::Item<'a>.

I pushed a fix that makes InnerObs part of SwitchMapOuterObserver via a PhantomData<fn() -> InnerObs> marker.

I also kept the reproduction coverage for Shared / Local, box_it, and box_it_clone, and cleaned up the test formatting.

Verified with:

cargo +nightly fmt --check
cargo test test_switch_map_box_it
cargo test

@M-Adoo
M-Adoo enabled auto-merge June 29, 2026 14:02
@M-Adoo
M-Adoo added this pull request to the merge queue Jun 29, 2026
Merged via the queue into rxRust:master with commit 528b298 Jun 29, 2026
12 checks passed
@mightyiam
mightyiam deleted the reproduction branch June 29, 2026 14:27
@mightyiam

Copy link
Copy Markdown
Contributor Author

Hey, @M-Adoo. Thank you so much!

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.

4 participants