Move script types to primitives#3431
Conversation
|
🚨 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. |
9d05c21 to
51f6bb0
Compare
|
🚨 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. |
51f6bb0 to
5758abf
Compare
|
🚨 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. |
jamillambert
left a comment
There was a problem hiding this comment.
As far as I can tell both the inline of bytes_to_asm_fmt and the move to primitives are good. I checked locally that the large sections of code that were moved were unchanged, except for the necessary changes in use statements etc. and all tests pass.
Although I didn’t verify or know how to verify if everything that needed to be moved, and only those items, have been moved.
There was a problem hiding this comment.
In 84af64671aa72cc39f5bf67546496d827469601b:
It's fine to unwrap here but the text in the expect message makes no sense. The reason is that "the fmt::Display impl for Self does not return an error". It has nothing to do with memory or writers.
Also, the commit message says you don't know why this method used to exist but you think it is from when Script was Sized. It has nothing to do with Sized. It is because the Display impl used to add a Script(...) wrapper to its output and users (Steven) wanted to get the text out without that noise.
There was a problem hiding this comment.
Oh I thought the Write trait has an error for I/O failures but writes to a String (eg writing to memory) never fail.
Thanks for clarifying the other thing, will fix.
There was a problem hiding this comment.
I'd like to clear this up because if I see this line in code write!(&mut buf, "{}", self).unwrap(); I have to ask myself "why is it ok to unwrap?", so I think using expect("exactly correct reason why this won't panic") is better.
There was a problem hiding this comment.
In this case, probably the best thing to write is "if this returns an error, to_string will panic, which would be a bug in its own right".
There was a problem hiding this comment.
Basically, I don't think you're really justified in having this unwrap here...but the implementation of ToString on T: Display in core has the same unwrap, and so everybody who implements fmt::Display has responded by bending over backward to never actually return a fmt::Result::Err, so we're allowed to pretend like the format functions are infallible.
There was a problem hiding this comment.
Cheers, turns out I'm a wombat anyways, we can just call self.to_string() and bypass the whole issue - face palm.
|
5758abf58e29d8141482d783bceff0bf1f9c4d3a looks good other than the one comment. |
5758abf to
6c115f4
Compare
|
Fixed the commit message but did not change the |
|
🚨 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. |
Hey @jamillambert I recently learned of some new git configuration options that make reviewing codes moves like this easier. It makes patches be colorized so that one doesn't have to manually check that large sections of code are unchanged. Add this to your |
6c115f4 to
c2773fd
Compare
|
🚨 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. |
c2773fd to
ef11581
Compare
|
🚨 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. |
|
Face palm, its 4am here and I got out of bed thinking that I really should get this PR done, only to find I did it 4 days ago. EDIT: Its #3406 that got me out of bed, and it does still need doing :) My review request stand still though please. Review please @apoelstra. |
Sorry. I probably ran this several days ago and forgot to dig into and repost the failure. |
This function does not need to exist anymore because it is exactly the same as what is produced by the `Display` impl.
Move the `Script` and `ScriptBuf` types to `primitives`, nothing else.
ef11581 to
d649c06
Compare
|
Bother, I fixed that the other day and put the fix in the wrong commit. Added import of |
|
🚨 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. |
|
Will also one-ack merge this since it has no comments from other maintainers and has been open for two weeks (and Kix appears to be offline anyway). |
First patch removes
bytes_to_asm_fmtas requested by Kix here: #3194 (comment)Second patch does the move. The move is minimal but there is quite a bit of code moved in
script/mod.rs- I believe it is as minimal as required as well.