Emit a warning around thin `&CStr` interior mutability breaks
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
From @chorman0773 https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/CStr.20as.20thin.20pointer/near/405432566
Passing an &UnsafeCell<CStr> to size_of_val is currently sound because it just returns the length parameter of the fat pointer. After making CStr thin however, size_of_val will need to call strlen on the data. This is not ok in a &UnsafeCell because another context could be writing the data, e.g. temporarily overwriting the \0.
This seems like something we may be able to emit a warning for?
Thin cstr: https://github.com/rust-lang/rust/issues/59905
@rustbot label +T-libs +T-compiler +A-diagnostics
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the thin CStr discussion in issue #59905 and the linked Zulip conversation. Define whether and how a compiler warning could identify the UnsafeCell and size_of_val situation, then establish diagnostics coverage for the intended warning behavior.
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