Skip to content

Instantly share code, notes, and snippets.

@Gankra
Last active March 3, 2024 01:39
Show Gist options
  • Save Gankra/d6dda09cc02e9e60b7d8ef2bade4fc85 to your computer and use it in GitHub Desktop.
Save Gankra/d6dda09cc02e9e60b7d8ef2bade4fc85 to your computer and use it in GitHub Desktop.

i would like to get the ball rolling on stabilizing as many of the pointer APIs that were introduced in the last year

APIs:

Initial Discussion:

  • feature(ptr_sub_ptr)
  • feature(ptr_mask)
    • โœ… seems free to stabilize as-is, although its docs refer to a strict_provenance API
  • feature(pointer_is_aligned)
    • โœ… is_aligned uncontroversial/good
    • โš ๏ธ is_aligned_to more controversial because it has to handle non-power of twos
      • proposed deprecate as insufficient motivation
      • waffle proposes unspecified behaviour (i agree this is reasonable)
      • mara proposes is_aligned_for::<T>() as more egnomic for most practical cases (also agree)
      • scott proposes core::ptr::Alignment (see next ptr_alignment_type below)
  • feature(ptr_alignment_type)
    • โœ… people are apparently hungering for this, so we should just stabilize it
    • โš ๏ธ "blocked" on it being weird that nothing in std actually uses it
  • feature(strict_provenance)
    • โš ๏ธ addr, with_addr, and map_addr all seem very good and inoffensive in a vacuum, but i strongly believe they shouldn't be stabilized without their exposing partners to form a fully consistent system to follow for strict provenance
    • ๐Ÿ›‘ invalid and invalid_mut are in a more dubious place
      • does not appropriately address the needs of hardcoded memory addresses or "from FFI"
  • feature(exposed_addr)
    • โš ๏ธ expose_addr, from_exposed_addr, and from_exposed_addr_mut all form a consistent system but people are cagey about them
      • i personally think they can just be stabilized with caveats that the semantics are opt-in and you're not "fucking up" if you fail to uphold them
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment