blob: bfb2b82e170ce68cb23bb93a057a8eb5236224d3 [file] [log] [blame] [edit]
<!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="Canonicalization is the key to constructing a query in the middle of type inference. Ordinarily, it is not possible to store types from type inference in query keys, because they contain references to inference variables whose lifetimes are too short and so forth. Canonicalizing a value T1 using `canonicalize_query` produces two things:"><title>hir::next_solver::infer::canonical - 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-e56847b5.css"><meta name="rustdoc-vars" data-root-path="../../../../" data-static-root-path="../../../../static.files/" data-current-crate="hir" data-themes="" data-resource-suffix="" data-rustdoc-version="1.91.1 (ed61e7d7e 2025-11-07)" data-channel="1.91.1" data-search-js="search-e256b49e.js" data-stringdex-js="stringdex-c3e638e9.js" data-settings-js="settings-c38705f0.js" ><script src="../../../../static.files/storage-e2aeef58.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../../../static.files/main-6dc2a7f3.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"><!--[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="#">Module canonical</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../../../hir/index.html">hir</a><span class="version">0.0.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module canonical</a></h2><h3><a href="#modules">Module Items</a></h3><ul class="block"><li><a href="#modules" title="Modules">Modules</a></li><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#types" title="Type Aliases">Type Aliases</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="../index.html">In hir::<wbr>next_<wbr>solver::<wbr>infer</a></h2></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"><div class="rustdoc-breadcrumbs"><a href="../../../index.html">hir</a>::<wbr><a href="../../index.html">next_solver</a>::<wbr><a href="../index.html">infer</a></div><h1>Module <span>canonical</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"></span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p><strong>Canonicalization</strong> is the key to constructing a query in the
middle of type inference. Ordinarily, it is not possible to store
types from type inference in query keys, because they contain
references to inference variables whose lifetimes are too short
and so forth. Canonicalizing a value T1 using <code>canonicalize_query</code>
produces two things:</p>
<ul>
<li>a value T2 where each unbound inference variable has been
replaced with a <strong>canonical variable</strong>;</li>
<li>a map M (of type <code>CanonicalVarValues</code>) from those canonical
variables back to the original.</li>
</ul>
<p>We can then do queries using T2. These will give back constraints
on the canonical variables which can be translated, using the map
M, into constraints in our source context. This process of
translating the results back is done by the
<code>instantiate_query_result</code> method.</p>
<p>For a more detailed look at what is happening here, check
out the <a href="https://rust-lang.github.io/chalk/book/canonical_queries/canonicalization.html">chapter in the rustc dev guide</a>.</p>
</div></details><h2 id="modules" class="section-header">Modules<a href="#modules" class="anchor">§</a></h2><dl class="item-table"><dt><a class="mod" href="canonicalizer/index.html" title="mod hir::next_solver::infer::canonical::canonicalizer">canonicalizer</a></dt><dd>This module contains code to canonicalize values into a <code>Canonical&lt;'db, T&gt;</code>.</dd><dt><a class="mod" href="instantiate/index.html" title="mod hir::next_solver::infer::canonical::instantiate">instantiate</a></dt><dd>This module contains code to instantiate new values into a
<code>Canonical&lt;'db, T&gt;</code>.</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.QueryRegionConstraints.html" title="struct hir::next_solver::infer::canonical::QueryRegionConstraints">Query<wbr>Region<wbr>Constraints</a></dt><dt><a class="struct" href="struct.QueryResponse.html" title="struct hir::next_solver::infer::canonical::QueryResponse">Query<wbr>Response</a></dt><dd>After we execute a query with a canonicalized key, we get back a
<code>Canonical&lt;QueryResponse&lt;..&gt;&gt;</code>. You can use
<code>instantiate_query_result</code> to access the data in this result.</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.QueryOutlivesConstraint.html" title="type hir::next_solver::infer::canonical::QueryOutlivesConstraint">Query<wbr>Outlives<wbr>Constraint</a></dt></dl></section></div></main></body></html>