Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-release > by-pkgid > 0c2243f8a1696816431e7210e991fa52 > files > 13326

rust-doc-1.35.0-1.mga7.armv7hl.rpm

<!DOCTYPE HTML>
<html lang="en" class="sidebar-visible no-js">
    <head>
        <!-- Book generated using mdBook -->
        <meta charset="UTF-8">
        <title>Attributes - The Rust Reference</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="theme-color" content="#ffffff" />

        <base href="">

        <link rel="stylesheet" href="book.css">
        <link href="https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" rel="stylesheet" type="text/css">
        <link href="https://fonts.googleapis.com/css?family=Source+Code+Pro:500" rel="stylesheet" type="text/css">

        <link rel="shortcut icon" href="favicon.png">

        <!-- Font Awesome -->
        <link rel="stylesheet" href="_FontAwesome/css/font-awesome.css">

        <link rel="stylesheet" href="highlight.css">
        <link rel="stylesheet" href="tomorrow-night.css">
        <link rel="stylesheet" href="ayu-highlight.css">

        <!-- Custom theme stylesheets -->
        
        <link rel="stylesheet" href="src/theme/reference.css">
        

        

    </head>
    <body class="light">
        <!-- Work around some values being stored in localStorage wrapped in quotes -->
        <script type="text/javascript">
            try {
                var theme = localStorage.getItem('mdbook-theme');
                var sidebar = localStorage.getItem('mdbook-sidebar');

                if (theme.startsWith('"') && theme.endsWith('"')) {
                    localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
                }

                if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
                    localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
                }
            } catch (e) { }
        </script>

        <!-- Set the theme before any content is loaded, prevents flash -->
        <script type="text/javascript">
            var theme;
            try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { } 
            if (theme === null || theme === undefined) { theme = 'light'; }
            document.body.className = theme;
            document.querySelector('html').className = theme + ' js';
        </script>

        <!-- Hide / unhide sidebar before it is displayed -->
        <script type="text/javascript">
            var html = document.querySelector('html');
            var sidebar = 'hidden';
            if (document.body.clientWidth >= 1080) {
                try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
                sidebar = sidebar || 'visible';
            }
            html.classList.remove('sidebar-visible');
            html.classList.add("sidebar-" + sidebar);
        </script>

        <nav id="sidebar" class="sidebar" aria-label="Table of contents">
            <ol class="chapter"><li class="affix"><a href="introduction.html">Introduction</a></li><li><a href="notation.html"><strong aria-hidden="true">1.</strong> Notation</a></li><li><a href="lexical-structure.html"><strong aria-hidden="true">2.</strong> Lexical structure</a></li><li><ol class="section"><li><a href="input-format.html"><strong aria-hidden="true">2.1.</strong> Input format</a></li><li><a href="keywords.html"><strong aria-hidden="true">2.2.</strong> Keywords</a></li><li><a href="identifiers.html"><strong aria-hidden="true">2.3.</strong> Identifiers</a></li><li><a href="comments.html"><strong aria-hidden="true">2.4.</strong> Comments</a></li><li><a href="whitespace.html"><strong aria-hidden="true">2.5.</strong> Whitespace</a></li><li><a href="tokens.html"><strong aria-hidden="true">2.6.</strong> Tokens</a></li><li><a href="paths.html"><strong aria-hidden="true">2.7.</strong> Paths</a></li></ol></li><li><a href="macros.html"><strong aria-hidden="true">3.</strong> Macros</a></li><li><ol class="section"><li><a href="macros-by-example.html"><strong aria-hidden="true">3.1.</strong> Macros By Example</a></li><li><a href="procedural-macros.html"><strong aria-hidden="true">3.2.</strong> Procedural Macros</a></li></ol></li><li><a href="crates-and-source-files.html"><strong aria-hidden="true">4.</strong> Crates and source files</a></li><li><a href="conditional-compilation.html"><strong aria-hidden="true">5.</strong> Conditional compilation</a></li><li><a href="items.html"><strong aria-hidden="true">6.</strong> Items</a></li><li><ol class="section"><li><a href="items/modules.html"><strong aria-hidden="true">6.1.</strong> Modules</a></li><li><a href="items/extern-crates.html"><strong aria-hidden="true">6.2.</strong> Extern crates</a></li><li><a href="items/use-declarations.html"><strong aria-hidden="true">6.3.</strong> Use declarations</a></li><li><a href="items/functions.html"><strong aria-hidden="true">6.4.</strong> Functions</a></li><li><a href="items/type-aliases.html"><strong aria-hidden="true">6.5.</strong> Type aliases</a></li><li><a href="items/structs.html"><strong aria-hidden="true">6.6.</strong> Structs</a></li><li><a href="items/enumerations.html"><strong aria-hidden="true">6.7.</strong> Enumerations</a></li><li><a href="items/unions.html"><strong aria-hidden="true">6.8.</strong> Unions</a></li><li><a href="items/constant-items.html"><strong aria-hidden="true">6.9.</strong> Constant items</a></li><li><a href="items/static-items.html"><strong aria-hidden="true">6.10.</strong> Static items</a></li><li><a href="items/traits.html"><strong aria-hidden="true">6.11.</strong> Traits</a></li><li><a href="items/implementations.html"><strong aria-hidden="true">6.12.</strong> Implementations</a></li><li><a href="items/external-blocks.html"><strong aria-hidden="true">6.13.</strong> External blocks</a></li><li><a href="items/generics.html"><strong aria-hidden="true">6.14.</strong> Type and lifetime parameters</a></li><li><a href="items/associated-items.html"><strong aria-hidden="true">6.15.</strong> Associated Items</a></li><li><a href="visibility-and-privacy.html"><strong aria-hidden="true">6.16.</strong> Visibility and Privacy</a></li></ol></li><li><a href="attributes.html" class="active"><strong aria-hidden="true">7.</strong> Attributes</a></li><li><ol class="section"><li><a href="attributes/testing.html"><strong aria-hidden="true">7.1.</strong> Testing</a></li><li><a href="attributes/derive.html"><strong aria-hidden="true">7.2.</strong> Derive</a></li><li><a href="attributes/diagnostics.html"><strong aria-hidden="true">7.3.</strong> Diagnostics</a></li><li><a href="attributes/codegen.html"><strong aria-hidden="true">7.4.</strong> Code generation</a></li><li><a href="attributes/limits.html"><strong aria-hidden="true">7.5.</strong> Limits</a></li></ol></li><li><a href="statements-and-expressions.html"><strong aria-hidden="true">8.</strong> Statements and expressions</a></li><li><ol class="section"><li><a href="statements.html"><strong aria-hidden="true">8.1.</strong> Statements</a></li><li><a href="expressions.html"><strong aria-hidden="true">8.2.</strong> Expressions</a></li><li><ol class="section"><li><a href="expressions/literal-expr.html"><strong aria-hidden="true">8.2.1.</strong> Literal expressions</a></li><li><a href="expressions/path-expr.html"><strong aria-hidden="true">8.2.2.</strong> Path expressions</a></li><li><a href="expressions/block-expr.html"><strong aria-hidden="true">8.2.3.</strong> Block expressions</a></li><li><a href="expressions/operator-expr.html"><strong aria-hidden="true">8.2.4.</strong> Operator expressions</a></li><li><a href="expressions/grouped-expr.html"><strong aria-hidden="true">8.2.5.</strong> Grouped expressions</a></li><li><a href="expressions/array-expr.html"><strong aria-hidden="true">8.2.6.</strong> Array and index expressions</a></li><li><a href="expressions/tuple-expr.html"><strong aria-hidden="true">8.2.7.</strong> Tuple and index expressions</a></li><li><a href="expressions/struct-expr.html"><strong aria-hidden="true">8.2.8.</strong> Struct expressions</a></li><li><a href="expressions/enum-variant-expr.html"><strong aria-hidden="true">8.2.9.</strong> Enum variant expressions</a></li><li><a href="expressions/call-expr.html"><strong aria-hidden="true">8.2.10.</strong> Call expressions</a></li><li><a href="expressions/method-call-expr.html"><strong aria-hidden="true">8.2.11.</strong> Method call expressions</a></li><li><a href="expressions/field-expr.html"><strong aria-hidden="true">8.2.12.</strong> Field access expressions</a></li><li><a href="expressions/closure-expr.html"><strong aria-hidden="true">8.2.13.</strong> Closure expressions</a></li><li><a href="expressions/loop-expr.html"><strong aria-hidden="true">8.2.14.</strong> Loop expressions</a></li><li><a href="expressions/range-expr.html"><strong aria-hidden="true">8.2.15.</strong> Range expressions</a></li><li><a href="expressions/if-expr.html"><strong aria-hidden="true">8.2.16.</strong> If and if let expressions</a></li><li><a href="expressions/match-expr.html"><strong aria-hidden="true">8.2.17.</strong> Match expressions</a></li><li><a href="expressions/return-expr.html"><strong aria-hidden="true">8.2.18.</strong> Return expressions</a></li></ol></li></ol></li><li><a href="patterns.html"><strong aria-hidden="true">9.</strong> Patterns</a></li><li><a href="type-system.html"><strong aria-hidden="true">10.</strong> Type system</a></li><li><ol class="section"><li><a href="types.html"><strong aria-hidden="true">10.1.</strong> Types</a></li><li><ol class="section"><li><a href="types/boolean.html"><strong aria-hidden="true">10.1.1.</strong> Boolean type</a></li><li><a href="types/numeric.html"><strong aria-hidden="true">10.1.2.</strong> Numeric types</a></li><li><a href="types/textual.html"><strong aria-hidden="true">10.1.3.</strong> Textual types</a></li><li><a href="types/never.html"><strong aria-hidden="true">10.1.4.</strong> Never type</a></li><li><a href="types/tuple.html"><strong aria-hidden="true">10.1.5.</strong> Tuple types</a></li><li><a href="types/array.html"><strong aria-hidden="true">10.1.6.</strong> Array types</a></li><li><a href="types/slice.html"><strong aria-hidden="true">10.1.7.</strong> Slice types</a></li><li><a href="types/struct.html"><strong aria-hidden="true">10.1.8.</strong> Struct types</a></li><li><a href="types/enum.html"><strong aria-hidden="true">10.1.9.</strong> Enumerated types</a></li><li><a href="types/union.html"><strong aria-hidden="true">10.1.10.</strong> Union types</a></li><li><a href="types/function-item.html"><strong aria-hidden="true">10.1.11.</strong> Function item types</a></li><li><a href="types/closure.html"><strong aria-hidden="true">10.1.12.</strong> Closure types</a></li><li><a href="types/pointer.html"><strong aria-hidden="true">10.1.13.</strong> Pointer types</a></li><li><a href="types/function-pointer.html"><strong aria-hidden="true">10.1.14.</strong> Function pointer types</a></li><li><a href="types/trait-object.html"><strong aria-hidden="true">10.1.15.</strong> Trait object types</a></li><li><a href="types/impl-trait.html"><strong aria-hidden="true">10.1.16.</strong> Impl trait type</a></li><li><a href="types/parameters.html"><strong aria-hidden="true">10.1.17.</strong> Type parameters</a></li><li><a href="types/inferred.html"><strong aria-hidden="true">10.1.18.</strong> Inferred type</a></li></ol></li><li><a href="dynamically-sized-types.html"><strong aria-hidden="true">10.2.</strong> Dynamically Sized Types</a></li><li><a href="type-layout.html"><strong aria-hidden="true">10.3.</strong> Type layout</a></li><li><a href="interior-mutability.html"><strong aria-hidden="true">10.4.</strong> Interior mutability</a></li><li><a href="subtyping.html"><strong aria-hidden="true">10.5.</strong> Subtyping and Variance</a></li><li><a href="trait-bounds.html"><strong aria-hidden="true">10.6.</strong> Trait and lifetime bounds</a></li><li><a href="type-coercions.html"><strong aria-hidden="true">10.7.</strong> Type coercions</a></li><li><a href="destructors.html"><strong aria-hidden="true">10.8.</strong> Destructors</a></li><li><a href="lifetime-elision.html"><strong aria-hidden="true">10.9.</strong> Lifetime elision</a></li></ol></li><li><a href="special-types-and-traits.html"><strong aria-hidden="true">11.</strong> Special types and traits</a></li><li><a href="memory-model.html"><strong aria-hidden="true">12.</strong> Memory model</a></li><li><ol class="section"><li><a href="memory-allocation-and-lifetime.html"><strong aria-hidden="true">12.1.</strong> Memory allocation and lifetime</a></li><li><a href="memory-ownership.html"><strong aria-hidden="true">12.2.</strong> Memory ownership</a></li><li><a href="variables.html"><strong aria-hidden="true">12.3.</strong> Variables</a></li></ol></li><li><a href="linkage.html"><strong aria-hidden="true">13.</strong> Linkage</a></li><li><a href="unsafety.html"><strong aria-hidden="true">14.</strong> Unsafety</a></li><li><ol class="section"><li><a href="unsafe-functions.html"><strong aria-hidden="true">14.1.</strong> Unsafe functions</a></li><li><a href="unsafe-blocks.html"><strong aria-hidden="true">14.2.</strong> Unsafe blocks</a></li><li><a href="behavior-considered-undefined.html"><strong aria-hidden="true">14.3.</strong> Behavior considered undefined</a></li><li><a href="behavior-not-considered-unsafe.html"><strong aria-hidden="true">14.4.</strong> Behavior not considered unsafe</a></li></ol></li><li><a href="const_eval.html"><strong aria-hidden="true">15.</strong> Constant Evaluation</a></li><li><a href="abi.html"><strong aria-hidden="true">16.</strong> Application Binary Interface</a></li><li><a href="runtime.html"><strong aria-hidden="true">17.</strong> The Rust runtime</a></li><li><a href="appendices.html"><strong aria-hidden="true">18.</strong> Appendices</a></li><li><ol class="section"><li><a href="macro-ambiguity.html"><strong aria-hidden="true">18.1.</strong> Macro Follow-Set Ambiguity Formal Specification</a></li><li><a href="influences.html"><strong aria-hidden="true">18.2.</strong> Influences</a></li><li><a href="glossary.html"><strong aria-hidden="true">18.3.</strong> Glossary</a></li></ol></li></ol>
        </nav>

        <div id="page-wrapper" class="page-wrapper">

            <div class="page">
                <header><p class="warning">
    For now, this reference is a best-effort document. We strive for validity
    and completeness, but are not yet there. In the future, the docs and lang
    teams will work together to figure out how best to do this. Until then, this
    is a best-effort attempt. If you find something wrong or missing, file an
    <a href="https://github.com/rust-lang-nursery/reference/issues">issue</a> or
    send in a pull request.
</p></header>
                <div id="menu-bar" class="menu-bar">
                    <div id="menu-bar-sticky-container">
                        <div class="left-buttons">
                            <button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
                                <i class="fa fa-bars"></i>
                            </button>
                            <button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
                                <i class="fa fa-paint-brush"></i>
                            </button>
                            <ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
                                <li role="none"><button role="menuitem" class="theme" id="light">Light <span class="default">(default)</span></button></li>
                                <li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
                                <li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
                                <li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
                                <li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
                            </ul>
                            
                            <button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
                                <i class="fa fa-search"></i>
                            </button>
                            
                        </div>

                        <h1 class="menu-title">The Rust Reference</h1> 

                        <div class="right-buttons">
                            <a href="print.html" title="Print this book" aria-label="Print this book">
                                <i id="print-button" class="fa fa-print"></i>
                            </a>
                        </div>
                    </div>
                </div>

                
                <div id="search-wrapper" class="hidden">
                    <form id="searchbar-outer" class="searchbar-outer">
                        <input type="search" name="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
                    </form>
                    <div id="searchresults-outer" class="searchresults-outer hidden">
                        <div id="searchresults-header" class="searchresults-header"></div>
                        <ul id="searchresults">
                        </ul>
                    </div>
                </div>
                

                <!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
                <script type="text/javascript">
                    document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
                    document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
                    Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
                        link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
                    });
                </script>

                <div id="content" class="content">
                    <main>
                        <script>
