-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Tracking Issue for hint::assert_unchecked
#119131
Comments
Add `hint::assert_unchecked` Libs-API expressed interest, modulo bikeshedding, in rust-lang/libs-team#315 (comment) I think that means this is good for nightly, since we can always rename it before stabilization. Tracking issue: rust-lang#119131
Add `hint::assert_unchecked` Libs-API expressed interest, modulo bikeshedding, in rust-lang/libs-team#315 (comment) I think that means this is good for nightly, since we can always rename it before stabilization. Tracking issue: rust-lang/rust#119131
…<try> Use `assert_unchecked` instead of `assume` intrinsic in the standard library Now that a public wrapper for the `assume` intrinsic exists, we can use it in the standard library. CC rust-lang#119131
…Nilstrieb Use `assert_unchecked` instead of `assume` intrinsic in the standard library Now that a public wrapper for the `assume` intrinsic exists, we can use it in the standard library. CC rust-lang#119131
Hello libs-api folks! I'm nominating this (at low priority) because when the open issue is the name, I think it mostly needs your input to make progress. |
What if the name was unsafe fn get_unchecked(self, slice: *const [T]) -> *const T {
unsafe { slice.as_ptr().add(self) }
unsafe {
safety_invariant(self < slice.len());
slice.as_ptr().add(self)
}
} |
…Nilstrieb,cuviper Use `assert_unchecked` instead of `assume` intrinsic in the standard library Now that a public wrapper for the `assume` intrinsic exists, we can use it in the standard library. CC rust-lang#119131
We discussed this in the libs-api meeting and we're happy with @rfcbot fcp merge |
Team member @Amanieu has proposed to merge this. The next step is review by the rest of the tagged team members: Concerns:
Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
Todo list: docs could use an example (+1 for the name |
@rfcbot concern doc-example I agree that we should have a doc example showing when someone might want to use this method. The docs otherwise look good as written! |
Suggestion for doc example: show example implementation of |
Could Edit: I guess |
I am unsure whether the FCP at #119131 (comment) was purely for the unstable name change or an intent to stabilize; assuming the latter, I created a stabilization PR at #123588. That PR should also resolve the docs example concern. |
Add `hint::assert_unchecked` Libs-API expressed interest, modulo bikeshedding, in rust-lang/libs-team#315 (comment) I think that means this is good for nightly, since we can always rename it before stabilization. Tracking issue: rust-lang/rust#119131
The problem is that all those extra |
Add `hint::assert_unchecked` Libs-API expressed interest, modulo bikeshedding, in rust-lang/libs-team#315 (comment) I think that means this is good for nightly, since we can always rename it before stabilization. Tracking issue: rust-lang/rust#119131
@rfcbot resolve doc-example |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. This will be merged soon. |
What happens if the expression passed to assert_unchecked has a side effect? I could not find a clear answer in the current documentation. |
|
In that case I think the documentation could use a clarification on a few related points:
|
If there are no other uses? Probably, at some point in the optimization pipeline. But up to that point the expression is preserved which can affect earlier optimizations. Which is one of the reasons why the docs say
The usual approach is to benchmark, look at the assembly or look at the LLVM IR after optimizations to see if it's worthwhile. Blind applications of the hint are discouraged. |
…d, r=dtolnay Stabilize `hint::assert_unchecked` Make the following API stable, including const: ```rust // core::hint, std::hint pub const unsafe fn assert_unchecked(p: bool); ``` This PR also reworks some of the documentation and adds an example. Tracking issue: rust-lang#119131 FCP: rust-lang#119131 (comment). The docs update should resolve the remaining concern.
Rollup merge of rust-lang#123588 - tgross35:stabilize-assert_unchecked, r=dtolnay Stabilize `hint::assert_unchecked` Make the following API stable, including const: ```rust // core::hint, std::hint pub const unsafe fn assert_unchecked(p: bool); ``` This PR also reworks some of the documentation and adds an example. Tracking issue: rust-lang#119131 FCP: rust-lang#119131 (comment). The docs update should resolve the remaining concern.
Closing as completed by #123588. |
Feature gate:
#![feature(hint_assert_unchecked)]
This is a tracking issue for ...
Public API
Steps / History
hint::assume
libs-team#315hint::assert_unchecked
#119133Unresolved Questions
hint::assume
libs-team#315 (comment)Footnotes
https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩
The text was updated successfully, but these errors were encountered: