-
Notifications
You must be signed in to change notification settings - Fork 533
Explain how to name rule identifiers #1609
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
Changes from 1 commit
c17f60c
06c1d98
8912726
d628425
d032fa8
d78728d
3c7523f
0ab2181
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 |
---|---|---|
|
@@ -75,6 +75,36 @@ Rules can be linked to by their ID using markdown such as `[foo.bar]`. There are | |
|
||
In the HTML, the rules are clickable just like headers. | ||
|
||
When assigning rules to new paragraphs, or when modifying rule names, use the following guidelines: | ||
1. A rule applies to one core idea, which should be easily determined when reading the paragraph it is applied to, | ||
2. Other than the "intro" paragraph, purely explanatory, expository, or exemplary content does not need a rule. If the expository paragraph isn't directly related to the previous, separate it with a hard (rendered) line break | ||
3. Rust Code examples and tests do not need their own rules | ||
4. Notes do not need rules. For other admonition types, use the following guidelines: | ||
* Warning: Omit the rule if and only if the warning follows from the previous paragraph. | ||
* Target Specific Behaviour: Always include the rule | ||
chorman0773 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* Edition Differences: Always include the rule | ||
chorman0773 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* Version History: Omit the rule if the present behaviour is explained in the immediately preceeding rule. | ||
chorman0773 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
4. The following keywords should be used to identify paragraphs when unambiguous: | ||
* `intro`: The beginning paragraph of each section - should explain the construct being defined overall. | ||
* `syntax`: Syntax definitions or explanations when BNF syntax definitions are not used | ||
* `restriction`: Syntactic (parsing) requirements on the construct | ||
* `constraint`: Semantic (type checking) requirements on the construct | ||
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. @ehuss and I talked about this part. We're a but uncertain about the strategy here. It feels like there are going to be a ton of We're also probably unconvinced on this means of separating syntactic and type checking requirements. I.e., it doesn't immediately speak to us that "restriction" would refer to parsing and "constraint" would refer to type checking and that these should be separated in this manner. This probably also applies to some of the others, such as "preconditions". 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. I haven't seen ambiguous keyword rules too often in my work, though that might change once I start my second pass. As for the specific terms, I'd like to discuss that tomorrow at the T-spec meeting. |
||
* `safety` (instead of restriction): Stating that an operation is `unsafe` or the conditions under which it is `unsafe` | ||
* `behavior`: Runtime effects of evaluating the construct in a well-defined manner | ||
* `panics`: Conditions under which evaluating the construct causes a runtime panic | ||
* `preconditions`: Conditions which must be satisfied for the evaluation of the construct to be well-defined | ||
* `namespace`: For items only, specifies the namespace(s) the item introduces a name in. May also be used elsewhere when defining a namespace (e.g. `r[attribute.diagnostic.namespace]`) | ||
5. When a rule doesn't fall under the above keywords. or for section rule ids, name the subrule as follows: | ||
* If the rule is naming a specific Rust language construct (IE. an attribute, standard library type/function, or keyword-introduced concept), use the construct as named in the language, appropriately case-adjusted (but do not replace `_`s with `-`s) | ||
chorman0773 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* Other than rust language concepts with `_`s in the name, use `-` characters to separate words within a "subrule" | ||
* Whenever possible, do not repeat previous components of the rule | ||
* Prefer using singular forms of words over plural unless the rule applies to a list or the construct is named as plural in the language (e.g. `r[attribute.diagnostic.lint.group]) | ||
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. I'm not sure this is true everywhere. Plural often makes sense. I'd expect chapter titles like "Items" (rather than "Item") or "Lints" (rather than "Lint"), and I'd expect the rule names to follow suit here. Often, what's going to come up, as it did with the diagnostic namespace, is not the difference between plural and singular, but the difference between nouns and adjectives. As a noun, it makes sense for the chapter title (and rules that follow that) to be "Diagnostics", but when used with "diagnostic namespace", it's an adjective, and so it doesn't have the "s". 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.
|
||
* Whenever possible, don't use a name that conflicts with one of the above keywords, even if this violates the first bullet. | ||
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. Can we think of any examples of where this would come up? 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.
|
||
* Use an appropriately discriptive, but short, name if the language does not provide one. | ||
6. When a keyword applies, but multiple different rules in the same section would use the same keyword, prefix or suffix the rule with a descriptive id given above, separated with a `-` | ||
* When the paragraph modifies a specific named construct or applies to a specific named construct only, prefix the rule with the name of the construct (e.g. `r[items.fn.params.self-constraint]`). | ||
* When the paragraph refers to a specific named construct that applies the particular keyword behaviour, suffix the rule with the name of the construct | ||
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. In discussion we were a bit unclear about the distinction being drawn here. Perhaps more examples would help. 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. I actually did this a couple times working on #1618. As another example, |
||
|
||
### Standard library links | ||
|
||
You should link to the standard library without specifying a URL in a fashion similar to [rustdoc intra-doc links][intra]. Some examples: | ||
|
Uh oh!
There was an error while loading. Please reload this page.