rust-lang / rust-lang/rust

Change `NonNull::{as_ref, as_mut}` to take `self` rather than `&self` in a future edition

Open
#142,947 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

A-maybe-future-edition T-libs
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

NonNull has two methods that take &self even though the type is Copy:

The raw pointer methods take self so it is surprising NonNull is different. Taking a reference is unnecessary here and the returned lifetime is unrelated to it.

If we ever get a good way to give methods edition-dependent signatures, this may be something worth considering. Inspired by @cuviper's comment at https://rust-lang.zulipchat.com/#narrow/channel/136281-t-opsem/topic/Completing.20our.20set.20of.20pointer-conversion.20methods/near/423274344

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked NonNull::as_ref and NonNull::as_mut documentation, then compare their signatures with the raw pointer methods mentioned in the issue. Investigate whether edition-dependent method signatures are supported; done requires a concrete, accepted path for changing these APIs in a future edition.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.