Skip to content

Commit d106ef8

Browse files
committed
Improved attribute section, mostly by mentioning lint attributes.
Closes #2769
1 parent d701fcd commit d106ef8

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

doc/rust.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,9 +1304,8 @@ Attributes may appear as any of
13041304
* An identifier followed by the equals sign '=' and a literal, providing a key/value pair
13051305
* An identifier followed by a parenthesized list of sub-attribute arguments
13061306

1307-
Attributes are applied to an entity by placing them within a hash-list
1308-
(`#[...]`) as either a prefix to the entity or as a semicolon-delimited
1309-
declaration within the entity body.
1307+
Attributes terminated by a semi-colon apply to the entity that the attribute is declared
1308+
within. Attributes that are not terminated by a semi-colon apply to the next entity.
13101309

13111310
An example of attributes:
13121311

@@ -1326,9 +1325,9 @@ mod bar {
13261325
...
13271326
}
13281327
1329-
// A documentation attribute
1330-
#[doc = "Add two numbers together."]
1331-
fn add(x: int, y: int) { x + y }
1328+
// A lint attribute used to suppress a warning/error
1329+
#[allow(non_camel_case_types)]
1330+
pub type int8_t = i8;
13321331
~~~~~~~~
13331332

13341333
> **Note:** In future versions of Rust, user-provided extensions to the compiler will be able to interpret attributes.
@@ -1341,6 +1340,8 @@ names are effectively reserved. Some significant attributes include:
13411340
* The `cfg` attribute, for conditional-compilation by build-configuration.
13421341
* The `link` attribute, for describing linkage metadata for a crate.
13431342
* The `test` attribute, for marking functions as unit tests.
1343+
* The `allow`, `warn`, `forbid`, and `deny` attributes, for controling lint checks. Lint checks supported
1344+
by the compiler can be found via `rustc -W help`.
13441345

13451346
Other attributes may be added or removed during development of the language.
13461347

0 commit comments

Comments
 (0)