From a410833a7f86363a5929e46d1bc2087375d91f0c Mon Sep 17 00:00:00 2001 From: Corey Richardson Date: Sat, 29 Mar 2014 23:50:05 -0400 Subject: [PATCH 1/8] manual: update the note about reserved attributes --- src/doc/rust.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/doc/rust.md b/src/doc/rust.md index 9e211dda2fb..239ffa5d690 100644 --- a/src/doc/rust.md +++ b/src/doc/rust.md @@ -1722,13 +1722,12 @@ mod bar { pub type int8_t = i8; ~~~~ -> **Note:** In future versions of Rust, user-provided extensions to the compiler -> will be able to interpret attributes. When this facility is provided, the -> compiler will distinguish between language-reserved and user-available -> attributes. +> **Note:** At some point in the future, the compiler will distinguish between +> language-reserved and user-available attributes. Until then, there is +> effectively no difference between an attribute handled by a loadable syntax +> extension and the compiler. -At present, only the Rust compiler interprets attributes, so all attribute names -are effectively reserved. Some significant attributes include: +Some significant attributes include: * The `doc` attribute, for documenting code in-place. * The `cfg` attribute, for conditional-compilation by build-configuration (see From 2eccb1d0c241b2ad67d0cdadc66bbc45e9f6e290 Mon Sep 17 00:00:00 2001 From: Corey Richardson Date: Sun, 30 Mar 2014 08:30:25 -0400 Subject: [PATCH 2/8] manual: many fixes Mostly around attributes and language items. --- src/doc/rust.md | 250 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 170 insertions(+), 80 deletions(-) diff --git a/src/doc/rust.md b/src/doc/rust.md index 239ffa5d690..f8ce61d28ad 100644 --- a/src/doc/rust.md +++ b/src/doc/rust.md @@ -611,7 +611,7 @@ Attributes on the anonymous crate module define important metadata that influenc the behavior of the compiler. ~~~~ -// Package ID +// Crate ID #[ crate_id = "projx#2.5" ]; // Additional metadata attributes @@ -792,7 +792,7 @@ extern crate std; // equivalent to: extern crate std = "std"; extern crate ruststd = "std"; // linking to 'std' under another name -extern crate foo = "some/where/rust-foo#foo:1.0"; // a full package ID for external tools +extern crate foo = "some/where/rust-foo#foo:1.0"; // a full crate ID for external tools ~~~~ ##### Use declarations @@ -1505,11 +1505,9 @@ specified name. extern { } ~~~~ -The type of a function -declared in an extern block -is `extern "abi" fn(A1, ..., An) -> R`, -where `A1...An` are the declared types of its arguments -and `R` is the decalred return type. +The type of a function declared in an extern block is `extern "abi" fn(A1, +..., An) -> R`, where `A1...An` are the declared types of its arguments and +`R` is the declared return type. ## Visibility and Privacy @@ -1680,41 +1678,43 @@ import public items from their destination, not private items. ## Attributes ~~~~ {.notrust .ebnf .gram} -attribute : '#' '[' attr_list ']' ; -attr_list : attr [ ',' attr_list ]* ; +attribute : '#' '!' ? '[' attr_list ']' +attr_list : attr [ ',' attr_list ]* attr : ident [ '=' literal - | '(' attr_list ')' ] ? ; + | '(' attr_list ')' ] ? ~~~~ Static entities in Rust -- crates, modules and items -- may have _attributes_ -applied to them. ^[Attributes in Rust are modeled on Attributes in ECMA-335, -C#] -An attribute is a general, free-form metadatum that is interpreted according to name, convention, and language and compiler version. -Attributes may appear as any of +applied to them. Attributes in Rust are modeled on Attributes in ECMA-335, C#. +An attribute is a general, free-form metadatum that is interpreted according +to name, convention, and language and compiler version. Attributes may appear +as any of: * A single identifier, the attribute name -* An identifier followed by the equals sign '=' and a literal, providing a key/value pair +* An identifier followed by the equals sign '=' and a literal, providing a + key/value pair * An identifier followed by a parenthesized list of sub-attribute arguments -Attributes terminated by a semi-colon apply to the entity that the attribute is declared -within. Attributes that are not terminated by a semi-colon apply to the next entity. +Attributes with a bang ("!") after the hash ("#") apply to the item that the +attribute is declared within. Attributes that do not have a bang after the +hash by a semi-colon apply to the next item. An example of attributes: -~~~~ {.ignore} +~~~~ // General metadata applied to the enclosing module or crate. -#[license = "BSD"]; +#![license = "BSD"] // A function marked as a unit test #[test] fn test_foo() { - ... + /* ... */ } // A conditionally-compiled module #[cfg(target_os="linux")] mod bar { - ... + /* ... */ } // A lint attribute used to suppress a warning/error @@ -1727,29 +1727,85 @@ pub type int8_t = i8; > effectively no difference between an attribute handled by a loadable syntax > extension and the compiler. -Some significant attributes include: +### Crate-only attributes -* The `doc` attribute, for documenting code in-place. -* The `cfg` attribute, for conditional-compilation by build-configuration (see - [Conditional compilation](#conditional-compilation)). -* The `crate_id` attribute, for describing the package ID of a crate. -* The `lang` attribute, for custom definitions of traits and functions that are - known to the Rust compiler (see [Language items](#language-items)). -* The `link` attribute, for describing linkage metadata for a extern blocks. -* The `test` attribute, for marking functions as unit tests. -* The `allow`, `warn`, `forbid`, and `deny` attributes, for - controlling lint checks (see [Lint check attributes](#lint-check-attributes)). -* The `deriving` attribute, for automatically generating implementations of - certain traits. -* The `inline` attribute, for expanding functions at caller location (see - [Inline attributes](#inline-attributes)). -* The `static_assert` attribute, for asserting that a static bool is true at - compiletime. -* The `thread_local` attribute, for defining a `static mut` as a thread-local. - Note that this is only a low-level building block, and is not local to a - *task*, nor does it provide safety. +- `crate_type` - see [linkage](#linkage). +- `feature` - see [compiler features](#compiler-features). +- `no_start` - disable linking to the `native` crate, which specifies the + "start" language item. +- `no_main` - disable emitting the `main` symbol. Useful when some + other object being linked to defines `main`. +- `no_std` - disable linking to the `std` crate. +- `crate_id` - specify the this crate's crate ID. -Other attributes may be added or removed during development of the language. +### Module-only attributes + +- `path` - specifies the file to load the module from. `#[path="foo.rs"] mod + bar;` is equivalent to `mod bar { /* contents of foo.rs */ }` +- `macro_escape` - macros defined in this module will be visible in the + module's parent, after this module has been included. +- `no_implicit_prelude` - disable injecting `use std::prelude::*` in this + module. + +### Function-only attributes + +- `start` - indicates that this function should be used as the entry point, + overriding the "start" language item. See the "start" [language + item](#language-items) for more details. +- `main` - indicates that this function should be passed to the entry point, + rather than the function in the crate root named `main`. +- `macro_registrar` - when using loadable syntax extensions, mark this + function as the registration point for the current crate's syntax + extensions. + +### Static-only attributes + +- `thread_local` - on a `static mut`, this signals that the value of this + static may change depending on the current thread. The exact consequences of + this are implementation-defined. +- `address_insignificant` - references to this static may alias with + references to other statics, potentially of unrelated type. + +### FFI attributes + +On an `extern` block, the following attributes are interpreted: + +- `link` - indicate that a native library should be linked to for the + declarations in this block to be linked correctly. See [external + blocks](#external-blocks) +- `link_args` - specify arguments to the linker, rather than just the library + name and type. This is feature gated and the exact behavior is + implementation-defined (due to variety of linker invocation syntax). + +On declarations inside an `extern` block, the following attributes are +interpreted: + +- `link_name` - the name of the symbol that this function or static should be + imported as. +- `linkage` - on a static, this specifies the [linkage + type](http://llvm.org/docs/LangRef.html#linkage-types). + +### Miscellaneous attributes + +- `simd` - on certain tuple structs, derive the arithmetic operators, which + lower to the target's SIMD instructions, if any. +- `link_section` - on statics and functions, this specifies the section of the + object file that this item's contents will be placed into. +- `static_assert` - on statics whose type is `bool`, terminates compilation + with an error if it is not initialized to `true`. +- `repr` - on C-like enums, this sets the underlying type used for + representation. Useful for FFI. +- `no_mangle` - on any item, do not apply the standard name mangling. Set the + symbol for this item to its identifier. +- `packed` - on structs or enums, eliminate any padding that would be used to + align fields. +- `unsafe_destructor` - allow implementations of the "drop" language item + where the type it is implemented for does not implement the "send" language + item. +- `unsafe_no_drop_flag` - on structs, remove the flag that prevents + destructors from being run twice. Destructors might be run multiple times on + the same object with this attribute. +- `macro_export` - export a macro for cross-crate usage. ### Conditional compilation @@ -1791,9 +1847,7 @@ one of `foo` and `bar` to be defined (this resembles in the disjunctive normal form). Additionally, one can reverse a condition by enclosing it in a `not(...)`, like e. g. `#[cfg(not(target_os = "win32"))]`. -To pass a configuration option which triggers a `#[cfg(identifier)]` one can use -`rustc --cfg identifier`. In addition to that, the following configurations are -pre-defined by the compiler: +The following configurations must be defined by the implementation: * `target_arch = "..."`. Target CPU architecture, such as `"x86"`, `"x86_64"` `"mips"`, or `"arm"`. @@ -1805,8 +1859,8 @@ pre-defined by the compiler: * `target_os = "..."`. Operating system of the target, examples include `"win32"`, `"macos"`, `"linux"`, `"android"` or `"freebsd"`. * `target_word_size = "..."`. Target word size in bits. This is set to `"32"` - for 32-bit CPU targets, and likewise set to `"64"` for 64-bit CPU targets. - * `test`. Only set in test builds (`rustc --test`). + for targets with 32-bit pointers, and likewise set to `"64"` for 64-bit + pointers. * `unix`. See `target_family`. * `windows`. See `target_family`. @@ -1823,7 +1877,7 @@ For any lint check `C`: * `allow(C)` overrides the check for `C` so that violations will go unreported, * `forbid(C)` is the same as `deny(C)`, but also forbids uses of - `allow(C)` within the entity. + `allow(C)` within the attribute. The lint checks supported by the compiler can be found via `rustc -W help`, along with their default settings. @@ -1881,11 +1935,11 @@ mod m3 { ### Language items -Some primitive Rust operations are defined in Rust code, -rather than being implemented directly in C or assembly language. -The definitions of these operations have to be easy for the compiler to find. -The `lang` attribute makes it possible to declare these operations. -For example, the `str` module in the Rust standard library defines the string equality function: +Some primitive Rust operations are defined in Rust code, rather than being +implemented directly in C or assembly language. The definitions of these +operations have to be easy for the compiler to find. The `lang` attribute +makes it possible to declare these operations. For example, the `str` module +in the Rust standard library defines the string equality function: ~~~~ {.ignore} #[lang="str_eq"] @@ -1900,16 +1954,23 @@ when generating calls to the string equality function. A complete list of the built-in language items follows: -#### Traits +#### Built-in Traits -`const` - : Cannot be mutated. -`owned` - : Are uniquely owned. -`durable` - : Contain references. +`send` + : Able to be sent across task boundaries. +`sized` + : Has a size known at compile time. +`copy` + : Types that do not move ownership when used by-value. +`share` + : Able to be safely shared between tasks when aliased. `drop` - : Have finalizers. + : Have destructors. + +#### Operators + +These language items are traits: + `add` : Elements can be added (for example, integers and floats). `sub` @@ -1940,17 +2001,54 @@ A complete list of the built-in language items follows: : Elements can be compared for equality. `ord` : Elements have a partial ordering. +`deref` + : `*` can be applied, yielding a reference to another type +`deref_mut` + : `*` can be applied, yielding a mutable reference to another type -#### Operations + +These are functions: `str_eq` - : Compare two strings for equality. + : Compare two strings (`&str`) for equality. `uniq_str_eq` - : Compare two owned strings for equality. -`annihilate` - : Destroy a box before freeing it. -`log_type` - : Generically print a string representation of any type. + : Compare two owned strings (`~str`) for equality. +`strdup_uniq` + : Return a new unique string + containing a copy of the contents of a unique string. + +#### Types + +`unsafe` + : A type whose contents can be mutated through an immutable reference +`type_id` + : The type returned by the `type_id` intrinsic. + +#### Marker types + +These types help drive the compiler's analysis + +`covariant_type` + : The type parameter should be considered covariant +`contravariant_type` + : The type parameter should be considered contravariant +`invariant_type` + : The type parameter should be considered invariant +`covariant_lifetime` + : The lifetime parameter should be considered covariant +`contravariant_lifetime` + : The lifetime parameter should be considered contravariant +`invariant_lifetime` + : The lifetime parameter should be considered invariant +`no_send_bound` + : This type does not implement "send", even if eligible +`no_copy_bound` + : This type does not implement "copy", even if eligible +`no_share_bound` + : This type does not implement "share", even if eligible +`managed_bound` + : This type implements "managed" + `fail_` : Abort the program with an error. `fail_bounds_check` @@ -1963,15 +2061,6 @@ A complete list of the built-in language items follows: : Allocate memory on the managed heap. `free` : Free memory that was allocated on the managed heap. -`borrow_as_imm` - : Create an immutable reference to a mutable value. -`return_to_mut` - : Release a reference created with `return_to_mut` -`check_not_borrowed` - : Fail if a value has existing references to it. -`strdup_uniq` - : Return a new unique string - containing a copy of the contents of a unique string. > **Note:** This list is likely to become out of date. We should auto-generate it > from `librustc/middle/lang_items.rs`. @@ -2039,6 +2128,7 @@ Supported traits for `deriving` are: * `Show`, to format a value using the `{}` formatter. ### Stability + One can indicate the stability of an API using the following attributes: * `deprecated`: This item should no longer be used, e.g. it has been @@ -2101,10 +2191,10 @@ necessarily ready for every-day use. These features are often of "prototype quality" or "almost production ready", but may not be stable enough to be considered a full-fleged language feature. -For this reason, rust recognizes a special crate-level attribute of the form: +For this reason, Rust recognizes a special crate-level attribute of the form: ~~~~ {.ignore} -#[feature(feature1, feature2, feature3)] +#![feature(feature1, feature2, feature3)] ~~~~ This directive informs the compiler that the feature list: `feature1`, @@ -2112,7 +2202,7 @@ This directive informs the compiler that the feature list: `feature1`, crate-level, not at a module-level. Without this directive, all features are considered off, and using the features will result in a compiler error. -The currently implemented features of the compiler are: +The currently implemented features of the reference compiler are: * `macro_rules` - The definition of new macros. This does not encompass macro-invocation, that is always enabled by default, this only From b6d5dafea58c7f8f254333d53fe6b4b8ee8763e3 Mon Sep 17 00:00:00 2001 From: Corey Richardson Date: Sun, 30 Mar 2014 08:34:32 -0400 Subject: [PATCH 3/8] etc: attempts at fixing editor highlighting for new attribute syntax --- src/etc/emacs/rust-mode.el | 2 +- src/etc/gedit/share/gtksourceview-3.0/language-specs/rust.lang | 2 +- src/etc/kate/rust.xml | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/etc/emacs/rust-mode.el b/src/etc/emacs/rust-mode.el index 5cee600c2c0..26bdf7d7fba 100644 --- a/src/etc/emacs/rust-mode.el +++ b/src/etc/emacs/rust-mode.el @@ -122,7 +122,7 @@ ;; but the "else" or "{" should align with the beginning ;; of the expression it's in.) (looking-at "\\\\|{") - + (save-excursion (rust-rewind-irrelevant) ;; Point is now at the end of the previous ine diff --git a/src/etc/gedit/share/gtksourceview-3.0/language-specs/rust.lang b/src/etc/gedit/share/gtksourceview-3.0/language-specs/rust.lang index b9b0aa55a86..7ffa35b94e4 100644 --- a/src/etc/gedit/share/gtksourceview-3.0/language-specs/rust.lang +++ b/src/etc/gedit/share/gtksourceview-3.0/language-specs/rust.lang @@ -282,7 +282,7 @@ - \#\[ + \#!?\[ \] diff --git a/src/etc/kate/rust.xml b/src/etc/kate/rust.xml index 98d870adf03..7fc44ebad29 100644 --- a/src/etc/kate/rust.xml +++ b/src/etc/kate/rust.xml @@ -202,6 +202,7 @@ + From 13ac12db1c3ec1542464fe65a56e2fc33278beb6 Mon Sep 17 00:00:00 2001 From: Corey Richardson Date: Fri, 4 Apr 2014 01:04:37 -0400 Subject: [PATCH 4/8] manual: update style --- src/doc/rust.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/doc/rust.md b/src/doc/rust.md index f8ce61d28ad..1ec5057e390 100644 --- a/src/doc/rust.md +++ b/src/doc/rust.md @@ -612,18 +612,18 @@ the behavior of the compiler. ~~~~ // Crate ID -#[ crate_id = "projx#2.5" ]; +#![crate_id = "projx#2.5"] // Additional metadata attributes -#[ desc = "Project X" ]; -#[ license = "BSD" ]; -#[ comment = "This is a comment on Project X." ]; +#![desc = "Project X"] +#![license = "BSD"] +#![comment = "This is a comment on Project X."] // Specify the output type -#[ crate_type = "lib" ]; +#![crate_type = "lib"] // Turn on a warning -#[ warn(non_camel_case_types) ]; +#![warn(non_camel_case_types)] ~~~~ A crate that contains a `main` function can be compiled to an executable. From a86d6b4cc9f19a8ad8fe34a627d5543cdd29230c Mon Sep 17 00:00:00 2001 From: Corey Richardson Date: Fri, 4 Apr 2014 01:17:35 -0400 Subject: [PATCH 5/8] manual: fix attribute ebnf --- src/doc/rust.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/doc/rust.md b/src/doc/rust.md index 1ec5057e390..02acd0acbb5 100644 --- a/src/doc/rust.md +++ b/src/doc/rust.md @@ -1678,10 +1678,10 @@ import public items from their destination, not private items. ## Attributes ~~~~ {.notrust .ebnf .gram} -attribute : '#' '!' ? '[' attr_list ']' -attr_list : attr [ ',' attr_list ]* +attribute : '#' '!' ? '[' attr_list ']' ; +attr_list : attr [ ',' attr_list ]* ; attr : ident [ '=' literal - | '(' attr_list ')' ] ? + | '(' attr_list ')' ] ? ; ~~~~ Static entities in Rust -- crates, modules and items -- may have _attributes_ From d2648cc23f34da72be41701d50bc956e4244c77c Mon Sep 17 00:00:00 2001 From: Corey Richardson Date: Fri, 4 Apr 2014 00:50:36 -0400 Subject: [PATCH 6/8] manual: further attribute clarifications - Sort attributes lexicographically - Use new attribute syntax consistently - Fix wording describing new attribute syntax - Expand section on `repr` --- src/doc/rust.md | 53 +++++++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/src/doc/rust.md b/src/doc/rust.md index 02acd0acbb5..1ff0d92d19b 100644 --- a/src/doc/rust.md +++ b/src/doc/rust.md @@ -610,7 +610,7 @@ and may optionally begin with any number of `attributes` that apply to the conta Attributes on the anonymous crate module define important metadata that influences the behavior of the compiler. -~~~~ +~~~~ {.rust} // Crate ID #![crate_id = "projx#2.5"] @@ -1697,7 +1697,7 @@ as any of: Attributes with a bang ("!") after the hash ("#") apply to the item that the attribute is declared within. Attributes that do not have a bang after the -hash by a semi-colon apply to the next item. +hash apply to the item that follows the attribute. An example of attributes: @@ -1729,53 +1729,54 @@ pub type int8_t = i8; ### Crate-only attributes +- `crate_id` - specify the this crate's crate ID. - `crate_type` - see [linkage](#linkage). - `feature` - see [compiler features](#compiler-features). +- `no_main` - disable emitting the `main` symbol. Useful when some other + object being linked to defines `main`. - `no_start` - disable linking to the `native` crate, which specifies the "start" language item. -- `no_main` - disable emitting the `main` symbol. Useful when some - other object being linked to defines `main`. - `no_std` - disable linking to the `std` crate. -- `crate_id` - specify the this crate's crate ID. ### Module-only attributes -- `path` - specifies the file to load the module from. `#[path="foo.rs"] mod - bar;` is equivalent to `mod bar { /* contents of foo.rs */ }` - `macro_escape` - macros defined in this module will be visible in the module's parent, after this module has been included. - `no_implicit_prelude` - disable injecting `use std::prelude::*` in this module. +- `path` - specifies the file to load the module from. `#[path="foo.rs"] mod + bar;` is equivalent to `mod bar { /* contents of foo.rs */ }`. The path is + taken relative to the directory that the current module is in. ### Function-only attributes -- `start` - indicates that this function should be used as the entry point, - overriding the "start" language item. See the "start" [language - item](#language-items) for more details. -- `main` - indicates that this function should be passed to the entry point, - rather than the function in the crate root named `main`. - `macro_registrar` - when using loadable syntax extensions, mark this function as the registration point for the current crate's syntax extensions. +- `main` - indicates that this function should be passed to the entry point, + rather than the function in the crate root named `main`. +- `start` - indicates that this function should be used as the entry point, + overriding the "start" language item. See the "start" [language + item](#language-items) for more details. ### Static-only attributes +- `address_insignificant` - references to this static may alias with + references to other statics, potentially of unrelated type. - `thread_local` - on a `static mut`, this signals that the value of this static may change depending on the current thread. The exact consequences of this are implementation-defined. -- `address_insignificant` - references to this static may alias with - references to other statics, potentially of unrelated type. ### FFI attributes On an `extern` block, the following attributes are interpreted: -- `link` - indicate that a native library should be linked to for the - declarations in this block to be linked correctly. See [external - blocks](#external-blocks) - `link_args` - specify arguments to the linker, rather than just the library name and type. This is feature gated and the exact behavior is implementation-defined (due to variety of linker invocation syntax). +- `link` - indicate that a native library should be linked to for the + declarations in this block to be linked correctly. See [external + blocks](#external-blocks) On declarations inside an `extern` block, the following attributes are interpreted: @@ -1787,25 +1788,29 @@ interpreted: ### Miscellaneous attributes -- `simd` - on certain tuple structs, derive the arithmetic operators, which - lower to the target's SIMD instructions, if any. - `link_section` - on statics and functions, this specifies the section of the object file that this item's contents will be placed into. -- `static_assert` - on statics whose type is `bool`, terminates compilation - with an error if it is not initialized to `true`. -- `repr` - on C-like enums, this sets the underlying type used for - representation. Useful for FFI. +- `macro_export` - export a macro for cross-crate usage. - `no_mangle` - on any item, do not apply the standard name mangling. Set the symbol for this item to its identifier. - `packed` - on structs or enums, eliminate any padding that would be used to align fields. +- `repr` - on C-like enums, this sets the underlying type used for + representation. Useful for FFI. Takes one argument, which is the primitive + type this enum should be represented for, or `C`, which specifies that it + should be the default `enum` size of the C ABI for that platform. Note that + enum representation in C is undefined, and this may be incorrect when the C + code is compiled with certain flags. +- `simd` - on certain tuple structs, derive the arithmetic operators, which + lower to the target's SIMD instructions, if any. +- `static_assert` - on statics whose type is `bool`, terminates compilation + with an error if it is not initialized to `true`. - `unsafe_destructor` - allow implementations of the "drop" language item where the type it is implemented for does not implement the "send" language item. - `unsafe_no_drop_flag` - on structs, remove the flag that prevents destructors from being run twice. Destructors might be run multiple times on the same object with this attribute. -- `macro_export` - export a macro for cross-crate usage. ### Conditional compilation From 838a57ba9e24e1f7c293828de142f56e64a2900b Mon Sep 17 00:00:00 2001 From: Corey Richardson Date: Fri, 4 Apr 2014 01:35:50 -0400 Subject: [PATCH 7/8] manual: refine ECMA-335 reference for attributes --- src/doc/rust.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/doc/rust.md b/src/doc/rust.md index 1ff0d92d19b..b2b550bfa82 100644 --- a/src/doc/rust.md +++ b/src/doc/rust.md @@ -1685,10 +1685,10 @@ attr : ident [ '=' literal ~~~~ Static entities in Rust -- crates, modules and items -- may have _attributes_ -applied to them. Attributes in Rust are modeled on Attributes in ECMA-335, C#. -An attribute is a general, free-form metadatum that is interpreted according -to name, convention, and language and compiler version. Attributes may appear -as any of: +applied to them. Attributes in Rust are modeled on Attributes in ECMA-335, +with the syntax coming from ECMA-334 (C#). An attribute is a general, +free-form metadatum that is interpreted according to name, convention, and +language and compiler version. Attributes may appear as any of: * A single identifier, the attribute name * An identifier followed by the equals sign '=' and a literal, providing a @@ -1881,8 +1881,8 @@ For any lint check `C`: * `deny(C)` signals an error after encountering a violation of `C`, * `allow(C)` overrides the check for `C` so that violations will go unreported, - * `forbid(C)` is the same as `deny(C)`, but also forbids uses of - `allow(C)` within the attribute. + * `forbid(C)` is the same as `deny(C)`, but also forbids changing the lint + level afterwards. The lint checks supported by the compiler can be found via `rustc -W help`, along with their default settings. From b727bb7febf8662ce4b45e46985ff192490cbbb5 Mon Sep 17 00:00:00 2001 From: Corey Richardson Date: Fri, 4 Apr 2014 04:08:13 -0400 Subject: [PATCH 8/8] manual: fix a broken example --- src/doc/rust.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/doc/rust.md b/src/doc/rust.md index b2b550bfa82..f73b40a3ff4 100644 --- a/src/doc/rust.md +++ b/src/doc/rust.md @@ -875,7 +875,7 @@ and `extern crate` declarations. An example of what will and will not work for `use` items: ~~~~ -# #[allow(unused_imports)]; +# #![allow(unused_imports)] use foo::native::start; // good: foo is at the root of the crate use foo::baz::foobaz; // good: foo is at the root of the crate @@ -1701,7 +1701,7 @@ hash apply to the item that follows the attribute. An example of attributes: -~~~~ +~~~~ {.rust} // General metadata applied to the enclosing module or crate. #![license = "BSD"] @@ -1719,7 +1719,7 @@ mod bar { // A lint attribute used to suppress a warning/error #[allow(non_camel_case_types)] -pub type int8_t = i8; +type int8_t = i8; ~~~~ > **Note:** At some point in the future, the compiler will distinguish between @@ -2160,7 +2160,7 @@ be unstable for the purposes of the lint. One can give an optional string that will be displayed when the lint flags the use of an item. ~~~~ {.ignore} -#[warn(unstable)]; +#![warn(unstable)] #[deprecated="replaced by `best`"] fn bad() { @@ -3978,7 +3978,7 @@ Rust provides several macros to log information. Here's a simple Rust program that demonstrates all four of them: ~~~~ -#[feature(phase)]; +#![feature(phase)] #[phase(syntax, link)] extern crate log; fn main() {