rust-lang / rust-lang/reference

Confusing use of the term "undefined behavior" in the note of `type.str.value`

Open Beginner friendly
#2,266 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
1.6k
Forks
607
PR merge metrics
PR metrics pending

Description

The note of type.str.value uses the term "undefined behavior" for what is usually denoted as "library undefined behavior" (which is by the way not a concept in the reference):

https://github.com/rust-lang/reference/blob/cf0e3915cb84e9903ef1294fc64a50b70a1da82c/src/types/str.md?plain=1#L15-L19

I believe this is confusing. The term "undefined behavior" in the reference should only be used for what is usually denoted as "language undefined behavior" since the reference is about the language. It is explicitly said in the introduction (under "what the reference is not") that the standard library is not documented by the reference:

https://github.com/rust-lang/reference/blob/cf0e3915cb84e9903ef1294fc64a50b70a1da82c/src/introduction.md?plain=1#L24-L26

Unless there is already a plan to talk about library UB in the reference (which I guess would be restricted to notes), I believe it would be preferable to avoid the terminology "undefined behavior" for library UB, and use a more evasive terminology, like "calling a str method with a non-UTF-8 buffer violates assumptions and invariants of the standard library and could result in unexpected behaviors down the line".

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 note in src/types/str.md at the linked lines, then read the cited introduction section about what the Reference does not document. Revise the note so it does not use “undefined behavior” for standard-library behavior, while preserving the warning about non-UTF-8 buffers; done means the terminology clearly distinguishes language and library concerns.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.