Skip to content

Commit 17d6d0c

Browse files
committed
Rule annotation cleanup
A few things for cleanup: - Fix spelling and formatting - Remove rules in a list. The list is more of an index, the items aren't intended to be rules themselves. - Use some more consistent naming. - Use plurals where appropriate. - Avoid generic "constraint" terminology.
1 parent d613d07 commit 17d6d0c

15 files changed

+129
-151
lines changed

src/items.md

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -44,43 +44,18 @@ execution, and may reside in read-only memory.
4444
r[items.kinds]
4545
There are several kinds of items:
4646

47-
r[items.kind-modules]
4847
* [modules]
49-
50-
r[items.kind-extern-crate]
5148
* [`extern crate` declarations]
52-
53-
r[items.kind-use]
5449
* [`use` declarations]
55-
56-
r[items.kind-fn]
5750
* [function definitions]
58-
59-
r[items.kind-type]
6051
* [type definitions]
61-
62-
r[items.kind-struct]
6352
* [struct definitions]
64-
65-
r[items.kind-enum]
6653
* [enumeration definitions]
67-
68-
r[items.kind-union]
6954
* [union definitions]
70-
71-
r[items.kind-const]
7255
* [constant items]
73-
74-
r[items.kind-static]
7556
* [static items]
76-
77-
r[items.kind-trait]
7857
* [trait definitions]
79-
80-
r[items.kind-impl]
8158
* [implementations]
82-
83-
r[items.kind-extern]
8459
* [`extern` blocks]
8560

8661
r[items.locations]

src/items/associated-items.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ r[items.associated.syntax]
1313
r[items.associated.intro]
1414
*Associated Items* are the items declared in [traits] or defined in
1515
[implementations]. They are called this because they are defined on an associate
16-
type — the type in the implementation
16+
type — the type in the implementation.
1717

1818
r[items.associated.kinds]
1919
They are a subset of the kinds of items you can declare in a module.
@@ -52,7 +52,7 @@ function body is replaced with a `;`.
5252
r[items.associated.name]
5353
The identifier is the name of the function.
5454

55-
r[items.associated.constraint]
55+
r[items.associated.same-signature]
5656
The generics, parameter list, return type, and where clause of the associated function must be the same as the
5757
associated function declarations's.
5858

@@ -111,7 +111,7 @@ Associated functions whose first parameter is named `self` are called *methods*
111111
and may be invoked using the [method call operator], for example, `x.foo()`, as
112112
well as the usual function call notation.
113113

114-
r[items.associated.fn.method.constraint]
114+
r[items.associated.fn.method.self-ty]
115115
If the type of the `self` parameter is specified, it is limited to types resolving
116116
to one generated by the following grammar (where `'lt` denotes some arbitrary
117117
lifetime):
@@ -121,7 +121,6 @@ P = &'lt S | &'lt mut S | Box<S> | Rc<S> | Arc<S> | Pin<P>
121121
S = Self | P
122122
```
123123

124-
r[items.associated.fn.method.self-ty]
125124
The `Self` terminal in this grammar denotes a type resolving to the implementing type.
126125
This can also include the contextual type alias `Self`, other type aliases,
127126
or associated type projections resolving to the implementing type.
@@ -215,7 +214,7 @@ let bounding_box = circle_shape.bounding_box();
215214
```
216215

217216

218-
r[items.associated.fn.params-edition2015]
217+
r[items.associated.fn.params.edition2015]
219218
> **Edition Differences**: In the 2015 edition, it is possible to declare trait
220219
> methods with anonymous parameters (e.g. `fn foo(u8)`). This is deprecated and
221220
> an error as of the 2018 edition. All parameters must have an argument name.
@@ -234,7 +233,7 @@ r[items.associated.type]
234233
r[items.associated.type.intro]
235234
*Associated types* are [type aliases] associated with another type.
236235

237-
r[items.associated.type.constraint]
236+
r[items.associated.type.restrictions]
238237
Associated types cannot be defined in [inherent implementations] nor can they be given a
239238
default implementation in traits.
240239

