Skip to content

Commit 076a798

Browse files
committed
Replace “min()” visibility notation with English.
1 parent ec0065f commit 076a798

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/attributes/type_system.md

+9-6
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,12 @@ Non-exhaustive types cannot be constructed outside of the defining crate:
7272

7373
- Non-exhaustive variants ([`struct`][struct] or [`enum` variant][enum]) cannot be constructed
7474
with a [_StructExpression_] \(including with [functional update syntax]).
75-
- The visibility of the same-named constant of a [unit-like struct][struct]
76-
is lowered to `min($vis, pub(crate))`.
77-
- The visibility of the same-named constructor function of a [tuple struct][struct]
78-
is lowered to `min($vis, pub(crate))`.
75+
- The implicitly defined same-named constant of a [unit-like struct][struct],
76+
or the same-named constructor function of a [tuple struct][struct],
77+
has a [visibility] no greater than `pub(crate)`.
78+
That is, if the struct’s visibility is `pub`, then the constant or constructor’s visibility
79+
is `pub(crate)`, and otherwise the visibility of the two items is the same
80+
(as is the case without `#[non_exhaustive]`).
7981
- [`enum`][enum] instances can be constructed.
8082

8183
The following examples of construction do not compile when outside the defining crate:
@@ -120,8 +122,8 @@ let message = Message::Quit;
120122
There are limitations when matching on non-exhaustive types outside of the defining crate:
121123

122124
- When pattern matching on a non-exhaustive variant ([`struct`][struct] or [`enum` variant][enum]),
123-
a [_StructPattern_] must be used which must include a `..`. Tuple variant constructor visibility
124-
is lowered to `min($vis, pub(crate))`.
125+
a [_StructPattern_] must be used which must include a `..`. A tuple variant's constructor's
126+
[visibility] is reduced to be no greater than `pub(crate)`.
125127
- When pattern matching on a non-exhaustive [`enum`][enum], matching on a variant does not
126128
contribute towards the exhaustiveness of the arms.
127129

@@ -181,3 +183,4 @@ Non-exhaustive types are always considered inhabited in downstream crates.
181183
[enum]: ../items/enumerations.md
182184
[functional update syntax]: ../expressions/struct-expr.md#functional-update-syntax
183185
[struct]: ../items/structs.md
186+
[visibility]: ../visibility-and-privacy.md

0 commit comments

Comments
 (0)