<p>A wrapper around the procedural macro API of the compiler’s <ahref="https://doc.rust-lang.org/proc_macro/"><code>proc_macro</code></a>
crate. This library serves two purposes:</p>
<ul>
<li>
<p><strong>Bring proc-macro-like functionality to other contexts like build.rs and
main.rs.</strong> Types from <code>proc_macro</code> are entirely specific to procedural
macros and cannot ever exist in code outside of a procedural macro.
Meanwhile <code>proc_macro2</code> types may exist anywhere including non-macro code.
By developing foundational libraries like <ahref="https://github.com/dtolnay/syn">syn</a> and <ahref="https://github.com/dtolnay/quote">quote</a> against
<code>proc_macro2</code> rather than <code>proc_macro</code>, the procedural macro ecosystem
becomes easily applicable to many other use cases and we avoid
reimplementing non-macro equivalents of those libraries.</p>
</li>
<li>
<p><strong>Make procedural macros unit testable.</strong> As a consequence of being
specific to procedural macros, nothing that uses <code>proc_macro</code> can be
executed from a unit test. In order for helper libraries or components of
a macro to be testable in isolation, they must be implemented using
<p>If parsing with <ahref="https://github.com/dtolnay/syn">Syn</a>, you’ll use <ahref="https://docs.rs/syn/2.0/syn/macro.parse_macro_input.html"><code>parse_macro_input!</code></a> instead to
propagate parse errors correctly back to the compiler when parsing fails.</p>
</div></details><h2id="modules"class="section-header">Modules<ahref="#modules"class="anchor">§</a></h2><ulclass="item-table"><li><divclass="item-name"><aclass="mod"href="extra/index.html"title="mod proc_macro2::extra">extra</a></div><divclass="desc docblock-short">Items which do not have a correspondence to any API in the proc_macro crate,
but are necessary to include in proc-macro2.</div></li><li><divclass="item-name"><aclass="mod"href="token_stream/index.html"title="mod proc_macro2::token_stream">token_stream</a></div><divclass="desc docblock-short">Public implementation details for the <code>TokenStream</code> type, such as iterators.</div></li></ul><h2id="structs"class="section-header">Structs<ahref="#structs"class="anchor">§</a></h2><ulclass="item-table"><li><divclass="item-name"><aclass="struct"href="struct.Group.html"title="struct proc_macro2::Group">Group</a></div><divclass="desc docblock-short">A delimited token stream.</div></li><li><divclass="item-name"><aclass="struct"href="struct.Ident.html"title="struct proc_macro2::Ident">Ident</a></div><divclass="desc docblock-short">A word of Rust code, which may be a keyword or legal variable name.</div></li><li><divclass="item-name"><aclass="struct"href="struct.LexError.html"title="struct proc_macro2::LexError">LexError</a></div><divclass="desc docblock-short">Error returned from <code>TokenStream::from_str</code>.</div></li><li><divclass="item-name"><aclass="struct"href="struct.Literal.html"title="struct proc_macro2::Literal">Literal</a></div><divclass="desc docblock-short">A literal string (<code>"hello"</code>), byte string (<code>b"hello"</code>), character (<code>'a'</code>),
a suffix (<code>1</code>, <code>1u8</code>, <code>2.3</code>, <code>2.3f32</code>).</div></li><li><divclass="item-name"><aclass="struct"href="struct.Punct.html"title="struct proc_macro2::Punct">Punct</a></div><divclass="desc docblock-short">A <code>Punct</code> is a single punctuation character like <code>+</code>, <code>-</code> or <code>#</code>.</div></li><li><divclass="item-name"><aclass="struct"href="struct.Span.html"title="struct proc_macro2::Span">Span</a></div><divclass="desc docblock-short">A region of source code, along with macro expansion information.</div></li><li><divclass="item-name"><aclass="struct"href="struct.TokenStream.html"title="struct proc_macro2::TokenStream">TokenStream</a></div><divclass="desc docblock-short">An abstract stream of tokens, or more concretely a sequence of token trees.</div></li></ul><h2id="enums"class="section-header">Enums<ahref="#enums"class="anchor">§</a></h2><ulclass="item-table"><li><divclass="item-name"><aclass="enum"href="enum.Delimiter.html"title="enum proc_macro2::Delimiter">Delimiter</a></div><divclass="desc docblock-short">Describes how a sequence of token trees is delimited.</div></li><li><divclass="item-name"><aclass="enum"href="enum.Spacing.html"title="enum proc_macro2::Spacing">Spacing</a></div><divclass="desc docblock-short">Whether a <code>Punct</code> is followed immediately by another <code>Punct</code> or followed by
another token or whitespace.</div></li><li><divclass="item-name"><aclass="enum"href="enum.TokenTree.html"title="enum proc_macro2::TokenTree">TokenTree</a></div><divclass="desc docblock-short">A single token or a delimited sequence of token trees (e.g. <code>[1, (), ..]</code>).</div></li></ul></section></div></main></body></html>