rust-lang / rust-lang/rust

btree/node.rs: pub fn `dormant` should be marked as unsafe

Open
#136,255 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-cleanup T-libs
Dominant language
Rust
Stars
119k
Forks
16.2k
PR merge metrics
PR metrics pending

Description

This issue is about the "public" API of module alloc/src/collections/btree/node.rs. (The module itself is not public.)

I don't know how serious people are about pursuing strong static typing for this API, but depending on that, I think both dormant functions (on NodeRef and on Handle) should be marked as unsafe: the very existence of a dormant NodeRef/Handle is unsafe because it can be turned into a NodeRef<Immut<'a>, ...> using non-unsafe method reborrow and then inspected arbitrarily, which may cause races, aliasing rules violations, etc. with concurrent use of a NodeRef<Mut<'a>, ...> existing at the same time.

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

Read library/alloc/src/collections/btree/node.rs, focusing on the dormant functions for NodeRef and Handle and the reborrow method. Determine whether both dormant APIs require unsafe callers to preserve aliasing guarantees; done means the API safety treatment is resolved consistently and covered by the relevant validation for this module.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend-api-design
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.