-
Notifications
You must be signed in to change notification settings - Fork 587
Fix grammar rules containing or pertaining to bounds #2257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -3,9 +3,9 @@ r[type.trait-object] | |||||
|
|
||||||
| r[type.trait-object.syntax] | ||||||
| ```grammar,types | ||||||
| TraitObjectType -> `dyn`? Bounds | ||||||
| TraitObjectType -> Bounds | `dyn` Bounds? | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to my other comment, can we have a rule to say at least one trait is required? I'm not sure if it makes sense to combine that into type.trait-object.constraint or to have a separate rule just below that. |
||||||
|
|
||||||
| TraitObjectTypeOneBound -> `dyn`? TraitBound | ||||||
| TraitObjectTypeOneBound -> TraitBound | `dyn` TraitBound? | ||||||
| ``` | ||||||
|
|
||||||
| r[type.trait-object.intro] | ||||||
|
|
@@ -37,7 +37,9 @@ r[type.trait-object.syntax-edition2021] | |||||
|
|
||||||
| r[type.trait-object.syntax-edition2018] | ||||||
| > [!EDITION-2018] | ||||||
| > In the 2015 edition, if the first bound of the trait object is a path that starts with `::`, then the `dyn` will be treated as a part of the path. The first path can be put in parenthesis to get around this. As such, if you want a trait object with the trait `::your_module::Trait`, you should write it as `dyn (::your_module::Trait)`. | ||||||
| > In the 2015 edition, `dyn` must be followed by [PathIdentSegment][grammar-PathIdentSegment], [LIFETIME_OR_LABEL][grammar-LIFETIME_OR_LABEL], `for`, `(` or `?` to be interpreted as the start of a trait object type. Otherwise, it will be interpreted as a regular identifier. | ||||||
|
fmease marked this conversation as resolved.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The link destinations aren't required here, since definitions for the rule names are generated automatically.
Suggested change
|
||||||
| > | ||||||
| > Most notably, `dyn`, `dyn::T` and `dyn<T>` will all be treated as type paths. The first path can be put in parenthesis to get around this. As such, if you want a trait object with the trait `::module::Trait`, you should write it as `dyn (::module::Trait)`. | ||||||
| > | ||||||
| > Beginning in the 2018 edition, `dyn` is a true keyword and is not allowed in paths, so the parentheses are not necessary. | ||||||
|
|
||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a rule somewhere in this chapter that specifies at least one trait must be listed in the bounds? I believe this corresponds to the
AtLeastOneTraiterror.