Skip to content

Commit 9e4d726

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 b563d02 commit 9e4d726

15 files changed

+129
-151
lines changed

src/items.md

-25
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

+11-12
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.
@@ -214,7 +213,7 @@ let circle_shape = Circle::new();
214213
let bounding_box = circle_shape.bounding_box();
215214
```
216215

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

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

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

258257
r[items.associated.type.name]
259-
The identifier is the name of the declared type alias
258+
The identifier is the name of the declared type alias.
260259

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

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

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

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

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

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

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

446445
```rust

src/items/constant-items.md

+2-2
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
@@ -48,7 +48,7 @@ const BITS_N_STRINGS: BitsNStrings<'static> = BitsNStrings {
4848
};
4949
```
5050

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

5454
## Constants with Destructors

src/items/enumerations.md

+8-8
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

+1-1
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

+26-23
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

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

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

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

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

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

250253
#### Linking modifiers: `bundle`
251254

252-
r[items.extern.attributes.link.modifier-bundle]
255+
r[items.extern.attributes.link.modifiers.bundle]
253256

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

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

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

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

274-
r[items.extern.attributes.link.modifier-bundle.default]
277+
r[items.extern.attributes.link.modifiers.bundle.default]
275278
The default for this modifier is `+bundle`.
276279

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

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

282-
r[items.extern.attributes.link.modifier-whole-archive]
285+
r[items.extern.attributes.link.modifiers.whole-archive]
283286

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

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

292-
r[items.extern.attributes.link.modifier-whole-archive.default]
295+
r[items.extern.attributes.link.modifiers.whole-archive.default]
293296
The default for this modifier is `-whole-archive`.
294297

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

298301
### Linking modifiers: `verbatim`
299302

300-
r[items.extern.attributes.link.modifier-verbatim]
303+
r[items.extern.attributes.link.modifiers.verbatim]
301304

302-
r[items.extern.attributes.link.modifier-verbatim.constraint]
305+
r[items.extern.attributes.link.modifiers.verbatim.allowed-kinds]
303306
This modifier is compatible with all linking kinds.
304307

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

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

314-
r[items.extern.attributes.link.modifier-verbatim.default]
317+
r[items.extern.attributes.link.modifiers.verbatim.default]
315318
The default for this modifier is `-verbatim`.
316319

317320
More implementation details about this modifier can be found in
@@ -420,7 +423,7 @@ unsafe extern "stdcall" {
420423
}
421424
```
422425

423-
r[items.extern.attributes.link_ordinal.constraints]
426+
r[items.extern.attributes.link_ordinal.allowed-kinds]
424427
This attribute is only used with the `raw-dylib` linking kind.
425428
Using any other kind will result in a compiler error.
426429

0 commit comments

Comments
 (0)