Docs say `const` items are always `'static`, but they aren't.
Open
Beginner friendly
Nobody has claimed this yet.
A-docs
needs-triage
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Location (URL)
https://doc.rust-lang.org/std/keyword.const.html
Summary
The documentation says:
The only lifetime allowed in a constant is
'static, which is the lifetime that encompasses all others in a Rust program.
However, the following program has a non-'static const (associated) item, contradicting the docs. It compiles without errors.
struct Thing<'a>(&'a i32);
impl<'a> Thing<'a> {
const DATA: &'a i64 = &1;
}
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
Open the const keyword documentation at the reported URL and locate the statement about lifetimes in constants. Check it against the associated-const example in the issue, then revise the wording so the documentation matches the demonstrated behavior and verify the example still compiles.
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
- Mostly clear
- Newbie friendliness
- 72/100