<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>src/tools/rustc-workspace-hack/README.md - fork/rust @ 1.42.0</title>
<meta name="description" content="src/tools/rustc-workspace-hack/README.md in fork/rust at 1.42.0.">
<meta property="og:title" content="src/tools/rustc-workspace-hack/README.md - fork/rust @ 1.42.0">
<meta property="og:description" content="src/tools/rustc-workspace-hack/README.md in fork/rust at 1.42.0.">
<meta property="og:type" content="website">
<meta property="og:site_name" content="git.julia.blue">
<link rel="stylesheet" href="/css/style.css?v=62">
<script type="module" src="/js/main.js?v=62"></script>
</head>
<body>
<main data-ref="1.42.0" data-tip="b8cedc00407a4c56a3bda1ed605c6fc166655447">
<noscript>
  <div class="callout">
    <p>
      hey! this is a static git repo viewer. commit diffs, file history,
      older commits and other revisions won't load without javascript.
    </p>
    <p>
      you are still able to view source files on branch/tag tips,
      but the experience is degraded.
    </p>
  </div>
</noscript>
<header class="repo"><div>
<h1>fork/rust</h1>
</div>
<pre class="clone">git clone https://git.julia.blue/fork/rust</pre>
</header>
<p class="snapshot-commit"><span class="commit-author">bors</span><span class="commit-message" data-commit="b8cedc00407a4c56a3bda1ed605c6fc166655447">Auto merge of #69854 - pietroalbini:stable-next, r=Centril</span><span class="snapshot-sha sha" data-commit="b8cedc00407a4c56a3bda1ed605c6fc166655447">b8cedc00407</span><time datetime="2020-03-09T22:09:51+00:00" title="2020-03-09 22:09:51 +0000">2020-03-09</time></p>
<header class="topbar"><details class="switcher"><summary>1.42.0</summary><div class="menu"><strong>branches</strong><a href="/fork/rust/ref/master/">master</a><strong>tags</strong><a href="/fork/rust/ref/1.39.0/">1.39.0</a><a href="/fork/rust/ref/1.40.0/">1.40.0</a><a href="/fork/rust/ref/1.41.0/">1.41.0</a><a href="/fork/rust/ref/1.41.1/">1.41.1</a><a class="current" href="/fork/rust/ref/1.42.0/">1.42.0</a><a href="/fork/rust/ref/1.43.0/">1.43.0</a><a href="/fork/rust/ref/1.43.1/">1.43.1</a><a href="/fork/rust/ref/1.44.0/">1.44.0</a><a class="all" href="/fork/rust/refs">all refs →</a></div></details><nav class="crumbs"><a href="/fork/rust/">rust</a> / <a href="/fork/rust/ref/1.42.0/tree/src/">src</a> / <a href="/fork/rust/ref/1.42.0/tree/src/tools/">tools</a> / <a href="/fork/rust/ref/1.42.0/tree/src/tools/rustc-workspace-hack/">rustc-workspace-hack</a> / <span class="cur">README.md</span></nav>
<span class="view-stats"><span>1.3 KiB</span><span>25 lines</span></span><span class="actions"><a class="raw" href="/fork/rust/raw/4a5286fae9c3effd4813838b3130ff35432708bf/src/tools/rustc-workspace-hack/README.md">raw</a></span></header>
<div class="markdown-view"><input type="radio" name="markdown-view" id="markdown-rendered" checked><label for="markdown-rendered">rendered</label><input type="radio" name="markdown-view" id="markdown-code"><label for="markdown-code">code</label><section class="readme rendered"><h1><code>rustc-workspace-hack</code></h1>
<p>This crate is a bit of a hack to make workspaces in rustc work a bit better.
The rationale for this existence is a bit subtle, but the general idea is that
we want commands like <code>./x.py build src/tools/{rls,clippy,cargo}</code> to share as
many dependencies as possible.</p>
<p>Each invocation is a different invocation of Cargo, however. Each time Cargo
runs a build it will re-resolve the dependency graph, notably selecting
different features sometimes for each build.</p>
<p>For example, let's say there's a very deep dependency like <code>num-traits</code> in each
of these builds. For Cargo the <code>num-traits</code>'s <code>default</code> feature is turned off.
In RLS, however, the <code>default</code> feature is turned. This means that building Cargo
and then the RLS will actually build Cargo twice (as a transitive dependency
changed). This is bad!</p>
<p>The goal of this crate is to solve this problem and ensure that the resolved
dependency graph for all of these tools is the same in the various subsets of
each tool, notably enabling the same features of transitive dependencies.</p>
<p>All tools vendored here depend on the <code>rustc-workspace-hack</code> crate on crates.io.
When on crates.io this crate is an empty crate that is just a noop. We override
it, however, in this workspace to this crate here, which means we can control
crates in the dependency graph for each of these tools.</p>
</section><div class="code-panel"><pre class="code src" data-hl="src/tools/rustc-workspace-hack/README.md"><span class="code-line"><a class="ln" id="L1" href="#L1">1</a><span class="code-text"># `rustc-workspace-hack`</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L2" href="#L2">2</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L3" href="#L3">3</a><span class="code-text">This crate is a bit of a hack to make workspaces in rustc work a bit better.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L4" href="#L4">4</a><span class="code-text">The rationale for this existence is a bit subtle, but the general idea is that</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L5" href="#L5">5</a><span class="code-text">we want commands like `./x.py build src/tools/{rls,clippy,cargo}` to share as</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L6" href="#L6">6</a><span class="code-text">many dependencies as possible.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L7" href="#L7">7</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L8" href="#L8">8</a><span class="code-text">Each invocation is a different invocation of Cargo, however. Each time Cargo</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L9" href="#L9">9</a><span class="code-text">runs a build it will re-resolve the dependency graph, notably selecting</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L10" href="#L10">10</a><span class="code-text">different features sometimes for each build.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L11" href="#L11">11</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L12" href="#L12">12</a><span class="code-text">For example, let's say there's a very deep dependency like `num-traits` in each</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L13" href="#L13">13</a><span class="code-text">of these builds. For Cargo the `num-traits`'s `default` feature is turned off.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L14" href="#L14">14</a><span class="code-text">In RLS, however, the `default` feature is turned. This means that building Cargo</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L15" href="#L15">15</a><span class="code-text">and then the RLS will actually build Cargo twice (as a transitive dependency</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L16" href="#L16">16</a><span class="code-text">changed). This is bad!</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L17" href="#L17">17</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L18" href="#L18">18</a><span class="code-text">The goal of this crate is to solve this problem and ensure that the resolved</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L19" href="#L19">19</a><span class="code-text">dependency graph for all of these tools is the same in the various subsets of</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L20" href="#L20">20</a><span class="code-text">each tool, notably enabling the same features of transitive dependencies.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L21" href="#L21">21</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L22" href="#L22">22</a><span class="code-text">All tools vendored here depend on the `rustc-workspace-hack` crate on crates.io.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L23" href="#L23">23</a><span class="code-text">When on crates.io this crate is an empty crate that is just a noop. We override</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L24" href="#L24">24</a><span class="code-text">it, however, in this workspace to this crate here, which means we can control</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L25" href="#L25">25</a><span class="code-text">crates in the dependency graph for each of these tools.</span></span></pre></div></div>
</main>
</body>
</html>