@@ -257,9 +256,9 @@ type Assoc<Params>: Bounds where WhereBounds;
257256
```
258257

259258
r[items.associated.type.name]
260-
The identifier is the name of the declared type alias
259+
The identifier is the name of the declared type alias.
261260

262-
r[items.associated.type.constraint-impl]
261+
r[items.associated.type.impl-fulfillment]
263262
The optional trait bounds must be fulfilled by the implementations of the type alias.
264263

265264
r[items.associated.type.sized]
@@ -269,7 +268,7 @@ r[items.associated.type.def]
269268
An *associated type definition* defines a type alias for the implementation
270269
of a trait on a type
271270

272-
r[items.associated.type.restriction-def]
271+
r[items.associated.type.def.restriction]
273272
They are written similarly to an *associated type declaration*, but cannot contain `Bounds`, but instead must contain a `Type`:
274273

275274
<!-- ignore: illustrative example forms -->
@@ -406,7 +405,7 @@ where clauses, dependent on functions in the trait and how the GAT is used. Thes
406405
rules may be loosened in the future; updates can be found [on the generic
407406
associated types initiative repository](https://rust-lang.github.io/generic-associated-types-initiative/explainer/required_bounds.html).
408407

409-
r[items.associated.type.generic-where-clause.constraint-valid-fn]
408+
r[items.associated.type.generic-where-clause.valid-fn]
410409
In a few words, these where clauses are required in order to maximize the allowed
411410
definitions of the associated type in impls. To do this, any clauses that *can be
412411
proven to hold* on functions (using the parameters of the function or trait)
@@ -423,7 +422,7 @@ In the above, on the `next` function, we can prove that `Self: 'a`, because of
423422
the implied bounds from `&'a mut self`; therefore, we must write the equivalent
424423
bound on the GAT itself: `where Self: 'x`.
425424

426-
r[items.associated.type.generic-where-clause.constraint-intersection]
425+
r[items.associated.type.generic-where-clause.intersection]
427426
When there are multiple functions in a trait that use the GAT, then the
428427
*intersection* of the bounds from the different functions are used, rather than
429428
the union.
@@ -441,7 +440,7 @@ know that `T: 'a` on `create_checker`, we do not know that on `do_check`. Howeve
441440
if `do_check` was commented out, then the `where T: 'x` bound would be required
442441
on `Checker`.
443442

444-
r[items.associated.type.generic-where-clause.constraint-forward]
443+
r[items.associated.type.generic-where-clause.forward]
445444
The bounds on associated types also propagate required where clauses.
446445

447446
```rust

src/items/constant-items.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ r[items.const.intro]
1111
A *constant item* is an optionally named _[constant value]_ which is not associated
1212
with a specific memory location in the program.
1313

14-
r[items.const.behaviour]
14+
r[items.const.behavior]
1515
Constants are essentially inlined wherever they are used, meaning that they are copied directly into the relevant
1616
context when used. This includes usage of constants from external crates, and
1717
non-[`Copy`] types. References to the same constant are not necessarily
@@ -49,7 +49,7 @@ const BITS_N_STRINGS: BitsNStrings<'static> = BitsNStrings {
4949
};
5050
```
5151

52-
r[items.const.restriction]
52+
r[items.const.expr-omission]
5353
The constant expression may only be omitted in a [trait definition].
5454

5555
## Constants with Destructors

src/items/enumerations.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
r[items.enum]
44

5-
r[items.enum.sybtax]
5+
r[items.enum.syntax]
66
> **<sup>Syntax</sup>**\
77
> _Enumeration_ :\
88
> &nbsp;&nbsp; `enum`
@@ -128,7 +128,7 @@ let z = StructLike { value: 123 }; // Struct expression.
128128

129129
r[items.enum.discriminant]
130130

131-
r[items.enum.discrimnant.intro]
131+
r[items.enum.discriminant.intro]
132132
Each enum instance has a _discriminant_: an integer logically associated to it
133133
that is used to determine which variant it holds.
134134

@@ -150,7 +150,7 @@ following the variant name with `=` and a [constant expression]:
150150
r[items.enum.discriminant.explicit.unit-only]
151151
1. if the enumeration is "[unit-only]".
152152

153-
r[items.enum.discriminan.explicit.primitive-repr]
153+
r[items.enum.discriminant.explicit.primitive-repr]
154154
2. if a [primitive representation] is used. For example:
155155

