diff --git a/src/comments.md b/src/comments.md index bf1e7ca..795bf63 100644 --- a/src/comments.md +++ b/src/comments.md @@ -30,7 +30,7 @@ >    | INNER_BLOCK_DOC > > _IsolatedCR_ :\ ->    _A `\r` not followed by a `\n`_ +>    \\r ## Non-doc comments @@ -53,8 +53,9 @@ that follows. That is, they are equivalent to writing `#![doc="..."]` around the body of the comment. `//!` comments are usually used to document modules that occupy a source file. -Isolated CRs (`\r`), i.e. not followed by LF (`\n`), are not allowed in doc -comments. +The character `U+000D` (CR) is not allowed in doc comments. + +> **Note**: The sequence `U+000D` (CR) immediately followed by `U+000A` (LF) would have been previously transformed into a single `U+000A` (LF). ## Examples diff --git a/src/crates-and-source-files.md b/src/crates-and-source-files.md index 8d54c3f..2373a79 100644 --- a/src/crates-and-source-files.md +++ b/src/crates-and-source-files.md @@ -2,16 +2,9 @@ > **Syntax**\ > _Crate_ :\ ->    UTF8BOM?\ ->    SHEBANG?\ >    [_InnerAttribute_]\*\ >    [_Item_]\* -> **Lexer**\ -> UTF8BOM : `\uFEFF`\ -> SHEBANG : `#!` \~`\n`\+[†](#shebang) - - > Note: Although Rust, like any other language, can be implemented by an > interpreter as well as a compiler, the only existing implementation is a > compiler, and the language has always been designed to be compiled. For these @@ -53,6 +46,8 @@ that apply to the containing module, most of which influence the behavior of the compiler. The anonymous crate module can have additional attributes that apply to the crate as a whole. +> **Note**: The file's contents may be preceded by a [shebang]. + ```rust // Specify the crate name. #![crate_name = "projx"] @@ -65,34 +60,6 @@ apply to the crate as a whole. #![warn(non_camel_case_types)] ``` -## Byte order mark - -The optional [_UTF8 byte order mark_] (UTF8BOM production) indicates that the -file is encoded in UTF8. It can only occur at the beginning of the file and -is ignored by the compiler. - -## Shebang - -A source file can have a [_shebang_] (SHEBANG production), which indicates -to the operating system what program to use to execute this file. It serves -essentially to treat the source file as an executable script. The shebang -can only occur at the beginning of the file (but after the optional -_UTF8BOM_). It is ignored by the compiler. For example: - - -```rust,ignore -#!/usr/bin/env rustx - -fn main() { - println!("Hello!"); -} -``` - -A restriction is imposed on the shebang syntax to avoid confusion with an -[attribute]. The `#!` characters must not be followed by a `[` token, ignoring -intervening [comments] or [whitespace]. If this restriction fails, then it is -not treated as a shebang, but instead as the start of an attribute. - ## Preludes and `no_std` This section has been moved to the [Preludes chapter](names/preludes.md). @@ -161,20 +128,17 @@ or `_` (U+005F) characters. [_InnerAttribute_]: attributes.md [_Item_]: items.md [_MetaNameValueStr_]: attributes.md#meta-item-attribute-syntax -[_shebang_]: https://en.wikipedia.org/wiki/Shebang_(Unix) -[_utf8 byte order mark_]: https://en.wikipedia.org/wiki/Byte_order_mark#UTF-8 [`ExitCode`]: ../std/process/struct.ExitCode.html [`Infallible`]: ../std/convert/enum.Infallible.html [`Termination`]: ../std/process/trait.Termination.html [attribute]: attributes.md [attributes]: attributes.md -[comments]: comments.md [function]: items/functions.md [module]: items/modules.md [module path]: paths.md +[shebang]: input-format.md#shebang-removal [trait or lifetime bounds]: trait-bounds.md [where clauses]: items/generics.md#where-clauses -[whitespace]: whitespace.md