(function() {
    var fragments = {
        "#cold-attribute": "codegen.html#the-cold-attribute",
        "#conditional-compilation": "conditional-compilation.html",
        "#deprecation": "diagnostics.html#the-deprecated-attribute",
        "#derive": "attributes/derive.html",
        "#documentation": "../rustdoc/the-doc-attribute.html",
        "#ffi-attributes": "attributes.html#built-in-attributes-index",
        "#inline-attribute": "codegen.html#the-inline-attribute",
        "#lint-check-attributes": "diagnostics.html#lint-check-attributes",
        "#macro-related-attributes": "attributes.html#built-in-attributes-index",
        "#miscellaneous-attributes": "attributes.html#built-in-attributes-index",
        "#must_use": "diagnostics.html#the-must_use-attribute",
        "#optimization-hints": "codegen.html#optimization-hints",
        "#path": "items/modules.html#the-path-attribute",
        "#preludes": "crates-and-source-files.html#preludes-and-no_std",
        "#testing": "testing.html",
        "#tool-lint-attributes": "diagnostics.html#tool-lint-attributes",
        "#crate-only-attributes": "attributes.html#built-in-attributes-index",
    };
    var target = fragments[window.location.hash];
    if (target) {
        var url = window.location.toString();
        var base = url.substring(0, url.lastIndexOf('/'));
        window.location.replace(base + "/" + target);
    }
})();
</script>
<a class="header" href="attributes.html#attributes" id="attributes"><h1>Attributes</h1></a>
<blockquote>
<p><strong><sup>Syntax</sup></strong><br />
<em>InnerAttribute</em> :<br />
   <code>#</code> <code>!</code> <code>[</code> <em>Attr</em> <code>]</code></p>