156156
```rust
@@ -187,9 +187,9 @@ assert_eq!(baz_discriminant, 123);
187187

188188
#### Restrictions
189189

190-
r[items.enum.discriminant.constraints]
190+
r[items.enum.discriminant.restrictions]
191191

192-
r[items.enum.discrimnant.constraints.same-discriminant]
192+
r[items.enum.discriminant.restrictions.same-discriminant]
193193
It is an error when two variants share the same discriminant.
194194

195195
```rust,compile_fail
@@ -205,7 +205,7 @@ enum SharedDiscriminantError2 {
205205
}
206206
```
207207

208-
r[items.enum.discrimnant.constraints.above-max-discriminant]
208+
r[items.enum.discriminant.restrictions.above-max-discriminant]
209209
It is also an error to have an unspecified discriminant where the previous
210210
discriminant is the maximum value for the size of the discriminant.
211211

@@ -254,7 +254,7 @@ assert_eq!(1, Enum::Bar as isize);
254254
assert_eq!(2, Enum::Baz as isize);
255255
```
256256

257-
r[items.enum.discriminant.coercion.constraint]
257+
r[items.enum.discriminant.coercion.fieldless]
258258
[Field-less enums] can be casted if they do not have explicit discriminants, or where only unit variants are explicit.
259259

260260
```rust
@@ -338,7 +338,7 @@ let y: u32 = x; // mismatched type error
338338

339339
## Variant visibility
340340

341-
r[items.enum.constraint-variant-visibility]
341+
r[items.enum.variant-visibility]
342342

343343
Enum variants syntactically allow a [_Visibility_] annotation, but this is
344344
rejected when the enum is validated. This allows items to be parsed with a

src/items/extern-crates.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Additionally, if the `extern crate` appears in the crate root, then the crate na
2525
r[items.extern-crate.as]
2626
The `as` clause can be used to bind the imported crate to a different name.
2727

28-
r[items.exter-crate.lookup]
28+
r[items.extern-crate.lookup]
2929
The external crate is resolved to a specific `soname` at compile time, and a
3030
runtime linkage requirement to that `soname` is passed to the linker for
3131
loading at runtime. The `soname` is resolved at compile time by scanning the

src/items/external-blocks.md

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ External blocks provide _declarations_ of items that are not _defined_ in the
2121
current crate and are the basis of Rust's foreign function interface. These are
2222
akin to unchecked imports.
2323

24-
r[items.extern.restriction]
24+
r[items.extern.allowed-kinds]
2525
Two kinds of item _declarations_ are allowed in external blocks: [functions] and
2626
[statics].
2727

@@ -38,10 +38,13 @@ r[items.extern.fn]
3838
r[items.extern.fn.body]
3939
Functions within external blocks are declared in the same way as other Rust
4040
functions, with the exception that they must not have a body and are instead
41-
terminated by a semicolon
41+
terminated by a semicolon.
4242

43-
r[items.extern.fn.restriction]
44-
Patterns are not allowed in parameters, only [IDENTIFIER] or `_` may be used. The `safe` and `unsafe` function qualifiers are
43+
r[items.extern.fn.param-patterns]
44+
Patterns are not allowed in parameters, only [IDENTIFIER] or `_` may be used.
45+
46+
r[items.extern.fn.qualifiers]
47+
The `safe` and `unsafe` function qualifiers are
4548
allowed, but other function qualifiers (e.g. `const`, `async`, `extern`) are
4649
not.
4750

@@ -199,19 +202,19 @@ r[items.extern.attributes.link.raw-dylib]
199202
an import library to link against (see [`dylib` versus `raw-dylib`] below
200203
for details). This is only valid for Windows targets.
201204

202-
r[items.extern.attributes.link.constraint]
205+
r[items.extern.attributes.link.name-requirement]
203206
The `name` key must be included if `kind` is specified.
204207

205208
r[items.extern.attributes.link.modifiers]
206209
The optional `modifiers` argument is a way to specify linking modifiers for the
207210
library to link.
208211

209-
r[items.extern.attributes.link.modifiers-syntax]
212+
r[items.extern.attributes.link.modifiers.syntax]
210213
Modifiers are specified as a comma-delimited string with each modifier prefixed
211214
with either a `+` or `-` to indicate that the modifier is enabled or disabled,
212215
respectively.
213216

214-
r[items.extern.attributes.link.modifiers-constraint]
217+
r[items.extern.attributes.link.modifiers.multiple]
215218
Specifying multiple `modifiers` arguments in a single `link` attribute,
216219
or multiple identical modifiers in the same `modifiers` argument is not currently supported. \
217220
Example: `#[link(name = "mylib", kind = "static", modifiers = "+whole-archive")]`.
@@ -248,69 +251,69 @@ block.
248251

249252
#### Linking modifiers: `bundle`
250253

251-
r[items.extern.attributes.link.modifier-bundle]
254+
r[items.extern.attributes.link.modifiers.bundle]
252255

