-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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 ptr::fn_addr_eq
#129322
Comments
T-lang as started an FCP for adding a lint against function pointer comparisons and would like to use this method Stabilization ReportImplementation History
API Summary// core::ptr
/// Compares the *addresses* of the two function pointers for equality.
///
/// Function pointers comparisons can have surprising results since
/// they are never guaranteed to be unique and could vary between different
/// code generation units. Furthermore, different functions could have the
/// same address after being merged together.
///
/// This is the same as `f == g` but using this function makes clear
/// that you are aware of these potentially surprising semantics.
pub fn fn_addr_eq<T: FnPtr, U: FnPtr>(f: T, g: U) -> bool {
f.addr() == g.addr()
} The
|
@rfcbot fcp merge |
Team member @dtolnay has proposed to merge this. The next step is review by the rest of the tagged team members:
No concerns currently listed. 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! cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns. |
@rfcbot reviewed |
Expand `ptr::fn_addr_eq()` documentation. * Describe more clearly what is (not) guaranteed, and de-emphasize the description of rustc implementation details. * Explain what you *can* reliably use it for. Tracking issue for `ptr_fn_addr_eq`: rust-lang#129322 The motivation for this PR is that I just learned that `ptr::fn_addr_eq()` exists, read the documentation, and thought: “*I* know what this means, but someone not already familiar with how `rustc` works could be left wondering whether this is even good for anything.” Fixing that seems especially important if we’re going to recommend people use it instead of `==` (as per rust-lang#118833).
Rollup merge of rust-lang#131457 - kpreid:fnaddr, r=dtolnay Expand `ptr::fn_addr_eq()` documentation. * Describe more clearly what is (not) guaranteed, and de-emphasize the description of rustc implementation details. * Explain what you *can* reliably use it for. Tracking issue for `ptr_fn_addr_eq`: rust-lang#129322 The motivation for this PR is that I just learned that `ptr::fn_addr_eq()` exists, read the documentation, and thought: “*I* know what this means, but someone not already familiar with how `rustc` works could be left wondering whether this is even good for anything.” Fixing that seems especially important if we’re going to recommend people use it instead of `==` (as per rust-lang#118833).
@rfcbot reviewed |
@rustbot labels -I-lang-nominated We discussed this in triage today. We've now unanimously checked off on the lang side. We appreciate @rust-lang/libs-api for moving this forward in support of the pending lang work. |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
Feature gate:
#![feature(ptr_fn_addr_eq)]
This is a tracking issue for
std::ptr::fn_addr_eq
Public API
Steps / History
ptr::fn_addr_eq
to compare functions pointers. libs-team#323ptr::fn_addr_eq
#129323 and Expandptr::fn_addr_eq()
documentation. #131457Unresolved Questions
Footnotes
https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩
The text was updated successfully, but these errors were encountered: