-
-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix stacked borrow violation and add miri CI #25
Conversation
Miri flagged that we borrow a reference to just the first element and then write through it to elements other than the first. The new implementation borrows the whole buffer before writing.
name: Miri | ||
script: | ||
- rustup component add miri || travis_terminate 0 | ||
- cargo miri test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great to see Miri being added here. :)
cargo miri test
will interactively ask for confirmation to install things, and will probably not work. Miri is just not available for the latest nightly so right now we do not enter this code path.
The recommended Miri CI integration is given in our README.
@@ -51,13 +51,15 @@ fn test_ryu() { | |||
|
|||
#[test] | |||
fn test_random() { | |||
let n = if cfg!(miri) { 100 } else { 1000000 }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I like this style... so far I always used #[cfg(miri)]
for this but that means we need 4 lines to define one constant.
let f: f64 = rand::random(); | ||
assert_eq!(f, buffer.format_finite(f).parse().unwrap()); | ||
} | ||
} | ||
|
||
#[cfg(not(miri))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, the usual alternative I use these days is #[cfg_attr(miri, ignore)]
. Then at least it is clear in the output that we are skipping some tests.
It doesn't really make a difference, though.
Fixes #24.