`expect` messages should follow our guidance
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
It's very likely that this turns into a LLM honeypot issue, but...
#96033 added official guidance on messages for .expect four years ago. Many .expect messages we write were either before the guidance existed or did not know of this guidance.
I like the reasoning on the guidance, and I think we should be consistent. So here's a list of files containing user-facing doc .expect messages that can be fixed (E-easy):
-
library/alloc/src/boxed.rs (#159882)
-
library/alloc/src/string.rs (#159882)
-
library/alloc/src/collections/binary_heap/mod.rs (I'm just not liking the "why is the test harness" message) (@SzilvasiPeter)
-
library/alloc/src/collections/vec_deque/mod.rs
-
library/alloc/src/ffi/c_str.rs (@asder8215)
-
library/alloc/src/vec/mod.rs (#159862)
-
library/core/src/primitive_docs.rs (@pluiee)
-
library/core/src/result.rs (@pluiee)
-
library/core/src/fmt/mod.rs
-
library/core/src/ptr/non_null.rs
-
Not listed: std, etc.
Please do not claim this issue, comment below and claim a subdirectory to work on would make it possible for multiple people to work on :D
What is more interesting is that there are many pre-existing .expect messages in our library code that use the expect message wrongly, e.g. Poll::Ready(self.0.take().expect("Ready polled after completion")) in impl<T> Future for Ready<T>, it would be nice if our messages change to be better (to say something like "Ready should not be polled after completion" instead), but that is more user facing and takes more time to decide IMO:
- TODO: list out user-facing
expectmessages
To be clear, this issue is meant for new contributes that want to learn how to work on the codebase manually. Do not work on this issue with LLMs.
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
Read the guidance from #96033, then choose an unchecked file or subdirectory from the list, such as library/core/src/result.rs or library/alloc/src/vec/mod.rs. Inspect its user-facing .expect messages and update the wording to follow that guidance. Done means the selected messages are consistent with the stated rules and the relevant library checks pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- documentation
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 70/100