Skip to content

Commit c1cc9e7

Browse files
committed
Address material changes
1 parent 6a96392 commit c1cc9e7

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

text/3323-restrictions.md

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,7 @@ TupleField :
309309
Type
310310

311311
+MutRestriction :
312-
+ mut
313-
+ | mut ( crate )
312+
+ mut ( crate )
314313
+ | mut ( self )
315314
+ | mut ( super )
316315
+ | mut ( in SimplePath )
@@ -332,25 +331,24 @@ Trait :
332331
}
333332

334333
+ImplRestriction :
335-
+ impl
336-
+ | impl ( crate )
334+
+ impl ( crate )
337335
+ | impl ( self )
338336
+ | impl ( super )
339337
+ | impl ( in SimplePath )
340338
```
341339

342-
Essentially, `mut` and `impl` have the same syntax as `pub`, just with a different keyword.
340+
Essentially, `mut` and `impl` have the same syntax as `pub`, just with a different keyword. Using
341+
the keyword without providing a path is not allowed.
343342

344343
## Behavior
345344

346345
The current behavior of `pub` is that `pub` makes something visible within the declared scope. If no
347346
scope is declared (such that it is just `pub`), then the item is visible everywhere. This behavior
348347
is preserved for `impl` and `mut`. When a restriction is used, the behavior is allowed only within
349-
the declared scope. When the keyword is used alone, the behavior is allowed everywhere. While in
350-
most cases the default visibility is private, `pub` is default in some cases, namely `enum`
351-
variants, `enum` fields, and `trait` items. `impl` and `mut` will have a consistent default: when
352-
omitted entirely, the scope is inherited from `pub`. This is both what is most convenient and is
353-
what is required for backwards compatibility with existing code.
348+
the declared scope. While in most cases the default visibility is private, `pub` is default in some
349+
cases, namely `enum` variants, `enum` fields, and `trait` items. `impl` and `mut` will have a
350+
consistent default: when omitted entirely, the scope is inherited from `pub`. This is both what is
351+
most convenient and is what is required for backwards compatibility with existing code.
354352

355353
When an `ImplRestriction` is present, implementations of the associated trait are only permitted
356354
within the designated path. Any implementation of the trait outside this scope is a compile error.
@@ -401,11 +399,8 @@ Trait aliases cannot be implemented. As such, there is no concern about compatib
401399

402400
# Unresolved questions
403401

404-
- Should unrestricted "restrictions" be allowed to be explicitly stated, or should this be banned?
405-
If allowed, should it be a warning?
406-
- Both `impl` and `mut` make no sense to have unrestricted, as that is the default behavior. An
407-
"unnecessary" restriction lint that is warn-by-default would be ideal. This would allow macros
408-
to emit more flexible syntax. This warning could also be used for `pub(self)`.
402+
- Should an "unnecessary restriction" lint be introduced? It would fire when the restriction is as
403+
strict or less strict than the visibility. This warning could also be used for `pub(self)`.
409404
- How will restrictions work with `macro_rules!` matchers? There is currently a `vis` matcher, but
410405
it is likely unwise to add a new matcher for each restriction. Should the new syntax be included
411406
as part of the `vis` matcher? If so, it is important to note that restrictions are not the same
@@ -414,7 +409,8 @@ Trait aliases cannot be implemented. As such, there is no concern about compatib
414409
- What is the interaction between stability and restrictions?
415410
- Suggestion: Visibility is an inherent part of the item; restrictions should be as well. Metadata
416411
can be added in the future indicating when an item had its restriction lifted, if applicable.
417-
The design for this is left to the language team as necessary.
412+
The design for this is left to the language team as necessary. A decision does _not_ need to be
413+
made prior to stabilization, as stability attributes are not stable in their own right.
418414

419415
# Future possibilities
420416

@@ -430,3 +426,5 @@ Trait aliases cannot be implemented. As such, there is no concern about compatib
430426
mutable within the module rather than mutable everywhere. This seems unlikely, as it would be an
431427
incredibly disruptive change, and the benefits would have to be significant.
432428
- Syntax such as `impl(mod)` could be added for clarity as an alternative to `impl(self)`.
429+
- `impl` and `mut` could be usable without a path if deemed necessary. This behavior would be
430+
identical to omitting the keyword entirely.

0 commit comments

Comments
 (0)