From 01cf0bde2773dc915fbe751d809cc46b873f71a1 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Wed, 30 Jun 2021 00:13:34 -0400 Subject: [PATCH] Document rustfmt on nightly-rustc The recursion_limit attribute avoids the following error: ``` error[E0275]: overflow evaluating the requirement `std::ptr::Unique: std::marker::Send` | = help: consider adding a `#![recursion_limit="256"]` attribute to your crate (`rustfmt_nightly`) ``` --- src/bootstrap/builder.rs | 2 +- src/bootstrap/doc.rs | 16 +++++++++++----- src/tools/rustfmt/src/lib.rs | 1 + 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 38705a56484..56ecc6e68a9 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -465,7 +465,7 @@ macro_rules! describe { doc::Std, doc::Rustc, doc::Rustdoc, - // doc::Rustfmt, + doc::Rustfmt, doc::ErrorIndex, doc::Nomicon, doc::Reference, diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index 7ba2ff073cd..8603361362c 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -594,7 +594,7 @@ fn run(self, builder: &Builder<'_>) { } macro_rules! tool_doc { - ($tool: ident, $should_run: literal, $path: literal, [$($krate: literal),+ $(,)?]) => { + ($tool: ident, $should_run: literal, $path: literal, [$($krate: literal),+ $(,)?] $(, binary=$bin:expr)?) => { #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct $tool { stage: u32, @@ -639,9 +639,6 @@ fn run(self, builder: &Builder<'_>) { // Build rustc docs so that we generate relative links. builder.ensure(Rustc { stage, target }); - // Build the tool. - builder.ensure(tool::$tool { compiler }); - // Symlink compiler docs to the output directory of rustdoc documentation. let out_dir = builder.stage_out(compiler, Mode::ToolRustc).join(target.triple).join("doc"); t!(fs::create_dir_all(&out_dir)); @@ -666,7 +663,9 @@ fn run(self, builder: &Builder<'_>) { cargo.arg("-p").arg($krate); )+ - cargo.rustdocflag("--document-private-items"); + $(if !$bin { + cargo.rustdocflag("--document-private-items"); + })? cargo.rustdocflag("--enable-index-page"); cargo.rustdocflag("--show-type-layout"); cargo.rustdocflag("-Zunstable-options"); @@ -677,6 +676,13 @@ fn run(self, builder: &Builder<'_>) { } tool_doc!(Rustdoc, "rustdoc-tool", "src/tools/rustdoc", ["rustdoc", "rustdoc-json-types"]); +tool_doc!( + Rustfmt, + "rustfmt-nightly", + "src/tools/rustfmt", + ["rustfmt-nightly", "rustfmt-config_proc_macro"], + binary = true +); #[derive(Ord, PartialOrd, Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct ErrorIndex { diff --git a/src/tools/rustfmt/src/lib.rs b/src/tools/rustfmt/src/lib.rs index cde5d390cf2..ce8a45eea65 100644 --- a/src/tools/rustfmt/src/lib.rs +++ b/src/tools/rustfmt/src/lib.rs @@ -1,6 +1,7 @@ #![feature(rustc_private)] #![deny(rust_2018_idioms)] #![warn(unreachable_pub)] +#![recursion_limit = "256"] #[macro_use] extern crate derive_new;