Skip to content

Tracking Issue for ptr::fn_addr_eq #129322

Closed
@Urgau

Description

@Urgau
Member

Feature gate: #![feature(ptr_fn_addr_eq)]

This is a tracking issue for std::ptr::fn_addr_eq

Compares the addresses of the two function pointers for equality.

Public API

// 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()
}

Steps / History

Unresolved Questions

  • None yet.

Footnotes

  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html

Activity

added
T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFC
on Aug 20, 2024
Urgau

Urgau commented on Oct 17, 2024

@Urgau
MemberAuthor

T-lang as started an FCP for adding a lint against function pointer comparisons and would like to use this method ptr::fn_addr_eq as recommendation to suppress the lint and hang documentation about caveats.

Stabilization Report

Implementation 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 std::marker::FnPtr bound

The FnPtr marker trait is not stable and would be not stabilized by this FCP, but this commits us to having such trait (even in this unstable form).


cc @rust-lang/lang (regarding the FnPtr bound)
cc @rust-lang/libs-api

dtolnay

dtolnay commented on Oct 17, 2024

@dtolnay
Member

@rfcbot fcp merge

rfcbot

rfcbot commented on Oct 17, 2024

@rfcbot
Collaborator

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.
See this document for info about what commands tagged team members can give me.

added
proposed-final-comment-periodProposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off.
disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.
on Oct 17, 2024
traviscross

traviscross commented on Oct 17, 2024

@traviscross
Contributor

@rfcbot reviewed

added
I-lang-nominatedNominated for discussion during a lang team meeting.
I-lang-easy-decisionIssue: The decision needed by the team is conjectured to be easy; this does not imply nomination
on Oct 17, 2024
added a commit that references this issue on Oct 25, 2024

Rollup merge of rust-lang#131457 - kpreid:fnaddr, r=dtolnay

fd78b67
added a commit that references this issue on Oct 25, 2024

21 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCI-lang-easy-decisionIssue: The decision needed by the team is conjectured to be easy; this does not imply nominationT-langRelevant to the language teamT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.

    Projects

    No projects

    Relationships

    None yet

      Development

      Participants

      @nikomatsakis@traviscross@dtolnay@Urgau@apiraino

      Issue actions

        Tracking Issue for `ptr::fn_addr_eq` · Issue #129322 · rust-lang/rust