Remove some uses of unsafe from Myers pattern matching and fastexp #398
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There's two uses of
unsafe
that aren't necessary for performanceor functionality:
format and f64 itself, because there's the safe
f64::from_bits
function in std
&[T]
from a single &T, becausethere's the safe
std::slice::from_ref
functionThe latter flags a minor safety issue: the
ShortTracebackHandler::column_slice method had an incorrect lifetime
in its return value. It was incorrectly suggesting that the returned
slice lived for longer than the
self
value. In particular, codecould write something like (in pseudo-Rust, with named lifetimes of
locals):
This method is private and explicitly designed for debugging use only,
and so (a) this minor safety issue probably doesn't cause issues in
practice, and (b) the fix doesn't break any existing code.
After this PR, the only two remaining uses of
unsafe
are the following, which are likely important for performance (#229 introduced them and states "Benchmarks are around 1.5 x faster when using unsafe").rust-bio/src/pattern_matching/myers/simple.rs
Lines 143 to 158 in 480872e