1
1
# Names
2
2
3
- r[ name ]
3
+ r[ names ]
4
4
5
- r[ name .intro]
5
+ r[ names .intro]
6
6
An * entity* is a language construct that can be referred to in some way within
7
7
the source program, usually via a [ path] . Entities include [ types] , [ items] ,
8
8
[ generic parameters] , [ variable bindings] , [ loop labels] , [ lifetimes] ,
9
9
[ fields] , [ attributes] , and [ lints] .
10
10
11
- r[ name .decl]
11
+ r[ names .decl]
12
12
A * declaration* is a syntactical construct that can introduce a * name* to
13
13
refer to an entity. Entity names are valid within a [ * scope* ] --- a region of
14
14
source text where that name may be referenced.
15
15
16
- r[ name .explicit-decl]
16
+ r[ names .explicit-decl]
17
17
Some entities are [ explicitly declared] ( #explicitly-declared-entities ) in the
18
18
source code, and some are [ implicitly declared] ( #implicitly-declared-entities )
19
19
as part of the language or compiler extensions.
20
20
21
- r[ name .path]
21
+ r[ names .path]
22
22
[ * Paths* ] are used to refer to an entity, possibly in another module or type.
23
23
24
- r[ name .lifetime]
24
+ r[ names .lifetime]
25
25
Lifetimes and loop labels use a [ dedicated syntax] [ lifetimes-and-loop-labels ] using a
26
26
leading quote.
27
27
28
- r[ name .namespace]
28
+ r[ names .namespace]
29
29
Names are segregated into different [ * namespaces* ] , allowing entities in
30
30
different namespaces to share the same name without conflict.
31
31
32
- r[ name .resolution]
32
+ r[ names .resolution]
33
33
[ * Name resolution* ] is the compile-time process of tying paths, identifiers,
34
34
and labels to entity declarations.
35
35
36
- r[ name .visibility]
36
+ r[ names .visibility]
37
37
Access to certain names may be restricted based on their [ * visibility* ] .
38
38
39
39
## Explicitly declared entities
40
40
41
- r[ name .explicit]
41
+ r[ names .explicit]
42
42
43
- r[ name .explicit.list]
43
+ r[ names .explicit.list]
44
44
Entities that explicitly introduce a name in the source code are:
45
45
46
- r[ name .explicit.item-decl]
46
+ r[ names .explicit.item-decl]
47
47
* [ Items] :
48
48
* [ Module declarations]
49
49
* [ External crate declarations]
@@ -59,7 +59,7 @@ r[name.explicit.item-decl]
59
59
* [ ` macro_rules ` declarations] and [ matcher metavariables]
60
60
* [ Implementation] associated items
61
61
62
- r[ name .explicit.expr]
62
+ r[ names .explicit.expr]
63
63
* [ Expressions] :
64
64
* [ Closure] parameters
65
65
* [ ` while let ` ] pattern bindings
@@ -68,66 +68,66 @@ r[name.explicit.expr]
68
68
* [ ` match ` ] pattern bindings
69
69
* [ Loop labels]
70
70
71
- r[ name .explicit.generics]
71
+ r[ names .explicit.generics]
72
72
* [ Generic parameters]
73
73
74
- r[ name .explicit.higher-ranked-bounds]
74
+ r[ names .explicit.higher-ranked-bounds]
75
75
* [ Higher ranked trait bounds]
76
76
77
- r[ name .explicit.binding]
77
+ r[ names .explicit.binding]
78
78
* [ ` let ` statement] pattern bindings
79
79
80
- r[ name .explicit.macro_use]
80
+ r[ names .explicit.macro_use]
81
81
* The [ ` macro_use ` attribute] can introduce macro names from another crate
82
82
83
- r[ name .explicit.macro_export]
83
+ r[ names .explicit.macro_export]
84
84
* The [ ` macro_export ` attribute] can introduce an alias for the macro into the crate root
85
85
86
- r[ name .explicit.macro-invocation]
86
+ r[ names .explicit.macro-invocation]
87
87
Additionally, [ macro invocations] and [ attributes] can introduce names by
88
88
expanding to one of the above items.
89
89
90
90
## Implicitly declared entities
91
91
92
- r[ name .implicit]
92
+ r[ names .implicit]
93
93
94
- r[ name .implicit.list]
94
+ r[ names .implicit.list]
95
95
The following entities are implicitly defined by the language, or are
96
96
introduced by compiler options and extensions:
97
97
98
- r[ name .implicit.primitive-types]
98
+ r[ names .implicit.primitive-types]
99
99
* [ Language prelude] :
100
100
* [ Boolean type] --- ` bool `
101
101
* [ Textual types] --- ` char ` and ` str `
102
102
* [ Integer types] --- ` i8 ` , ` i16 ` , ` i32 ` , ` i64 ` , ` i128 ` , ` u8 ` , ` u16 ` , ` u32 ` , ` u64 ` , ` u128 `
103
103
* [ Machine-dependent integer types] --- ` usize ` and ` isize `
104
104
* [ floating-point types] --- ` f32 ` and ` f64 `
105
105
106
- r[ name .implicit.builtin-attributes]
106
+ r[ names .implicit.builtin-attributes]
107
107
* [ Built-in attributes]
108
108
109
- r[ name .implicit.prelude]
109
+ r[ names .implicit.prelude]
110
110
* [ Standard library prelude] items, attributes, and macros
111
111
112
- r[ name .implicit.stdlib]
112
+ r[ names .implicit.stdlib]
113
113
* [ Standard library] [ extern-prelude ] crates in the root module
114
114
115
- r[ name .implicit.extern-prelude]
115
+ r[ names .implicit.extern-prelude]
116
116
* [ External crates] [ extern-prelude ] linked by the compiler
117
117
118
- r[ name .implicit.tool-attributes]
118
+ r[ names .implicit.tool-attributes]
119
119
* [ Tool attributes]
120
120
121
- r[ name .implicit.lints]
121
+ r[ names .implicit.lints]
122
122
* [ Lints] and [ tool lint attributes]
123
123
124
- r[ name .implicit.derive-helpers]
124
+ r[ names .implicit.derive-helpers]
125
125
* [ Derive helper attributes] are valid within an item without being explicitly imported
126
126
127
- r[ name .implicit.lifetime-static]
127
+ r[ names .implicit.lifetime-static]
128
128
* The [ ` 'static ` ] lifetime
129
129
130
- r[ name .implicit.root]
130
+ r[ names .implicit.root]
131
131
Additionally, the crate root module does not have a name, but can be referred
132
132
to with certain [ path qualifiers] or aliases.
133
133
0 commit comments