GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||
GeezerVison is showing doc.rust-lang.org — Attributes - The Rust Reference AttributesSyntax
OuterAttribute → # [ Attr ] Attr → An attribute is a general, free-form metadatum that is interpreted according to name, convention, language, and compiler version. Attributes are modeled on Attributes in ECMA-335, with the syntax coming from ECMA-334 (C#). Inner attributes apply to the form that the attribute is declared within.
Outer attributes apply to the form that follows the attribute.
The attribute consists of a path to the attribute, followed by an optional delimited token tree whose interpretation is defined by the attribute. Attributes other than macro attributes also allow the input to be an equals sign ( An attribute may be unsafe to apply. To avoid undefined behavior when using these attributes, certain obligations that cannot be checked by the compiler must be met. To assert these have been, the attribute is wrapped in The following attributes are unsafe: Attributes can be classified into the following kinds: Attributes may be applied to many forms in the language:
Meta item attribute syntaxA “meta item” is the syntax used for the Attr rule by most built-in attributes. It has the following grammar: Syntax
MetaSeq → Expressions in meta items must macro-expand to literal expressions, which must not include integer or float type suffixes. Expressions which are not literal expressions will be syntactically accepted (and can be passed to proc-macros), but will be rejected after parsing. Note that if the attribute appears within another macro, it will be expanded after that outer macro. For example, the following code will expand the
Additionally, macros in attributes will be expanded only after all other attributes applied to the item:
Various built-in attributes use different subsets of the meta item syntax to specify their inputs. The following grammar rules show some commonly used forms: Syntax
MetaNameValueStr → MetaListPaths → MetaListIdents → MetaListNameValueStr → Some examples of meta items are:
Active and inert attributesAn attribute is either active or inert. During attribute processing, active attributes remove themselves from the form they are on while inert attributes stay on. The Tool attributesThe compiler may allow attributes for external tools where each tool resides in its own module in the tool prelude. The first segment of the attribute path is the name of the tool, with one or more additional segments whose interpretation is up to the tool. When a tool is not in use, the tool’s attributes are accepted without a warning. When the tool is in use, the tool is responsible for processing and interpretation of its attributes. Tool attributes are not available if the
Built-in attributes indexThe following is an index of all built-in attributes.
| ||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |