define "uninhabited type"
Nobody has claimed this yet.
- Dominant language
- reStructuredText
- Stars
- 497
- Forks
- 41
- Avg merge
- 3h 52m
- Merged PRs (30d)
- 4
Description
The FLS does not define what an "uninhabited type" is, and it should. I propose we insert the following rules between 4.1:1 and 4.1:2:
An :t:inhabited type is a :t:type with :t:[constructor]s and :t:[value]s.
An :t:uninhabited type is a :t:type without :t:[constructor]s and :t:[value]s.
The FLS also does not define what a "constructor" is, and it should. I propose we insert a new 6.1.3 Constructor Expressions subsection, with the following singular legality rule:
A :t:constructor is an :t:array expression, a :t:struct expression, or a :t:tuple expression.
(I probably missed an expression here...)
Needless to say, all these rules will need corresponding entries in the Glossary.
Give the above, I propose the following changes:
:dp:fls_Fs12dmznjsMf
Matching against an :t:enum variant of an :t:enum with more than one :t:[enum variant]s :t:captures <capturing> the :t:place by :t:immutable borrow as the :t:discriminant is read.
:dp:fls_7EXHdE2eOVek
Matching against an :t:enum variant of an :t:enum with one :t:enum variant does not :t:capture <capturing> the :t:place as the :t:discriminant is not read, unless the :t:enum is subject to :t:attribute non_exhaustive, in which case the :t:place is captured by :t:immutable borrow.
I do not understand what the type.closure.capture.precision.discriminants.uninhabited-variants Reference rule is trying to say. Is it something along the lines of "if an enum type has at least one inhabited variant, and possibly multiple uninhabited variants, then the discriminant is still read, thus capturing takes place"?
This comment is still relevant.
Originally posted by @kirtchev-adacore in https://github.com/rust-lang/fls/pull/698#discussion_r3217333425
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 with FLS sections 4.1 and 6.1, the Glossary, and the type.closure.capture.precision.discriminants.uninhabited-variants Reference rule. Determine the intended definitions for inhabited and uninhabited types and constructors, resolve which expressions qualify as constructors, and clarify the proposed enum-capture wording. Done means the relevant rules and glossary entries are consistent and the ambiguous Reference rule is explained.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100