Repository navigation
std: the unchecked helpers are unsafe fn; std acknowledges the risk at each call (D100, #2208) - #2237
Merged
Merged
Conversation
…sk at each call (D100, #2208) Spec v7.27 (D100): "an unchecked helper should also be an unsafe fn, so even code inside std has to acknowledge the risk when calling it". The helpers whose safety rests on what the caller passes — a raw pointer, a length, an unchecked index — are now `unsafe fn`: sorted_vec.slot_at, hash_index.find, trie's lookup/prefix_node/trie_key_bytes, json_skip, sys's _read_pass/_write_pass, Aes128.new, AesGcm.new, HmacSha256.new, hmac_sha256, and regex.w's helpers over a raw pcre2 code pointer. Every std caller that was not already inside an unsafe context wraps the call in `unsafe { }` (json, sys, gcm, the Regex methods, which vouch for the code pointer they own). Drop/deref impls that encapsulate their unsafe are untouched.
Contributor
Author
|
Battery GREEN on stack top dd1c22f (seed-driven): gate rc=0 555s, uat rc=0 26s, battery-checks rc=0 823s. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Spec v7.27 (D100): an unchecked helper is also an
unsafe fn. sorted_vec.slot_at, hash_index.find, trie's lookup/prefix_node/trie_key_bytes, json_skip, sys's _read_pass/_write_pass, Aes128.new, AesGcm.new, HmacSha256.new, hmac_sha256 and regex.w's raw-code helpers areunsafe fn; every std caller not already in an unsafe context wraps the call. Found on the way:with checkof a module says ok over a bare unsafe call inside an uninstantiated generic body (#2235).Fixes #2208. Draft until the stack's battery is green.