9
9
10
10
> ** <sup >Lexer</sup >** \
11
11
> UTF8BOM : ` \uFEFF ` \
12
- > SHEBANG : ` #! ` ~ [ ` [ ` ` \n ` ] ~ ` \n ` <sup >\* </sup >
12
+ > SHEBANG : ` #! ` \ ~` \n ` <sup >\+ </sup >[ † ] ( #shebang )
13
13
14
14
15
15
> Note: Although Rust, like any other language, can be implemented by an
@@ -65,10 +65,14 @@ apply to the crate as a whole.
65
65
#![warn(non_camel_case_types)]
66
66
```
67
67
68
+ ## Byte order mark
69
+
68
70
The optional [ _ UTF8 byte order mark_ ] (UTF8BOM production) indicates that the
69
71
file is encoded in UTF8. It can only occur at the beginning of the file and
70
72
is ignored by the compiler.
71
73
74
+ ## Shebang
75
+
72
76
A source file can have a [ _ shebang_ ] (SHEBANG production), which indicates
73
77
to the operating system what program to use to execute this file. It serves
74
78
essentially to treat the source file as an executable script. The shebang
@@ -84,6 +88,13 @@ fn main() {
84
88
}
85
89
```
86
90
91
+ There are two restrictions imposed on the shebang syntax to avoid confusion
92
+ with an [ attribute] . The shebang line must have at least one non-[ whitespace]
93
+ character anywhere after the ` #! ` characters. Additionally, The ` #! `
94
+ characters must not be followed by a ` [ ` token, ignoring intervening
95
+ [ comments] or [ whitespace] . If either of these restrictions fails, then it is
96
+ not treated as a shebang, but instead as the start of an attribute.
97
+
87
98
## Preludes and ` no_std `
88
99
89
100
All crates have a * prelude* that automatically inserts names from a specific
@@ -166,8 +177,10 @@ or `-` (U+002D) characters.
166
177
[ `std::prelude::v1` ] : ../std/prelude/index.html
167
178
[ attribute ] : attributes.md
168
179
[ attributes ] : attributes.md
180
+ [ comments ] : comments.md
169
181
[ function ] : items/functions.md
170
182
[ module ] : items/modules.md
171
183
[ module path ] : paths.md
172
184
[ trait or lifetime bounds ] : trait-bounds.md
173
185
[ where clauses ] : items/generics.md#where-clauses
186
+ [ whitespace ] : whitespace.md
0 commit comments