<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>README.md - +/feature-unification-test @ main</title>
<meta name="description" content="README.md in +/feature-unification-test at main.">
<meta property="og:title" content="README.md - +/feature-unification-test @ main">
<meta property="og:description" content="README.md in +/feature-unification-test at main.">
<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="main" data-tip="1382ea7423eef07407a839360c8d50937da05070">
<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>+/feature-unification-test</h1>
</div>
<pre class="clone">git clone https://git.julia.blue/+/feature-unification-test</pre>
</header>
<p class="snapshot-commit"><span class="commit-author">Julia Ryan</span><span class="commit-message" data-commit="1382ea7423eef07407a839360c8d50937da05070">Initial commit</span><span class="snapshot-sha sha" data-commit="1382ea7423eef07407a839360c8d50937da05070">1382ea7</span><time datetime="2025-03-26T13:24:43-07:00" title="2025-03-26 13:24:43 -0700">2025-03-26</time></p>
<header class="topbar"><details class="switcher"><summary>main</summary><div class="menu"><strong>branches</strong><a class="current" href="/%2B/feature-unification-test/ref/main/">main</a><a class="all" href="/%2B/feature-unification-test/refs">all refs →</a></div></details><nav class="crumbs"><a href="/%2B/feature-unification-test/">feature-unification-test</a> / <span class="cur">README.md</span></nav>
<span class="view-stats"><span>747 B</span><span>16 lines</span></span><span class="actions"><a class="raw" href="/%2B/feature-unification-test/raw/85af05eb983939708c3e2c0d28ff31246edfcd18/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"><p>Feature unification lets you access an API you shouldn't be able to.</p>
<p>This workspace has a root binary which depends on 2 crates, each of which depend on serde but only one of them adds the <code>derive</code> feature.</p>
<p>building the whole workspace (including dep-b) succeeds, and uses a single copy of serde with serde-derive enabled (because dep-a needed it):</p>
<pre class="language-bash"><a-f>cargo</a-f> b</pre>
<p>... but building just <code>dep-b</code> fails because it's using <code>serde::Deserialize</code> without enabling the <code>derive</code> feature</p>
<pre class="language-bash"><a-f>cargo</a-f> b <a-co>-p</a-co> dep-b</pre>
<p>this behavior was quite surprising to me. I assumed that even in the face of feature unification there was some way that the compiler was made aware of which features your crate was actually "allowed" to use, but that's not the case.</p>
</section><div class="code-panel"><pre class="code src language-markdown"><span class="code-line"><a class="ln" id="L1" href="#L1">1</a><span class="code-text">Feature unification lets you access an API you shouldn&#39;t be able to.</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 workspace has a root binary which depends on 2 crates, each of which depend on serde but only one of them adds the `derive` feature.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L4" href="#L4">4</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L5" href="#L5">5</a><span class="code-text">building the whole workspace (including dep-b) succeeds, and uses a single copy of serde with serde-derive enabled (because dep-a needed it):</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L6" href="#L6">6</a><span class="code-text"><a-p>```</a-p><a-tl>sh</a-tl></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L7" href="#L7">7</a><span class="code-text"><a-p>cargo b</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L8" href="#L8">8</a><span class="code-text"><a-p>```</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L9" href="#L9">9</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L10" href="#L10">10</a><span class="code-text"><a-p>... but building just `dep-b` fails because it&#39;s using `serde::Deserialize` without enabling the `derive` feature</a-p></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"><a-p>```</a-p><a-tl>sh</a-tl></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L13" href="#L13">13</a><span class="code-text"><a-p>cargo b -p dep-b</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L14" href="#L14">14</a><span class="code-text"><a-p>```</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L15" href="#L15">15</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L16" href="#L16">16</a><span class="code-text">this behavior was quite surprising to me. I assumed that even in the face of feature unification there was some way that the compiler was made aware of which features your crate was actually &quot;allowed&quot; to use, but that&#39;s not the case.</span></span></pre></div></div>
</main>
</body>
</html>
