Skip to content

Commit b63782c

Browse files
authored
Merge pull request rust-lang#426 from ehuss/grammar-items
Grammar: Add definition of "Item".
2 parents 81088ea + 56916af commit b63782c

File tree

1 file changed

+64
-16
lines changed

1 file changed

+64
-16
lines changed

src/items.md

+64-16
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,49 @@
11
# Items
22

3+
> **<sup>Syntax:<sup>**\
4+
> _Item_:\
5+
> &nbsp;&nbsp; [_OuterAttribute_]<sup>\*</sup> [_Visibility_]<sup>?</sup>\
6+
> &nbsp;&nbsp; (\
7+
> &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; [_Module_]\
8+
> &nbsp;&nbsp; &nbsp;&nbsp; | [_ExternCrate_]\
9+
> &nbsp;&nbsp; &nbsp;&nbsp; | [_UseDeclaration_]\
10+
> &nbsp;&nbsp; &nbsp;&nbsp; | [_Function_]\
11+
> &nbsp;&nbsp; &nbsp;&nbsp; | [_TypeAlias_]\
12+
> &nbsp;&nbsp; &nbsp;&nbsp; | [_Struct_]\
13+
> &nbsp;&nbsp; &nbsp;&nbsp; | [_Enumeration_]\
14+
> &nbsp;&nbsp; &nbsp;&nbsp; | [_Union_]\
15+
> &nbsp;&nbsp; &nbsp;&nbsp; | [_ConstantItem_]\
16+
> &nbsp;&nbsp; &nbsp;&nbsp; | [_StaticItem_]\
17+
> &nbsp;&nbsp; &nbsp;&nbsp; | [_Trait_]\
18+
> &nbsp;&nbsp; &nbsp;&nbsp; | [_Implementation_]\
19+
> &nbsp;&nbsp; &nbsp;&nbsp; | [_ExternBlock_]\
20+
> &nbsp;&nbsp; &nbsp;&nbsp; | _Macro_\
21+
> &nbsp;&nbsp; &nbsp;&nbsp; | _MacroDefinition_\
22+
> &nbsp;&nbsp; )
23+
324
An _item_ is a component of a crate. Items are organized within a crate by a
425
nested set of [modules]. Every crate has a single "outermost" anonymous module;
526
all further items within the crate have [paths] within the module tree of the
627
crate.
728

8-
[modules]: items/modules.html
9-
[paths]: paths.html
10-
1129
Items are entirely determined at compile-time, generally remain fixed during
1230
execution, and may reside in read-only memory.
1331

1432
There are several kinds of items:
1533

16-
* [modules](items/modules.html)
17-
* [`extern crate` declarations](items/extern-crates.html)
18-
* [`use` declarations](items/use-declarations.html)
19-
* [function definitions](items/functions.html)
20-
* [type definitions](items/type-aliases.html)
21-
* [struct definitions](items/structs.html)
22-
* [enumeration definitions](items/enumerations.html)
23-
* [union definitions](items/unions.html)
24-
* [constant items](items/constant-items.html)
25-
* [static items](items/static-items.html)
26-
* [trait definitions](items/traits.html)
27-
* [implementations](items/implementations.html)
28-
* [`extern` blocks](items/external-blocks.html)
34+
* [modules]
35+
* [`extern crate` declarations]
36+
* [`use` declarations]
37+
* [function definitions]
38+
* [type definitions]
39+
* [struct definitions]
40+
* [enumeration definitions]
41+
* [union definitions]
42+
* [constant items]
43+
* [static items]
44+
* [trait definitions]
45+
* [implementations]
46+
* [`extern` blocks]
2947

3048
Some items form an implicit scope for the declaration of sub-items. In other
3149
words, within a function or module, declarations of items can (in many cases)
@@ -36,3 +54,33 @@ as if the item was declared outside the scope &mdash; it is still a static item
3654
qualified by the name of the enclosing item, or is private to the enclosing
3755
item (in the case of functions). The grammar specifies the exact locations in
3856
which sub-item declarations may appear.
57+
58+
[_ConstantItem_]: items/constant-items.html
59+
[_Enumeration_]: items/enumerations.html
60+
[_ExternBlock_]: items/external-blocks.html
61+
[_ExternCrate_]: items/extern-crates.html
62+
[_Function_]: items/functions.html
63+
[_Implementation_]: items/implementations.html
64+
[_Module_]: items/modules.html
65+
[_OuterAttribute_]: attributes.html
66+
[_StaticItem_]: items/static-items.html
67+
[_Struct_]: items/structs.html
68+
[_Trait_]: items/traits.html
69+
[_TypeAlias_]: items/type-aliases.html
70+
[_Union_]: items/unions.html
71+
[_UseDeclaration_]: items/use-declarations.html
72+
[_Visibility_]: visibility-and-privacy.html
73+
[`extern crate` declarations]: items/extern-crates.html
74+
[`extern` blocks]: items/external-blocks.html
75+
[`use` declarations]: items/use-declarations.html
76+
[constant items]: items/constant-items.html
77+
[enumeration definitions]: items/enumerations.html
78+
[function definitions]: items/functions.html
79+
[implementations]: items/implementations.html
80+
[modules]: items/modules.html
81+
[paths]: paths.html
82+
[static items]: items/static-items.html
83+
[struct definitions]: items/structs.html
84+
[trait definitions]: items/traits.html
85+
[type definitions]: items/type-aliases.html
86+
[union definitions]: items/unions.html

0 commit comments

Comments
 (0)