357 lines
19 KiB
HTML
357 lines
19 KiB
HTML
<!DOCTYPE HTML>
|
|
<html lang="en" class="light sidebar-visible" dir="ltr">
|
|
<head>
|
|
<!-- Book generated using mdBook -->
|
|
<meta charset="UTF-8">
|
|
<title>Stabilizing Features - Rust Compiler Development Guide</title>
|
|
|
|
|
|
<!-- Custom HTML head -->
|
|
|
|
<meta name="description" content="A guide to developing the Rust compiler (rustc)">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<meta name="theme-color" content="#ffffff">
|
|
|
|
<link rel="icon" href="favicon.svg">
|
|
<link rel="shortcut icon" href="favicon.png">
|
|
<link rel="stylesheet" href="css/variables.css">
|
|
<link rel="stylesheet" href="css/general.css">
|
|
<link rel="stylesheet" href="css/chrome.css">
|
|
<link rel="stylesheet" href="css/print.css" media="print">
|
|
|
|
<!-- Fonts -->
|
|
<link rel="stylesheet" href="FontAwesome/css/font-awesome.css">
|
|
<link rel="stylesheet" href="fonts/fonts.css">
|
|
|
|
<!-- Highlight.js Stylesheets -->
|
|
<link rel="stylesheet" id="highlight-css" href="highlight.css">
|
|
<link rel="stylesheet" id="tomorrow-night-css" href="tomorrow-night.css">
|
|
<link rel="stylesheet" id="ayu-highlight-css" href="ayu-highlight.css">
|
|
|
|
<!-- Custom theme stylesheets -->
|
|
|
|
|
|
<!-- Provide site root and default themes to javascript -->
|
|
<script>
|
|
const path_to_root = "";
|
|
const default_light_theme = "light";
|
|
const default_dark_theme = "navy";
|
|
</script>
|
|
<!-- Start loading toc.js asap -->
|
|
<script src="toc.js"></script>
|
|
</head>
|
|
<body>
|
|
<div id="body-container">
|
|
<!-- Work around some values being stored in localStorage wrapped in quotes -->
|
|
<script>
|
|
try {
|
|
let theme = localStorage.getItem('mdbook-theme');
|
|
let sidebar = localStorage.getItem('mdbook-sidebar');
|
|
|
|
if (theme.startsWith('"') && theme.endsWith('"')) {
|
|
localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
|
|
}
|
|
|
|
if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
|
|
localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
|
|
}
|
|
} catch (e) { }
|
|
</script>
|
|
|
|
<!-- Set the theme before any content is loaded, prevents flash -->
|
|
<script>
|
|
const default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? default_dark_theme : default_light_theme;
|
|
let theme;
|
|
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
|
|
if (theme === null || theme === undefined) { theme = default_theme; }
|
|
const html = document.documentElement;
|
|
html.classList.remove('light')
|
|
html.classList.add(theme);
|
|
html.classList.add("js");
|
|
</script>
|
|
|
|
<input type="checkbox" id="sidebar-toggle-anchor" class="hidden">
|
|
|
|
<!-- Hide / unhide sidebar before it is displayed -->
|
|
<script>
|
|
let sidebar = null;
|
|
const sidebar_toggle = document.getElementById("sidebar-toggle-anchor");
|
|
if (document.body.clientWidth >= 1080) {
|
|
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
|
|
sidebar = sidebar || 'visible';
|
|
} else {
|
|
sidebar = 'hidden';
|
|
}
|
|
sidebar_toggle.checked = sidebar === 'visible';
|
|
html.classList.remove('sidebar-visible');
|
|
html.classList.add("sidebar-" + sidebar);
|
|
</script>
|
|
|
|
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
|
|
<!-- populated by js -->
|
|
<mdbook-sidebar-scrollbox class="sidebar-scrollbox"></mdbook-sidebar-scrollbox>
|
|
<noscript>
|
|
<iframe class="sidebar-iframe-outer" src="toc.html"></iframe>
|
|
</noscript>
|
|
<div id="sidebar-resize-handle" class="sidebar-resize-handle">
|
|
<div class="sidebar-resize-indicator"></div>
|
|
</div>
|
|
</nav>
|
|
|
|
<div id="page-wrapper" class="page-wrapper">
|
|
|
|
<div class="page">
|
|
<div id="menu-bar-hover-placeholder"></div>
|
|
<div id="menu-bar" class="menu-bar sticky">
|
|
<div class="left-buttons">
|
|
<label id="sidebar-toggle" class="icon-button" for="sidebar-toggle-anchor" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
|
|
<i class="fa fa-bars"></i>
|
|
</label>
|
|
<button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
|
|
<i class="fa fa-paint-brush"></i>
|
|
</button>
|
|
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
|
|
<li role="none"><button role="menuitem" class="theme" id="default_theme">Auto</button></li>
|
|
<li role="none"><button role="menuitem" class="theme" id="light">Light</button></li>
|
|
<li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
|
|
<li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
|
|
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
|
|
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
|
|
</ul>
|
|
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
|
|
<i class="fa fa-search"></i>
|
|
</button>
|
|
</div>
|
|
|
|
<h1 class="menu-title">Rust Compiler Development Guide</h1>
|
|
|
|
<div class="right-buttons">
|
|
<a href="print.html" title="Print this book" aria-label="Print this book">
|
|
<i id="print-button" class="fa fa-print"></i>
|
|
</a>
|
|
<a href="https://github.com/rust-lang/rustc-dev-guide" title="Git repository" aria-label="Git repository">
|
|
<i id="git-repository-button" class="fa fa-github"></i>
|
|
</a>
|
|
<a href="https://github.com/rust-lang/rustc-dev-guide/edit/master/src/stabilization_guide.md" title="Suggest an edit" aria-label="Suggest an edit">
|
|
<i id="git-edit-button" class="fa fa-edit"></i>
|
|
</a>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="search-wrapper" class="hidden">
|
|
<form id="searchbar-outer" class="searchbar-outer">
|
|
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
|
|
</form>
|
|
<div id="searchresults-outer" class="searchresults-outer hidden">
|
|
<div id="searchresults-header" class="searchresults-header"></div>
|
|
<ul id="searchresults">
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
|
|
<script>
|
|
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
|
|
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
|
|
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
|
|
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
|
|
});
|
|
</script>
|
|
|
|
<div id="content" class="content">
|
|
<main>
|
|
<h1 id="request-for-stabilization"><a class="header" href="#request-for-stabilization">Request for stabilization</a></h1>
|
|
<p><strong>NOTE</strong>: this page is about stabilizing <em>language</em> features.
|
|
For stabilizing <em>library</em> features, see <a href="./stability.html#stabilizing-a-library-feature">Stabilizing a library feature</a>.</p>
|
|
<p>Once an unstable feature has been well-tested with no outstanding
|
|
concern, anyone may push for its stabilization. It involves the
|
|
following steps:</p>
|
|
<ul>
|
|
<li><a href="#documentation-prs">Documentation PRs</a></li>
|
|
<li><a href="#write-a-stabilization-report">Write a stabilization report</a></li>
|
|
<li><a href="#fcp">FCP</a></li>
|
|
<li><a href="#stabilization-pr">Stabilization PR</a>
|
|
<ul>
|
|
<li><a href="#updating-the-feature-gate-listing">Updating the feature-gate listing</a></li>
|
|
<li><a href="#removing-existing-uses-of-the-feature-gate">Removing existing uses of the feature-gate</a></li>
|
|
<li><a href="#do-not-require-the-feature-gate-to-use-the-feature">Do not require the feature-gate to use the feature</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
<h2 id="documentation-prs"><a class="header" href="#documentation-prs">Documentation PRs</a></h2>
|
|
<p><a id="updating-documentation"></a></p>
|
|
<p>If any documentation for this feature exists, it should be
|
|
in the <a href="https://doc.rust-lang.org/unstable-book/index.html"><code>Unstable Book</code></a>, located at <a href="https://github.com/rust-lang/rust/tree/master/src/doc/unstable-book"><code>src/doc/unstable-book</code></a>.
|
|
If it exists, the page for the feature gate should be removed.</p>
|
|
<p>If there was documentation there, integrating it into the
|
|
existing documentation is needed.</p>
|
|
<p>If there wasn't documentation there, it needs to be added.</p>
|
|
<p>Places that may need updated documentation:</p>
|
|
<ul>
|
|
<li><a href="https://github.com/rust-lang/reference">The Reference</a>: This must be updated, in full detail.</li>
|
|
<li><a href="https://github.com/rust-lang/book">The Book</a>: This may or may not need updating, depends.
|
|
If you're not sure, please open an issue on this repository
|
|
and it can be discussed.</li>
|
|
<li>standard library documentation: As needed. Language features
|
|
often don't need this, but if it's a feature that changes
|
|
how good examples are written, such as when <code>?</code> was added
|
|
to the language, updating examples is important.</li>
|
|
<li><a href="https://github.com/rust-lang/rust-by-example">Rust by Example</a>: As needed.</li>
|
|
</ul>
|
|
<p>Prepare PRs to update documentation involving this new feature
|
|
for repositories mentioned above. Maintainers of these repositories
|
|
will keep these PRs open until the whole stabilization process
|
|
has completed. Meanwhile, we can proceed to the next step.</p>
|
|
<h2 id="write-a-stabilization-report"><a class="header" href="#write-a-stabilization-report">Write a stabilization report</a></h2>
|
|
<p>Find the tracking issue of the feature, and create a short
|
|
stabilization report. Essentially this would be a brief summary
|
|
of the feature plus some links to test cases showing it works
|
|
as expected, along with a list of edge cases that came up
|
|
and were considered. This is a minimal "due diligence" that
|
|
we do before stabilizing.</p>
|
|
<p>The report should contain:</p>
|
|
<ul>
|
|
<li>A summary, showing examples (e.g. code snippets) what is
|
|
enabled by this feature.</li>
|
|
<li>Links to test cases in our test suite regarding this feature
|
|
and describe the feature's behavior on encountering edge cases.</li>
|
|
<li>Links to the documentations (the PRs we have made in the
|
|
previous steps).</li>
|
|
<li>Any other relevant information.</li>
|
|
<li>The resolutions of any unresolved questions if the stabilization
|
|
is for an RFC.</li>
|
|
</ul>
|
|
<p>Examples of stabilization reports can be found in
|
|
<a href="https://github.com/rust-lang/rust/issues/44494#issuecomment-360191474">rust-lang/rust#44494</a> and <a href="https://github.com/rust-lang/rust/issues/28237#issuecomment-363374130">rust-lang/rust#28237</a> (these links
|
|
will bring you directly to the comment containing the stabilization report).</p>
|
|
<h2 id="fcp"><a class="header" href="#fcp">FCP</a></h2>
|
|
<p>If any member of the team responsible for tracking this
|
|
feature agrees with stabilizing this feature, they will
|
|
start the FCP (final-comment-period) process by commenting</p>
|
|
<pre><code class="language-text">@rfcbot fcp merge
|
|
</code></pre>
|
|
<p>The rest of the team members will review the proposal. If the final
|
|
decision is to stabilize, we proceed to do the actual code modification.</p>
|
|
<h2 id="stabilization-pr"><a class="header" href="#stabilization-pr">Stabilization PR</a></h2>
|
|
<p><em>This is for stabilizing language features. If you are stabilizing a library
|
|
feature, see <a href="https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html">the stabilization chapter of the std dev guide</a> instead.</em></p>
|
|
<p>Once we have decided to stabilize a feature, we need to have
|
|
a PR that actually makes that stabilization happen. These kinds
|
|
of PRs are a great way to get involved in Rust, as they take
|
|
you on a little tour through the source code.</p>
|
|
<p>Here is a general guide to how to stabilize a feature --
|
|
every feature is different, of course, so some features may
|
|
require steps beyond what this guide talks about.</p>
|
|
<p>Note: Before we stabilize any feature, it's the rule that it
|
|
should appear in the documentation.</p>
|
|
<h3 id="updating-the-feature-gate-listing"><a class="header" href="#updating-the-feature-gate-listing">Updating the feature-gate listing</a></h3>
|
|
<p>There is a central listing of unstable feature-gates in
|
|
<a href="https://github.com/rust-lang/rust/tree/master/compiler/rustc_feature/src/unstable.rs"><code>compiler/rustc_feature/src/unstable.rs</code></a>. Search for the <code>declare_features!</code>
|
|
macro. There should be an entry for the feature you are aiming
|
|
to stabilize, something like (this example is taken from
|
|
<a href="https://github.com/rust-lang/rust/issues/32409">rust-lang/rust#32409</a>:</p>
|
|
<pre><code class="language-rust ignore">// pub(restricted) visibilities (RFC 1422)
|
|
(unstable, pub_restricted, "CURRENT_RUSTC_VERSION", Some(32409)),</code></pre>
|
|
<p>The above line should be moved to <a href="https://github.com/rust-lang/rust/tree/master/compiler/rustc_feature/src/accepted.rs"><code>compiler/rustc_feature/src/accepted.rs</code></a>.
|
|
Entries in the <code>declare_features!</code> call are sorted, so find the correct place.
|
|
When it is done, it should look like:</p>
|
|
<pre><code class="language-rust ignore">// pub(restricted) visibilities (RFC 1422)
|
|
(accepted, pub_restricted, "CURRENT_RUSTC_VERSION", Some(32409)),
|
|
// note that we changed this</code></pre>
|
|
<p>(Even though you will encounter version numbers in the file of past changes,
|
|
you should not put the rustc version you expect your stabilization to happen in,
|
|
but instead <code>CURRENT_RUSTC_VERSION</code>)</p>
|
|
<h3 id="removing-existing-uses-of-the-feature-gate"><a class="header" href="#removing-existing-uses-of-the-feature-gate">Removing existing uses of the feature-gate</a></h3>
|
|
<p>Next search for the feature string (in this case, <code>pub_restricted</code>)
|
|
in the codebase to find where it appears. Change uses of
|
|
<code>#![feature(XXX)]</code> from the <code>std</code> and any rustc crates (this includes test folders
|
|
under <code>library/</code> and <code>compiler/</code> but not the toplevel <code>tests/</code> one) to be
|
|
<code>#![cfg_attr(bootstrap, feature(XXX))]</code>. This includes the feature-gate
|
|
only for stage0, which is built using the current beta (this is
|
|
needed because the feature is still unstable in the current beta).</p>
|
|
<p>Also, remove those strings from any tests (e.g. under <code>tests/</code>). If there are tests
|
|
specifically targeting the feature-gate (i.e., testing that the
|
|
feature-gate is required to use the feature, but nothing else),
|
|
simply remove the test.</p>
|
|
<h3 id="do-not-require-the-feature-gate-to-use-the-feature"><a class="header" href="#do-not-require-the-feature-gate-to-use-the-feature">Do not require the feature-gate to use the feature</a></h3>
|
|
<p>Most importantly, remove the code which flags an error if the
|
|
feature-gate is not present (since the feature is now considered
|
|
stable). If the feature can be detected because it employs some
|
|
new syntax, then a common place for that code to be is in the
|
|
same <code>compiler/rustc_ast_passes/src/feature_gate.rs</code>.
|
|
For example, you might see code like this:</p>
|
|
<pre><code class="language-rust ignore">gate_feature_post!(&self, pub_restricted, span,
|
|
"`pub(restricted)` syntax is experimental");</code></pre>
|
|
<p>This <code>gate_feature_post!</code> macro prints an error if the
|
|
<code>pub_restricted</code> feature is not enabled. It is not needed
|
|
now that <code>#[pub_restricted]</code> is stable.</p>
|
|
<p>For more subtle features, you may find code like this:</p>
|
|
<pre><code class="language-rust ignore">if self.tcx.sess.features.borrow().pub_restricted { /* XXX */ }</code></pre>
|
|
<p>This <code>pub_restricted</code> field (obviously named after the feature)
|
|
would ordinarily be false if the feature flag is not present
|
|
and true if it is. So transform the code to assume that the field
|
|
is true. In this case, that would mean removing the <code>if</code> and
|
|
leaving just the <code>/* XXX */</code>.</p>
|
|
<pre><code class="language-rust ignore">if self.tcx.sess.features.borrow().pub_restricted { /* XXX */ }
|
|
becomes
|
|
/* XXX */
|
|
|
|
if self.tcx.sess.features.borrow().pub_restricted && something { /* XXX */ }
|
|
becomes
|
|
if something { /* XXX */ }</code></pre>
|
|
|
|
</main>
|
|
|
|
<nav class="nav-wrapper" aria-label="Page navigation">
|
|
<!-- Mobile navigation buttons -->
|
|
<a rel="prev" href="stability.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
|
|
<i class="fa fa-angle-left"></i>
|
|
</a>
|
|
|
|
<a rel="next prefetch" href="feature-gates.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
|
|
<i class="fa fa-angle-right"></i>
|
|
</a>
|
|
|
|
<div style="clear: both"></div>
|
|
</nav>
|
|
</div>
|
|
</div>
|
|
|
|
<nav class="nav-wide-wrapper" aria-label="Page navigation">
|
|
<a rel="prev" href="stability.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
|
|
<i class="fa fa-angle-left"></i>
|
|
</a>
|
|
|
|
<a rel="next prefetch" href="feature-gates.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
|
|
<i class="fa fa-angle-right"></i>
|
|
</a>
|
|
</nav>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
window.playground_copyable = true;
|
|
</script>
|
|
|
|
|
|
<script src="elasticlunr.min.js"></script>
|
|
<script src="mark.min.js"></script>
|
|
<script src="searcher.js"></script>
|
|
|
|
<script src="clipboard.min.js"></script>
|
|
<script src="highlight.js"></script>
|
|
<script src="book.js"></script>
|
|
|
|
<!-- Custom JS scripts -->
|
|
<script src="mermaid.min.js"></script>
|
|
<script src="mermaid-init.js"></script>
|
|
|
|
|
|
</div>
|
|
</body>
|
|
</html>
|