Skip to content

io: Make traits dyn compatible#5249

Merged
apoelstra merged 1 commit intorust-bitcoin:masterfrom
tcharding:push-zroqtltmopzx
Nov 21, 2025
Merged

io: Make traits dyn compatible#5249
apoelstra merged 1 commit intorust-bitcoin:masterfrom
tcharding:push-zroqtltmopzx

Conversation

@tcharding
Copy link
Copy Markdown
Member

@tcharding tcharding commented Nov 6, 2025

Add an API test that shows dyn compatibility of std io traits and the same for ours. Patch the crate to make the test pass.

This is API breaking for io, that means that this cannot be backported to 0.1.0 (depended on by bitcoin v0.32).

Close: #3833

@github-actions github-actions bot added C-bitcoin PRs modifying the bitcoin crate C-io PRs modifying the io crate test C-p2p labels Nov 6, 2025
@github-actions
Copy link
Copy Markdown

github-actions bot commented Nov 6, 2025

🚨 API BREAKING CHANGE DETECTED

To see the changes click details on "Check semver breaks / PR Semver - stable toolchain" job then expand "Run semver checker script" and scroll to the end of the section.

@github-actions github-actions bot added the API break This PR requires a version bump for the next release label Nov 6, 2025
@tcharding
Copy link
Copy Markdown
Member Author

tcharding commented Nov 6, 2025

Finally I got Claude to do something useful in a reasonable amount of time. I doubt I would have gotten the &mut &mut *r

@github-actions
Copy link
Copy Markdown

github-actions bot commented Nov 6, 2025

🚨 API BREAKING CHANGE DETECTED

To see the changes click details on "Check semver breaks / PR Semver - stable toolchain" job then expand "Run semver checker script" and scroll to the end of the section.

@tcharding
Copy link
Copy Markdown
Member Author

Improved yesterdays effort by adding an additional patch that removes the need to do the &mut &mut thing.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Nov 6, 2025

🚨 API BREAKING CHANGE DETECTED

To see the changes click details on "Check semver breaks / PR Semver - stable toolchain" job then expand "Run semver checker script" and scroll to the end of the section.

@apoelstra
Copy link
Copy Markdown
Member

In 8d9df9a:

Can you add a comment saying that the code you've written is equivalent to self.take(limit).read_to_end(), but you can't use this because:

  • self is potentially unsized
  • &mut self is sized but potentially does not implement Read (would require a blanket impl which would make "substitute io for std non-additive)

@apoelstra
Copy link
Copy Markdown
Member

Wait. the second point is untrue. So why do we need the first commit here?

@apoelstra
Copy link
Copy Markdown
Member

I think you can drop your first commit entirely and this will still compile.

I had assumed that you'd need to do the io::Read::take(r, limit) trick (good find, BTW) but you don't even need to do that, according to my testing.

@tcharding
Copy link
Copy Markdown
Member Author

I think you can drop your first commit entirely and this will still compile.

Yes you are right, nice.

I had assumed that you'd need to do the io::Read::take(r, limit) trick (good find, BTW) but you don't even need to do that, according to my testing.

This is nice and simple now. Cheers.

@github-actions
Copy link
Copy Markdown

🚨 API BREAKING CHANGE DETECTED

To see the changes click details on "Check semver breaks / PR Semver - stable toolchain" job then expand "Run semver checker script" and scroll to the end of the section.

Copy link
Copy Markdown
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 33e66e0; successfully ran local tests

@apoelstra
Copy link
Copy Markdown
Member

Gonna one-ACK merge -- no comments from anyone else for 2 weeks and I don't know if anyone else even cares about the io crate.

@tcharding
Copy link
Copy Markdown
Member Author

tcharding commented Nov 20, 2025

We are just ignoring the MSRV fails and hoping they magically go away, right? I.e., are you intending on merging this as is?

EDIT: Oh silly question, I had not seen all the purple in notifications. I'm trying to do useful work in the morning before looking at notifications so expect more of these sort of comments. Open to process suggestions. The problem I'm trying to solve is that notifications have a tendency to make me not want to be at the computer anymore.

@tcharding
Copy link
Copy Markdown
Member Author

I have been patiently waiting for the MSRV thing to go away for a week though and it has not ...

Add an API test that shows dyn compatibility of std io traits and the
same for ours. Patch the crate to make the test pass.
@github-actions
Copy link
Copy Markdown

🚨 API BREAKING CHANGE DETECTED

To see the changes click details on "Check semver breaks / PR Semver - stable toolchain" job then expand "Run semver checker script" and scroll to the end of the section.

@apoelstra
Copy link
Copy Markdown
Member

I have been patiently waiting for the MSRV thing to go away for a week though and it has not ...

Yes, it is a Github bug. We merged a workaround in #5310.

Copy link
Copy Markdown
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 45d3f18; successfully ran local tests

@apoelstra apoelstra merged commit 152188e into rust-bitcoin:master Nov 21, 2025
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API break This PR requires a version bump for the next release C-bitcoin PRs modifying the bitcoin crate C-io PRs modifying the io crate C-p2p test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

I/O traits should be object safe

2 participants