Add relnotes-api-list in-tree tool by pietroalbini · Pull Request #143053 · rust-lang/rust (original) (raw)

⚠️ This PR is not ready yet. Opening it up for early review. ⚠️


This PR adds a new in-tree tool called relnotes-api-list to generate a simplified JSON representation of the standard library API. This representation will be uploaded as a dist artifact (but it won't be included in the published releases), and it will be used by the relnotes tool to generate the "Stabilized APIs" section by comparing the JSON file of multiple releases.

Behind the scenes, the tool consumes the Rustdoc JSON (cc @rust-lang/rustdoc) and depends on the in-tree src/rustdoc-json-types crate. Being an in-tree tool, this implies PRs modifying the JSON output will also have to adapt this tool to pass CI.

The generated JSON contains a tree structure, with each node containing an item (module, struct, function, etc) and its children (for example, the methods of a struct). This tree representation will allow the relnotes tool (for example) to only show a line for a new module being added instead of also showing all of the structs, functions and methods within that new module.

Outstanding question: impl blocks

While deciding how to represent most items in the JSON is trivial (just the path to the item as the name, and the Rustdoc URL as the URL), impl blocks are trickier, and there is no single obvious solution to them.

The first problem is whether to include impl blocks at all:

So, if we go with these assumptions, we only care about how to represent impl <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>t</mi><mi>r</mi><mi>a</mi><mi>i</mi><mi>t</mi><mi>f</mi><mi>o</mi><mi>r</mi></mrow><annotation encoding="application/x-tex">trait for </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">t</span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="mord mathnormal">ai</span><span class="mord mathnormal">t</span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="mord mathnormal" style="margin-right:0.02778em;">or</span></span></span></span>type {} in the resulting JSON. This has two big open questions though:

std/result/enum.Result.html#impl-FromIterator<Result<A,+E>>-for-Result<V,+E>  
std/option/enum.Option.html#impl-Hash-for-Option<T>  

Outstanding question: move some of the behavior to Rustdoc JSON?

There is a lot of complexity right now in the tool that could maybe benefit from being uplifted in the Rustdoc JSON emitter:

Q&A

r? @Mark-Simulacrum
cc @rust-lang/release