253-
r[items.extern.attributes.link.modifier-bundle.constraint]
256+
r[items.extern.attributes.link.modifiers.bundle.allowed-kinds]
254257
This modifier is only compatible with the `static` linking kind.
255258
Using any other kind will result in a compiler error.
256259

257-
r[items.extern.attributes.link.modifier-bundle.behaviour]
260+
r[items.extern.attributes.link.modifiers.bundle.behavior]
258261
When building a rlib or staticlib `+bundle` means that the native static library
259262
will be packed into the rlib or staticlib archive, and then retrieved from there
260263
during linking of the final binary.
261264

262-
r[items.extern.attributes.link.modifier-bundle.behaviour-negative]
265+
r[items.extern.attributes.link.modifiers.bundle.behavior-negative]
263266
When building a rlib `-bundle` means that the native static library is registered as a dependency
264267
of that rlib "by name", and object files from it are included only during linking of the final
265268
binary, the file search by that name is also performed during final linking. \
266269
When building a staticlib `-bundle` means that the native static library is simply not included
267270
into the archive and some higher level build system will need to add it later during linking of
268271
the final binary.
269272

270-
r[items.extern.attributes.link.modifier-bundle.no-effect]
273+
r[items.extern.attributes.link.modifiers.bundle.no-effect]
271274
This modifier has no effect when building other targets like executables or dynamic libraries.
272275

273-
r[items.extern.attributes.link.modifier-bundle.default]
276+
r[items.extern.attributes.link.modifiers.bundle.default]
274277
The default for this modifier is `+bundle`.
275278

276279
More implementation details about this modifier can be found in
277280
[`bundle` documentation for rustc].
278281

279282
#### Linking modifiers: `whole-archive`
280283

281-
r[items.extern.attributes.link.modifier-whole-archive]
284+
r[items.extern.attributes.link.modifiers.whole-archive]
282285

283-
r[items.extern.attributes.link.modifier-whole-archive.constraint]
286+
r[items.extern.attributes.link.modifiers.whole-archive.allowed-kinds]
284287
This modifier is only compatible with the `static` linking kind.
285288
Using any other kind will result in a compiler error.
286289

287-
r[items.extern.attributes.link.modifier-whole-archive.behaviour]
290+
r[items.extern.attributes.link.modifiers.whole-archive.behavior]
288291
`+whole-archive` means that the static library is linked as a whole archive
289292
without throwing any object files away.
290293

291-
r[items.extern.attributes.link.modifier-whole-archive.default]
294+
r[items.extern.attributes.link.modifiers.whole-archive.default]
292295
The default for this modifier is `-whole-archive`.
293296

294297
More implementation details about this modifier can be found in
295298
[`whole-archive` documentation for rustc].
296299

297300
### Linking modifiers: `verbatim`
298301

299-
r[items.extern.attributes.link.modifier-verbatim]
302+
r[items.extern.attributes.link.modifiers.verbatim]
300303

301-
r[items.extern.attributes.link.modifier-verbatim.constraint]
304+
r[items.extern.attributes.link.modifiers.verbatim.allowed-kinds]
302305
This modifier is compatible with all linking kinds.
303306

304-
r[items.extern.attributes.link.modifier-verbatim.behaviour]
307+
r[items.extern.attributes.link.modifiers.verbatim.behavior]
305308
`+verbatim` means that rustc itself won't add any target-specified library prefixes or suffixes
306309
(like `lib` or `.a`) to the library name, and will try its best to ask for the same thing from the
307310
linker.
308311

309-
r[items.extern.attributes.link.modifier-verbatim.behaviour-negative]
312+
r[items.extern.attributes.link.modifiers.verbatim.behavior-negative]
310313
`-verbatim` means that rustc will either add a target-specific prefix and suffix to the library
311314
name before passing it to linker, or won't prevent linker from implicitly adding it.
312315

313-
r[items.extern.attributes.link.modifier-verbatim.default]
316+
r[items.extern.attributes.link.modifiers.verbatim.default]
314317
The default for this modifier is `-verbatim`.
315318

316319
More implementation details about this modifier can be found in
@@ -425,7 +428,7 @@ unsafe extern "stdcall" {
425428
}
426429
```
427430

428-
r[items.extern.attributes.link_ordinal.constraints]
431+
r[items.extern.attributes.link_ordinal.allowed-kinds]
429432
This attribute is only used with the `raw-dylib` linking kind.
430433
Using any other kind will result in a compiler error.
431434

0 commit comments

Comments
 (0)