<p><em>OuterAttribute</em> :<br />
   <code>#</code> <code>[</code> <em>Attr</em> <code>]</code></p>
<p><em>Attr</em> :<br />
   <a href="paths.html#simple-paths"><em>SimplePath</em></a> <em>AttrInput</em><sup>?</sup></p>
<p><em>AttrInput</em> :<br />
      <a href="macros.html"><em>DelimTokenTree</em></a><br />
   | <code>=</code> <a href="expressions/literal-expr.html"><em>LiteralExpression</em></a><sub><em>without suffix</em></sub></p>
</blockquote>
<p>An <em>attribute</em> is a general, free-form metadatum that is interpreted according
to name, convention, and language and compiler version. Attributes are modeled
on Attributes in <a href="https://www.ecma-international.org/publications/standards/Ecma-335.htm">ECMA-335</a>, with the syntax coming from <a href="https://www.ecma-international.org/publications/standards/Ecma-334.htm">ECMA-334</a> (C#).</p>
<p><em>Inner attributes</em>, written with a bang (<code>!</code>) after the hash (<code>#</code>), apply to the
item that the attribute is declared within. <em>Outer attributes</em>, written without
the bang after the hash, apply to the thing that follows the attribute.</p>
<p>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 (<code>=</code>) followed by a literal expression. See the <a href="attributes.html#meta-item-attribute-syntax">meta item
syntax</a> below for more details.</p>
<p>Attributes can be classified into the following kinds:</p>
<ul>
<li><a href="attributes.html#built-in-attributes-index">Built-in attributes</a></li>
<li><a href="procedural-macros.html#attribute-macros">Macro attributes</a></li>
<li><a href="procedural-macros.html#derive-macro-helper-attributes">Derive macro helper attributes</a></li>
<li><a href="attributes.html#tool-attributes">Tool attributes</a></li>
</ul>
<p>Attributes may be applied to many things in the language:</p>
<ul>
<li>All <a href="items.html">item declarations</a> accept outer attributes while <a href="items/external-blocks.html">external blocks</a>,
<a href="items/functions.html">functions</a>, <a href="items/implementations.html">implementations</a>, and <a href="items/modules.html">modules</a> accept inner attributes.</li>
<li>Most <a href="statements.html">statements</a> accept outer attributes (see <a href="expressions.html#expression-attributes">Expression Attributes</a> for
limitations on expression statements).</li>
<li><a href="expressions/block-expr.html">Block expressions</a> accept outer and inner attributes, but only when they are
the outer expression of an <a href="statements.html#expression-statements">expression statement</a> or the final expression of
another block expression.</li>
<li><a href="items/enumerations.html">Enum</a> variants and <a href="items/structs.html">struct</a> and <a href="items/unions.html">union</a> fields accept outer attributes.</li>
<li><a href="expressions/match-expr.html">Match expression arms</a> accept outer attributes.</li>
<li><a href="items/generics.html">Generic lifetime or type parameter</a> accept outer attributes.</li>
<li>Expressions accept outer attributes in limited situations, see <a href="expressions.html#expression-attributes">Expression
Attributes</a> for details.</li>
</ul>
<p>Some examples of attributes:</p>
<pre><pre class="playpen"><code class="language-rust">
# #![allow(unused_variables)]
#fn main() {
// General metadata applied to the enclosing module or crate.
#![crate_type = &quot;lib&quot;]

// A function marked as a unit test
#[test]
fn test_foo() {
    /* ... */
}

// A conditionally-compiled module
#[cfg(target_os = &quot;linux&quot;)]
mod bar {
    /* ... */
}

// A lint attribute used to suppress a warning/error
#[allow(non_camel_case_types)]
type int8_t = i8;

// Inner attribute applies to the entire function.
fn some_unused_variables() {
  #![allow(unused_variables)]

  let x = ();
  let y = ();
  let z = ();
}
#}</code></pre></pre>
<a class="header" href="attributes.html#meta-item-attribute-syntax" id="meta-item-attribute-syntax"><h2>Meta Item Attribute Syntax</h2></a>
<p>A &quot;meta item&quot; is the syntax used for the <em>Attr</em> rule by most <a href="attributes.html#built-in-attributes-index">built-in
attributes</a> and the <a href="macros-by-example.html"><code>meta</code> macro fragment specifier</a>. It has the following
grammar:</p>
<blockquote>
<p><strong><sup>Syntax</sup></strong><br />
<em>MetaItem</em> :<br />
      <a href="paths.html#simple-paths"><em>SimplePath</em></a><br />
   | <a href="paths.html#simple-paths"><em>SimplePath</em></a> <code>=</code> <a href="expressions/literal-expr.html"><em>LiteralExpression</em></a><sub><em>without suffix</em></sub><br />
   | <a href="paths.html#simple-paths"><em>SimplePath</em></a> <code>(</code> <em>MetaSeq</em><sup>?</sup> <code>)</code></p>
<p><em>MetaSeq</em> :<br />
   <em>MetaItemInner</em> ( <code>,</code> MetaItemInner )<sup>*</sup> <code>,</code><sup>?</sup></p>
<p><em>MetaItemInner</em> :<br />
      <em>MetaItem</em><br />
   | <a href="expressions/literal-expr.html"><em>LiteralExpression</em></a><sub><em>without suffix</em></sub></p>
</blockquote>
<p>Literal expressions in meta items must not include integer or float type
suffixes.</p>
<p>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:</p>
<blockquote>
<p><strong><sup>Syntax</sup></strong><br />
<em>MetaWord</em>:<br />
   <a href="identifiers.html">IDENTIFIER</a></p>
<p><em>MetaNameValueStr</em>:<br />
   <a href="identifiers.html">IDENTIFIER</a> <code>=</code> (<a href="tokens.html#string-literals">STRING_LITERAL</a> | <a href="tokens.html#raw-string-literals">RAW_STRING_LITERAL</a>)</p>
<p><em>MetaListPaths</em>:<br />
   <a href="identifiers.html">IDENTIFIER</a> <code>(</code> ( <a href="paths.html#simple-paths"><em>SimplePath</em></a> (<code>,</code> <a href="paths.html#simple-paths"><em>SimplePath</em></a>)* <code>,</code><sup>?</sup> )<sup>?</sup> <code>)</code></p>
<p><em>MetaListIdents</em>:<br />
   <a href="identifiers.html">IDENTIFIER</a> <code>(</code> ( <a href="identifiers.html">IDENTIFIER</a> (<code>,</code> <a href="identifiers.html">IDENTIFIER</a>)* <code>,</code><sup>?</sup> )<sup>?</sup> <code>)</code></p>
<p><em>MetaListNameValueStr</em>:<br />
   <a href="identifiers.html">IDENTIFIER</a> <code>(</code> ( <em>MetaNameValueStr</em> (<code>,</code> <em>MetaNameValueStr</em>)* <code>,</code><sup>?</sup> )<sup>?</sup> <code>)</code></p>
</blockquote>
<p>Some examples of meta items are:</p>
<table><thead><tr><th>Style </th><th> Example</th></tr></thead><tbody>
<tr><td><em>MetaWord</em> </td><td> <code>no_std</code></td></tr>
<tr><td><em>MetaNameValueStr</em> </td><td> <code>doc = &quot;example&quot;</code></td></tr>
<tr><td><em>MetaListPaths</em> </td><td> <code>allow(unused, clippy::inline_always)</code></td></tr>
<tr><td><em>MetaListIdents</em> </td><td> <code>macro_use(foo, bar)</code></td></tr>
<tr><td><em>MetaListNameValueStr</em> </td><td> <code>link(name = &quot;CoreFoundation&quot;, kind = &quot;framework&quot;)</code></td></tr>
</tbody></table>
<a class="header" href="attributes.html#active-and-inert-attributes" id="active-and-inert-attributes"><h2>Active and inert attributes</h2></a>
<p>An attribute is either active or inert. During attribute processing, <em>active
attributes</em> remove themselves from the thing they are on while <em>inert attributes</em>
stay on.</p>
<p>The <a href="conditional-compilation.html#the-cfg-attribute"><code>cfg</code></a> and <a href="conditional-compilation.html#the-cfg_attr-attribute"><code>cfg_attr</code></a> attributes are active. The <a href="attributes/testing.html#the-test-attribute"><code>test</code></a> attribute is
inert when compiling for tests and active otherwise. <a href="procedural-macros.html#attribute-macros">Attribute macros</a> are
active. All other attributes are inert.</p>
<a class="header" href="attributes.html#tool-attributes" id="tool-attributes"><h2>Tool attributes</h2></a>
<p>The compiler may allow attributes for external tools where each tool resides
in its own namespace. 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.</p>
<p>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.</p>
<p>Tool attributes are not available if the <a href="items/modules.html#prelude-items"><code>no_implicit_prelude</code></a> attribute is
used.</p>
<pre><pre class="playpen"><code class="language-rust">
# #![allow(unused_variables)]
#fn main() {
// Tells the rustfmt tool to not format the following element.
#[rustfmt::skip]
struct S {
}

// Controls the &quot;cyclomatic complexity&quot; threshold for the clippy tool.
#[clippy::cyclomatic_complexity = &quot;100&quot;]
pub fn f() {}
#}</code></pre></pre>
<blockquote>
<p>Note: <code>rustc</code> currently recognizes the tools &quot;clippy&quot; and &quot;rustfmt&quot;.</p>
</blockquote>
<a class="header" href="attributes.html#built-in-attributes-index" id="built-in-attributes-index"><h2>Built-in attributes index</h2></a>
<p>The following is an index of all built-in attributes.</p>
<ul>
<li>Conditional compilation
<ul>
<li><a href="conditional-compilation.html#the-cfg-attribute"><code>cfg</code></a> — Controls conditional compilation.</li>
<li><a href="conditional-compilation.html#the-cfg_attr-attribute"><code>cfg_attr</code></a> — Conditionally includes attributes.</li>
</ul>
</li>
<li>Testing
<ul>
<li><a href="attributes/testing.html#the-test-attribute"><code>test</code></a> — Marks a function as a test.</li>
<li><a href="attributes/testing.html#the-ignore-attribute"><code>ignore</code></a> — Disables a test function.</li>
<li><a href="attributes/testing.html#the-should_panic-attribute"><code>should_panic</code></a> — Indicates a test should generate a panic.</li>
</ul>
</li>
<li>Derive
<ul>
<li><a href="attributes/derive.html"><code>derive</code></a> — Automatic trait implementations.</li>
</ul>
</li>
<li>Macros
<ul>
<li><a href="macros-by-example.html#path-based-scope"><code>macro_export</code></a> — Exports a <code>macro_rules</code> macro for cross-crate usage.</li>
<li><a href="macros-by-example.html#the-macro_use-attribute"><code>macro_use</code></a> — Expands macro visibility, or imports macros from other
crates.</li>
<li><a href="procedural-macros.html#function-like-procedural-macros"><code>proc_macro</code></a> — Defines a function-like macro.</li>
<li><a href="procedural-macros.html#derive-macros"><code>proc_macro_derive</code></a> — Defines a derive macro.</li>
<li><a href="procedural-macros.html#attribute-macros"><code>proc_macro_attribute</code></a> — Defines an attribute macro.</li>
</ul>
</li>
<li>Diagnostics
<ul>
<li><a href="attributes/diagnostics.html#lint-check-attributes"><code>allow</code></a>, <a href="attributes/diagnostics.html#lint-check-attributes"><code>warn</code></a>, <a href="attributes/diagnostics.html#lint-check-attributes"><code>deny</code></a>, <a href="attributes/diagnostics.html#lint-check-attributes"><code>forbid</code></a> — Alters the default lint level.</li>
<li><a href="attributes/diagnostics.html#the-deprecated-attribute"><code>deprecated</code></a> — Generates deprecation notices.</li>
<li><a href="attributes/diagnostics.html#the-must_use-attribute"><code>must_use</code></a> — Generates a lint for unused values.</li>
</ul>
</li>
<li>ABI, linking, symbols, and FFI
<ul>
<li><a href="items/external-blocks.html#the-link-attribute"><code>link</code></a> — Specifies a native library to link with an <code>extern</code> block.</li>
<li><a href="items/external-blocks.html#the-link_name-attribute"><code>link_name</code></a> — Specifies the name of the symbol for functions or statics
in an <code>extern</code> block.</li>
<li><a href="items/extern-crates.html#the-no_link-attribute"><code>no_link</code></a> — Prevents linking an extern crate.</li>
<li><a href="type-layout.html#representations"><code>repr</code></a> — Controls type layout.</li>
<li><a href="linkage.html"><code>crate_type</code></a> — Specifies the type of crate (library, executable, etc.).</li>
<li><a href="crates-and-source-files.html#the-no_main-attribute"><code>no_main</code></a> — Disables emitting the <code>main</code> symbol.</li>
<li><a href="abi.html#the-export_name-attribute"><code>export_name</code></a> — Specifies the exported symbol name for a function or
static.</li>
<li><a href="abi.html#the-link_section-attribute"><code>link_section</code></a> — Specifies the section of an object file to use for a
function or static.</li>
<li><a href="abi.html#the-no_mangle-attribute"><code>no_mangle</code></a> — Disables symbol name encoding.</li>
<li><a href="abi.html#the-used-attribute"><code>used</code></a> — Forces the compiler to keep a static item in the output
object file.</li>
<li><a href="crates-and-source-files.html#the-crate_name-attribute"><code>crate_name</code></a> — Specifies the crate name.</li>
</ul>
</li>
<li>Code generation
<ul>
<li><a href="attributes/codegen.html#the-inline-attribute"><code>inline</code></a> — Hint to inline code.</li>
<li><a href="attributes/codegen.html#the-cold-attribute"><code>cold</code></a> — Hint that a function is unlikely to be called.</li>
<li><a href="attributes/codegen.html#the-no_builtins-attribute"><code>no_builtins</code></a> — Disables use of certain built-in functions.</li>
<li><a href="attributes/codegen.html#the-target_feature-attribute"><code>target_feature</code></a> — Configure platform-specific code generation.</li>
</ul>
</li>
<li>Documentation
<ul>
<li><code>doc</code> — Specifies documentation. See <a href="../rustdoc/the-doc-attribute.html">The Rustdoc Book</a> for more
information. <a href="comments.html#doc-comments">Doc comments</a> are transformed into <code>doc</code> attributes.</li>
</ul>
</li>
<li>Preludes
<ul>
<li><a href="crates-and-source-files.html#preludes-and-no_std"><code>no_std</code></a> — Removes std from the prelude.</li>
<li><a href="items/modules.html#prelude-items"><code>no_implicit_prelude</code></a> — Disables prelude lookups within a module.</li>
</ul>
</li>
<li>Modules
<ul>
<li><a href="items/modules.html#the-path-attribute"><code>path</code></a> — Specifies the filename for a module.</li>
</ul>
</li>
<li>Limits
<ul>
<li><a href="attributes/limits.html#the-recursion_limit-attribute"><code>recursion_limit</code></a> — Sets the maximum recursion limit for certain
compile-time operations.</li>
<li><a href="attributes/limits.html#the-type_length_limit-attribute"><code>type_length_limit</code></a> — Sets the maximum size of a polymorphic type.</li>
</ul>
</li>
<li>Runtime
<ul>
<li><a href="runtime.html#the-panic_handler-attribute"><code>panic_handler</code></a> — Sets the function to handle panics.</li>
<li><a href="runtime.html#the-global_allocator-attribute"><code>global_allocator</code></a> — Sets the global memory allocator.</li>
<li><a href="runtime.html#the-windows_subsystem-attribute"><code>windows_subsystem</code></a> — Specifies the windows subsystem to link with.</li>
</ul>
</li>
<li>Features
<ul>
<li><code>feature</code> — Used to enable unstable or experimental compiler features. See
<a href="../unstable-book/index.html">The Unstable Book</a> for features implemented in <code>rustc</code>.</li>
</ul>
</li>
</ul>

                    </main>

                    <nav class="nav-wrapper" aria-label="Page navigation">
                        <!-- Mobile navigation buttons -->
                        
                            <a rel="prev" href="visibility-and-privacy.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
                                <i class="fa fa-angle-left"></i>
                            </a>
                        

                        
                            <a rel="next" href="attributes/testing.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
                                <i class="fa fa-angle-right"></i>
                            </a>
                        

                        <div style="clear: both"></div>
                    </nav>
                </div>
            </div>

            <nav class="nav-wide-wrapper" aria-label="Page navigation">
                
                    <a href="visibility-and-privacy.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
                        <i class="fa fa-angle-left"></i>
                    </a>
                

                
                    <a href="attributes/testing.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
                        <i class="fa fa-angle-right"></i>
                    </a>
                
            </nav>

        </div>

        

        

        

        

        
        <script src="searchindex.js" type="text/javascript" charset="utf-8"></script>
        
        
        <script src="elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
        <script src="mark.min.js" type="text/javascript" charset="utf-8"></script>
        <script src="searcher.js" type="text/javascript" charset="utf-8"></script>
        

        <script src="clipboard.min.js" type="text/javascript" charset="utf-8"></script>
        <script src="highlight.js" type="text/javascript" charset="utf-8"></script>
        <script src="book.js" type="text/javascript" charset="utf-8"></script>

        <!-- Custom JS scripts -->
        

    </body>
</html>