You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a tracking issue for the RFC "Restrictions" (rust-lang/rfcs#3323).
The feature gates for the issue are:
#![feature(impl_restriction)]
#![feature(mut_restriction)]
About tracking issues
Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Should an "unnecessary restriction" lint be introduced? It would fire when the restriction is as
strict or less strict than the visibility. This warning could also be used for pub(self).
Does this necessarily have to be decided as part of this RFC?
How will restrictions work with macro_rules! matchers? There is currently a vis matcher, but
it is likely unwise to add a new matcher for each restriction.
The proposed syntax cannot be added to the vis matcher, as it does not current restrict the
tokens that can follow. For this reason, it could break existing code, such as the following
example.
A restriction matcher could work, but restrictions are not the same everywhere.
mut_restriction and impl_restriction are relatively long.
This is a non-issue if the syntax ends up being attribute-based (or sugar for attributes).
What is the interaction between stability and restrictions?
Suggestion: Visibility is an inherent part of the item; restrictions should be as well. Metadata
can be added in the future indicating when an item had its restriction lifted, if applicable.
The design for this is left to the language team as necessary. A decision does not need to be
made prior to stabilization, as stability attributes are not stable in their own right.
Should the in syntax be permitted for restrictions? Including it is consistent with the existing
syntax for visibility. Further, the lack of inclusion would lead to continued use of the
workaround for impl. For mut, there is no workaround. The syntax is not used often for
visibility, but it is very useful when it is used.
Should struct expressions be disallowed?
Where would it be desirable to prohibit mutability after construction, but still permit
construction with unchecked values?
View all comments
This is a tracking issue for the RFC "Restrictions" (rust-lang/rfcs#3323).
The feature gates for the issue are:
#![feature(impl_restriction)]#![feature(mut_restriction)]About tracking issues
Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Steps
implrestrictionsimplrestrictions #152943implrestriction lowering #153556implrestrictions #154661mutrestrictionsimplandmutrestrictions rust-analyzer#22022Unresolved Questions
unsafefields?Decided in Decide on keyword order for
impl,mutrestrictions #155222; group with visibility. Remaining question of overall syntax remains.sealedorreadonly. Adifferent syntax altogether could be used as well.
strict or less strict than the visibility. This warning could also be used for
pub(self).macro_rules!matchers? There is currently avismatcher, butit is likely unwise to add a new matcher for each restriction.
vismatcher, as it does not current restrict thetokens that can follow. For this reason, it could break existing code, such as the following
example.
restrictionmatcher could work, but restrictions are not the same everywhere.mut_restrictionandimpl_restrictionare relatively long.can be added in the future indicating when an item had its restriction lifted, if applicable.
The design for this is left to the language team as necessary. A decision does not need to be
made prior to stabilization, as stability attributes are not stable in their own right.
insyntax be permitted for restrictions? Including it is consistent with the existingsyntax for visibility. Further, the lack of inclusion would lead to continued use of the
workaround for
impl. Formut, there is no workaround. The syntax is not used often forvisibility, but it is very useful when it is used.
structexpressions be disallowed?construction with unchecked values?
Implementation history
implrestrictions to AST, lower torustc_middle#141754 — closed in favor of GSoCimplrestrictions #152943implrestriction lowering #153556implrestrictions #154661