What is considered a "read"?
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Documentation
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- rust
- Domain
- documentation
Research direction
Start with the referenced functions in compiler/rustc_middle/src/hir/mod.rs and compiler/rustc_hir/src/hir.rs, then read Reference PRs 1837 and 2067 plus the linked Rust PRs. Compare the rules for divergence, closure capture, patterns, and discriminant reads; done means the Reference clearly documents the applicable definitions and distinctions.
Written by the indexing model from the issue text.
Description
https://github.com/rust-lang/reference/pull/2067 added a chapter on divergence with the rule expr.block.diverging that says:
A block is considered to be diverging if all reachable control flow paths contain a diverging expression, unless that expression is a place expression that is not read from.
But I don't think the reference has a clear definition of what it means to "read" from a place expression. What are the rules for what is considered a "read"? Is this unique to divergence checking?
Closure capture has has a bunch of rules of what it considers a "read" (or more often, what is not considered a read). I believe there are slight differences for various reasons. For example, a reference does not seem to be read for the purpose of divergence, but for the purpose of closure capture it does seem to be considered a read and is captured. There are various things around fake reads that I have forgotten how they work. I don't know if the rules are fundamentally different, or if there is some commonality.
I'll take a wild guess as to what is not considered a read based on expr_guaranteed_to_constitute_read_for_never:
- A borrow expression.
- The left-hand side of an assignment.
- The base of a field projection that doesn't itself constitute a read.
- The scrutinee of a match expression where at least one arm's pattern does not force a read.
- The initializer of a let statement where the pattern does not force a read.
- The scrutinee of a
letcondition where the pattern does not force a read.
(Of course non-place is always "read".)
I don't know if there are other considerations or how things like discriminants get involved.
It could also include details on which patterns force a read, which I think is is_guaranteed_to_constitute_read_for_never, which is more or less the following aren't reads:
_wildcard|or patterns where at least one alternative doesn't force a read
See also some recent things:
- https://github.com/rust-lang/reference/pull/1837 --- Changed what a closure capture considers a "read", particularly around discriminants.
- https://github.com/rust-lang/rust/pull/150681 --- Change for enum discriminant read.
cc @jackh726
- Dominant language
- Rust
- Stars
- 1.6k
- Forks
- 609
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 7
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing 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.
More from rust-lang/reference
-
A-const-eval A-undefined-behavior
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
rust-lang/reference#2266 · 1 comment ·
Maintainers usually reply within 1 day
-
A-resolve
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
A-coercions
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
rust-lang/reference#2094 · 1 comment ·
Maintainers usually reply within 1 day
All issues in rust-lang/reference
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
[Bug]: Bedrock request metadata forwarding does not work for /embeddingsPossibly taken A pull request linked to this issue is open or already merged. Openbug llm translation
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
pytest plugin: a crashed xdist worker aborts the whole session with INTERNALERRORPossibly taken @hazelxue claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
skillfs: one malformed chat-log line aborts the entire skill-usage analysis (skill_usage_from_chat_logs.py)Possibly taken @zjncs claimed this today. Opencomponent:skillfs
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
agentic-os-org/ANOLISA#6116 · 1 comment ·
Maintainers usually reply within 1 day