| <!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="`hir_expand` deals with macro expansion."><title>hir_expand - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="hir_expand" data-themes="" data-resource-suffix="" data-rustdoc-version="1.92.0 (ded5c06cf 2025-12-08)" data-channel="1.92.0" data-search-js="search-d69d8955.js" data-stringdex-js="stringdex-c3e638e9.js" data-settings-js="settings-c38705f0.js" ><script src="../static.files/storage-e2aeef58.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-ce535bd0.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">Crate hir_expand</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../hir_expand/index.html">hir_<wbr>expand</a><span class="version">0.0.0</span></h2></div><div class="sidebar-elems"><ul class="block"><li><a id="all-types" href="all.html">All Items</a></li></ul><section id="rustdoc-toc"><h3><a href="#reexports">Crate Items</a></h3><ul class="block"><li><a href="#reexports" title="Re-exports">Re-exports</a></li><li><a href="#modules" title="Modules">Modules</a></li><li><a href="#macros" title="Macros">Macros</a></li><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#enums" title="Enums">Enums</a></li><li><a href="#traits" title="Traits">Traits</a></li><li><a href="#functions" title="Functions">Functions</a></li><li><a href="#types" title="Type Aliases">Type Aliases</a></li></ul></section><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><h1>Crate <span>hir_<wbr>expand</span> <button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/hir_expand/lib.rs.html#1-1152">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p><code>hir_expand</code> deals with macro expansion.</p> |
| <p>Specifically, it implements a concept of <code>MacroFile</code> – a file whose syntax |
| tree originates not from the text of some <code>FileId</code>, but from some macro |
| expansion.</p> |
| </div></details><h2 id="reexports" class="section-header">Re-exports<a href="#reexports" class="anchor">§</a></h2><dl class="item-table reexports"><dt id="reexport.AstId"><code>pub use crate::files::<a class="type" href="files/type.AstId.html" title="type hir_expand::files::AstId">AstId</a>;</code></dt><dt id="reexport.ErasedAstId"><code>pub use crate::files::<a class="type" href="files/type.ErasedAstId.html" title="type hir_expand::files::ErasedAstId">ErasedAstId</a>;</code></dt><dt id="reexport.FileRange"><code>pub use crate::files::<a class="type" href="files/type.FileRange.html" title="type hir_expand::files::FileRange">FileRange</a>;</code></dt><dt id="reexport.InFile"><code>pub use crate::files::<a class="type" href="files/type.InFile.html" title="type hir_expand::files::InFile">InFile</a>;</code></dt><dt id="reexport.InMacroFile"><code>pub use crate::files::<a class="type" href="files/type.InMacroFile.html" title="type hir_expand::files::InMacroFile">InMacroFile</a>;</code></dt><dt id="reexport.InRealFile"><code>pub use crate::files::<a class="type" href="files/type.InRealFile.html" title="type hir_expand::files::InRealFile">InRealFile</a>;</code></dt><dt id="reexport.intern"><code>pub use intern;</code></dt><dt id="reexport.tt"><code>pub use tt;</code></dt></dl><h2 id="modules" class="section-header">Modules<a href="#modules" class="anchor">§</a></h2><dl class="item-table"><dt><a class="mod" href="attrs/index.html" title="mod hir_expand::attrs">attrs</a></dt><dd>Defines the basics of attributes lowering.</dd><dt><a class="mod" href="builtin/index.html" title="mod hir_expand::builtin">builtin</a></dt><dd>Builtin macros and attributes</dd><dt><a class="mod" href="change/index.html" title="mod hir_expand::change">change</a></dt><dd>Defines a unit of change that can applied to the database to get the next |
| state. Changes are transactional.</dd><dt><a class="mod" href="db/index.html" title="mod hir_expand::db">db</a></dt><dd>Defines database & queries for macro expansion.</dd><dt><a class="mod" href="declarative/index.html" title="mod hir_expand::declarative">declarative</a></dt><dd>Compiled declarative macro expanders (<code>macro_rules!</code> and <code>macro</code>)</dd><dt><a class="mod" href="eager/index.html" title="mod hir_expand::eager">eager</a></dt><dd>Eager expansion related utils</dd><dt><a class="mod" href="files/index.html" title="mod hir_expand::files">files</a></dt><dd>Things to wrap other things in file ids.</dd><dt><a class="mod" href="hygiene/index.html" title="mod hir_expand::hygiene">hygiene</a></dt><dd>Machinery for hygienic macros.</dd><dt><a class="mod" href="inert_attr_macro/index.html" title="mod hir_expand::inert_attr_macro">inert_<wbr>attr_<wbr>macro</a></dt><dd>Builtin attributes resolved by nameres.</dd><dt><a class="mod" href="mod_path/index.html" title="mod hir_expand::mod_path">mod_<wbr>path</a></dt><dd>A lowering for <code>use</code>-paths (more generally, paths without angle-bracketed segments).</dd><dt><a class="mod" href="name/index.html" title="mod hir_expand::name">name</a></dt><dd>See <a href="name/struct.Name.html" title="struct hir_expand::name::Name"><code>Name</code></a>.</dd><dt><a class="mod" href="proc_macro/index.html" title="mod hir_expand::proc_macro">proc_<wbr>macro</a></dt><dd>Proc Macro Expander stuff</dd><dt><a class="mod" href="span_map/index.html" title="mod hir_expand::span_map">span_<wbr>map</a></dt><dd>Span maps for real files and macro expansions.</dd></dl><h2 id="macros" class="section-header">Macros<a href="#macros" class="anchor">§</a></h2><dl class="item-table"><dt><a class="macro" href="macro.__known_path.html" title="macro hir_expand::__known_path">__<wbr>known_<wbr>path</a></dt><dt><a class="macro" href="macro.__path.html" title="macro hir_expand::__path">__path</a></dt><dt><a class="macro" href="macro.__tool_path.html" title="macro hir_expand::__tool_path">__<wbr>tool_<wbr>path</a></dt><dt><a class="macro" href="macro.impl_intern_lookup.html" title="macro hir_expand::impl_intern_lookup">impl_<wbr>intern_<wbr>lookup</a></dt><dt><a class="macro" href="macro.quote.html" title="macro hir_expand::quote">quote</a></dt><dd>FIXME: |
| It probably should implement in proc-macro</dd></dl><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><dl class="item-table"><dt><a class="struct" href="struct.AttrMacroAttrIds.html" title="struct hir_expand::AttrMacroAttrIds">Attr<wbr>Macro<wbr>Attr<wbr>Ids</a></dt><dt><a class="struct" href="struct.DeclarativeMacro.html" title="struct hir_expand::DeclarativeMacro">Declarative<wbr>Macro</a></dt><dd>This struct contains AST for a single <code>macro_rules</code> definition. What might |
| be very confusing is that AST has almost exactly the same shape as |
| <code>tt::TokenTree</code>, but there’s a crucial difference: in macro rules, <code>$ident</code> |
| and <code>$()*</code> have special meaning (see <code>Var</code> and <code>Repeat</code> data structures)</dd><dt><a class="struct" href="struct.EagerCallInfo.html" title="struct hir_expand::EagerCallInfo">Eager<wbr>Call<wbr>Info</a></dt><dt><a class="struct" href="struct.EditionedFileId.html" title="struct hir_expand::EditionedFileId">Editioned<wbr>File<wbr>Id</a></dt><dt><a class="struct" href="struct.ExpandError.html" title="struct hir_expand::ExpandError">Expand<wbr>Error</a></dt><dt><a class="struct" href="struct.ExpansionInfo.html" title="struct hir_expand::ExpansionInfo">Expansion<wbr>Info</a></dt><dd>ExpansionInfo mainly describes how to map text range between src and expanded macro</dd><dt><a class="struct" href="struct.MacroCallId.html" title="struct hir_expand::MacroCallId">Macro<wbr>Call<wbr>Id</a></dt><dt><a class="struct" href="struct.MacroCallLoc.html" title="struct hir_expand::MacroCallLoc">Macro<wbr>Call<wbr>Loc</a></dt><dt><a class="struct" href="struct.MacroCallStyles.html" title="struct hir_expand::MacroCallStyles">Macro<wbr>Call<wbr>Styles</a></dt><dd>A set of <code>MacroCallStyle</code> values, allowing macros to indicate that |
| they support more than one style.</dd><dt><a class="struct" href="struct.MacroDefId.html" title="struct hir_expand::MacroDefId">Macro<wbr>DefId</a></dt><dt><a class="struct" href="struct.RenderedExpandError.html" title="struct hir_expand::RenderedExpandError">Rendered<wbr>Expand<wbr>Error</a></dt><dt><a class="struct" href="struct.ValueResult.html" title="struct hir_expand::ValueResult">Value<wbr>Result</a></dt></dl><h2 id="enums" class="section-header">Enums<a href="#enums" class="anchor">§</a></h2><dl class="item-table"><dt><a class="enum" href="enum.ExpandErrorKind.html" title="enum hir_expand::ExpandErrorKind">Expand<wbr>Error<wbr>Kind</a></dt><dt><a class="enum" href="enum.ExpandTo.html" title="enum hir_expand::ExpandTo">Expand<wbr>To</a></dt><dd>In Rust, macros expand token trees to token trees. When we want to turn a |
| token tree into an AST node, we need to figure out what kind of AST node we |
| want: something like <code>foo</code> can be a type, an expression, or a pattern.</dd><dt><a class="enum" href="enum.HirFileId.html" title="enum hir_expand::HirFileId">HirFile<wbr>Id</a></dt><dt><a class="enum" href="enum.MacroCallKind.html" title="enum hir_expand::MacroCallKind">Macro<wbr>Call<wbr>Kind</a></dt><dt><a class="enum" href="enum.MacroCallStyle.html" title="enum hir_expand::MacroCallStyle">Macro<wbr>Call<wbr>Style</a></dt><dt><a class="enum" href="enum.MacroDefKind.html" title="enum hir_expand::MacroDefKind">Macro<wbr>DefKind</a></dt><dt><a class="enum" href="enum.MacroKind.html" title="enum hir_expand::MacroKind">Macro<wbr>Kind</a></dt></dl><h2 id="traits" class="section-header">Traits<a href="#traits" class="anchor">§</a></h2><dl class="item-table"><dt><a class="trait" href="trait.Intern.html" title="trait hir_expand::Intern">Intern</a></dt><dt><a class="trait" href="trait.Lookup.html" title="trait hir_expand::Lookup">Lookup</a></dt></dl><h2 id="functions" class="section-header">Functions<a href="#functions" class="anchor">§</a></h2><dl class="item-table"><dt><a class="fn" href="fn.check_cfg_attr_value.html" title="fn hir_expand::check_cfg_attr_value">check_<wbr>cfg_<wbr>attr_<wbr>value</a></dt><dt><a class="fn" href="fn.map_node_range_up.html" title="fn hir_expand::map_node_range_up">map_<wbr>node_<wbr>range_<wbr>up</a></dt><dd>Maps up the text range out of the expansion hierarchy back into the original file its from.</dd><dt><a class="fn" href="fn.map_node_range_up_rooted.html" title="fn hir_expand::map_node_range_up_rooted">map_<wbr>node_<wbr>range_<wbr>up_<wbr>rooted</a></dt><dd>Maps up the text range out of the expansion hierarchy back into the original file its from only |
| considering the root spans contained. |
| Unlike <a href="fn.map_node_range_up.html" title="fn hir_expand::map_node_range_up"><code>map_node_range_up</code></a>, this will not return <code>None</code> if any anchors or syntax contexts differ.</dd><dt><a class="fn" href="fn.prettify_macro_expansion.html" title="fn hir_expand::prettify_macro_expansion">prettify_<wbr>macro_<wbr>expansion</a></dt><dd>Inserts whitespace and replaces <code>$crate</code> in macro expansions.</dd><dt><a class="fn" href="fn.span_for_offset.html" title="fn hir_expand::span_for_offset">span_<wbr>for_<wbr>offset</a></dt><dd>Looks up the span at the given offset.</dd></dl><h2 id="types" class="section-header">Type Aliases<a href="#types" class="anchor">§</a></h2><dl class="item-table"><dt><a class="type" href="type.ExpandResult.html" title="type hir_expand::ExpandResult">Expand<wbr>Result</a></dt></dl></section></div></main></body></html> |