]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #49654 - davidtwco:issue-29893, r=alexcrichton
authorkennytm <kennytm@gmail.com>
Thu, 5 Apr 2018 08:51:25 +0000 (16:51 +0800)
committerkennytm <kennytm@gmail.com>
Thu, 5 Apr 2018 10:37:28 +0000 (18:37 +0800)
Host compiler documentation: Include private items

Fixes #29893. Now that compiler documentation is being hosted, including private items seems sensible as these types are going to be being used by contributors working on the compiler.

However, including this means that doc comments that contain codeblocks with invalid Rust and can fail the documenting of a given crate (as evidenced by the changes in the second commit included in this PR). We'd need some way of ensuring that this cannot happen so that these failures don't cause documenting to fail. I'm unsure whether this change to documentation steps will cause this to happen already or if something new will be required.

r? @alexcrichton

1  2 
src/bootstrap/doc.rs
src/librustc/traits/select.rs

diff --combined src/bootstrap/doc.rs
index f07c3e707574b4e4a051fc6e9b1f9e0950b82917,06340a4e98a47f3029611f498493106cac0b62ac..4237ded2215c218e4fd8ed16e4d7d4a795fecc4b
@@@ -26,12 -26,11 +26,12 @@@ use std::path::{PathBuf, Path}
  use {Build, Mode};
  use build_helper::up_to_date;
  
 -use util::{cp_r, symlink_dir};
 +use util::symlink_dir;
  use builder::{Builder, Compiler, RunConfig, ShouldRun, Step};
  use tool::Tool;
  use compile;
  use cache::{INTERNER, Interned};
 +use config::Config;
  
  macro_rules! book {
      ($($name:ident, $path:expr, $book_name:expr;)+) => {
@@@ -169,7 -168,7 +169,7 @@@ impl Step for CargoBook 
  
          let out = out.join(name);
  
 -        println!("Cargo Book ({}) - {}", target, name);
 +        build.info(&format!("Cargo Book ({}) - {}", target, name));
  
          let _ = fs::remove_dir_all(&out);
  
@@@ -211,13 -210,12 +211,13 @@@ impl Step for RustbookSrc 
          let src = src.join(name);
          let index = out.join("index.html");
          let rustbook = builder.tool_exe(Tool::Rustbook);
 +        let mut rustbook_cmd = builder.tool_cmd(Tool::Rustbook);
          if up_to_date(&src, &index) && up_to_date(&rustbook, &index) {
              return
          }
 -        println!("Rustbook ({}) - {}", target, name);
 +        build.info(&format!("Rustbook ({}) - {}", target, name));
          let _ = fs::remove_dir_all(&out);
 -        build.run(builder.tool_cmd(Tool::Rustbook)
 +        build.run(rustbook_cmd
                         .arg("build")
                         .arg(&src)
                         .arg("-d")
@@@ -283,11 -281,11 +283,11 @@@ impl Step for TheBook 
  
          // build the index page
          let index = format!("{}/index.md", name);
 -        println!("Documenting book index ({})", target);
 +        build.info(&format!("Documenting book index ({})", target));
          invoke_rustdoc(builder, compiler, target, &index);
  
          // build the redirect pages
 -        println!("Documenting book redirect pages ({})", target);
 +        build.info(&format!("Documenting book redirect pages ({})", target));
          for file in t!(fs::read_dir(build.src.join("src/doc/book/redirects"))) {
              let file = t!(file);
              let path = file.path();
@@@ -360,7 -358,7 +360,7 @@@ impl Step for Standalone 
          let build = builder.build;
          let target = self.target;
          let compiler = self.compiler;
 -        println!("Documenting standalone ({})", target);
 +        build.info(&format!("Documenting standalone ({})", target));
          let out = build.doc_out(target);
          t!(fs::create_dir_all(&out));
  
          let version_input = build.src.join("src/doc/version_info.html.template");
          let version_info = out.join("version_info.html");
  
 -        if !up_to_date(&version_input, &version_info) {
 +        if !build.config.dry_run && !up_to_date(&version_input, &version_info) {
              let mut info = String::new();
              t!(t!(File::open(&version_input)).read_to_string(&mut info));
              let info = info.replace("VERSION", &build.rust_release())
                 up_to_date(&favicon, &html) &&
                 up_to_date(&full_toc, &html) &&
                 up_to_date(&version_info, &html) &&
 -               up_to_date(&rustdoc, &html) {
 +               (build.config.dry_run || up_to_date(&rustdoc, &html)) {
                  continue
              }
  
@@@ -451,7 -449,7 +451,7 @@@ impl Step for Std 
          let build = builder.build;
          let stage = self.stage;
          let target = self.target;
 -        println!("Documenting stage{} std ({})", stage, target);
 +        build.info(&format!("Documenting stage{} std ({})", stage, target));
          let out = build.doc_out(target);
          t!(fs::create_dir_all(&out));
          let compiler = builder.compiler(stage, build.build);
          // will also directly handle merging.
          let my_out = build.crate_doc_out(target);
          build.clear_if_dirty(&my_out, &rustdoc);
 -        t!(symlink_dir_force(&my_out, &out_dir));
 +        t!(symlink_dir_force(&build.config, &my_out, &out_dir));
  
          let mut cargo = builder.cargo(compiler, Mode::Libstd, target, "doc");
          compile::std_cargo(builder, &compiler, target, &mut cargo);
          }
  
          build.run(&mut cargo);
 -        cp_r(&my_out, &out);
 +        build.cp_r(&my_out, &out);
      }
  }
  
@@@ -532,7 -530,7 +532,7 @@@ impl Step for Test 
          let build = builder.build;
          let stage = self.stage;
          let target = self.target;
 -        println!("Documenting stage{} test ({})", stage, target);
 +        build.info(&format!("Documenting stage{} test ({})", stage, target));
          let out = build.doc_out(target);
          t!(fs::create_dir_all(&out));
          let compiler = builder.compiler(stage, build.build);
          // See docs in std above for why we symlink
          let my_out = build.crate_doc_out(target);
          build.clear_if_dirty(&my_out, &rustdoc);
 -        t!(symlink_dir_force(&my_out, &out_dir));
 +        t!(symlink_dir_force(&builder.config, &my_out, &out_dir));
  
          let mut cargo = builder.cargo(compiler, Mode::Libtest, target, "doc");
          compile::test_cargo(build, &compiler, target, &mut cargo);
          build.run(&mut cargo);
 -        cp_r(&my_out, &out);
 +        build.cp_r(&my_out, &out);
      }
  }
  
@@@ -598,7 -596,7 +598,7 @@@ impl Step for WhitelistedRustc 
          let build = builder.build;
          let stage = self.stage;
          let target = self.target;
 -        println!("Documenting stage{} whitelisted compiler ({})", stage, target);
 +        build.info(&format!("Documenting stage{} whitelisted compiler ({})", stage, target));
          let out = build.doc_out(target);
          t!(fs::create_dir_all(&out));
          let compiler = builder.compiler(stage, build.build);
          // See docs in std above for why we symlink
          let my_out = build.crate_doc_out(target);
          build.clear_if_dirty(&my_out, &rustdoc);
 -        t!(symlink_dir_force(&my_out, &out_dir));
 +        t!(symlink_dir_force(&builder.config, &my_out, &out_dir));
  
          let mut cargo = builder.cargo(compiler, Mode::Librustc, target, "doc");
          compile::rustc_cargo(build, &mut cargo);
          }
  
          build.run(&mut cargo);
 -        cp_r(&my_out, &out);
 +        build.cp_r(&my_out, &out);
      }
  }
  
@@@ -670,7 -668,7 +670,7 @@@ impl Step for Rustc 
          let build = builder.build;
          let stage = self.stage;
          let target = self.target;
 -        println!("Documenting stage{} compiler ({})", stage, target);
 +        build.info(&format!("Documenting stage{} compiler ({})", stage, target));
          let out = build.compiler_doc_out(target);
          t!(fs::create_dir_all(&out));
          let compiler = builder.compiler(stage, build.build);
          };
  
          if !build.config.compiler_docs {
 -            println!("\tskipping - compiler docs disabled");
 +            build.info(&format!("\tskipping - compiler docs disabled"));
              return;
          }
  
          // We do not symlink to the same shared folder that already contains std library
          // documentation from previous steps as we do not want to include that.
          build.clear_if_dirty(&out, &rustdoc);
 -        t!(symlink_dir_force(&out, &out_dir));
 +        t!(symlink_dir_force(&builder.config, &out, &out_dir));
  
          let mut cargo = builder.cargo(compiler, Mode::Librustc, target, "doc");
+         cargo.env("RUSTDOCFLAGS", "--document-private-items");
          compile::rustc_cargo(build, &mut cargo);
  
          // Only include compiler crates, no dependencies of those, such as `libc`.
@@@ -761,7 -760,7 +762,7 @@@ impl Step for ErrorIndex 
          let build = builder.build;
          let target = self.target;
  
 -        println!("Documenting error index ({})", target);
 +        build.info(&format!("Documenting error index ({})", target));
          let out = build.doc_out(target);
          t!(fs::create_dir_all(&out));
          let mut index = builder.tool_cmd(Tool::ErrorIndex);
@@@ -806,10 -805,10 +807,10 @@@ impl Step for UnstableBookGen 
              target,
          });
  
 -        println!("Generating unstable book md files ({})", target);
 +        build.info(&format!("Generating unstable book md files ({})", target));
          let out = build.md_doc_out(target).join("unstable-book");
 -        t!(fs::create_dir_all(&out));
 -        t!(fs::remove_dir_all(&out));
 +        build.create_dir(&out);
 +        build.remove_dir(&out);
          let mut cmd = builder.tool_cmd(Tool::UnstableBookGen);
          cmd.arg(build.src.join("src"));
          cmd.arg(out);
      }
  }
  
 -fn symlink_dir_force(src: &Path, dst: &Path) -> io::Result<()> {
 +fn symlink_dir_force(config: &Config, src: &Path, dst: &Path) -> io::Result<()> {
 +    if config.dry_run {
 +        return Ok(());
 +    }
      if let Ok(m) = fs::symlink_metadata(dst) {
          if m.file_type().is_dir() {
              try!(fs::remove_dir_all(dst));
          }
      }
  
 -    symlink_dir(src, dst)
 +    symlink_dir(config, src, dst)
  }
index bbd428611874ae2d994cbcd90ebe1eeb4181023c,548296b77f9cf04b7b9f23e61487f3783826ae75..b1649686323f8750e09e47f33be76fdf28a7f839
@@@ -362,7 -362,9 +362,9 @@@ enum EvaluationResult 
      /// When checking `foo`, we have to prove `T: Trait`. This basically
      /// translates into this:
      ///
+     /// ```plain,ignore
      ///     (T: Trait + Sized →_\impl T: Trait), T: Trait ⊢ T: Trait
+     /// ```
      ///
      /// When we try to prove it, we first go the first option, which
      /// recurses. This shows us that the impl is "useless" - it won't
@@@ -2061,15 -2063,11 +2063,15 @@@ impl<'cx, 'gcx, 'tcx> SelectionContext<
  
          match self_ty.sty {
              ty::TyInfer(ty::IntVar(_)) | ty::TyInfer(ty::FloatVar(_)) |
 +            ty::TyFnDef(..) | ty::TyFnPtr(_) | ty::TyError => {
 +                Where(ty::Binder(Vec::new()))
 +            }
 +
              ty::TyUint(_) | ty::TyInt(_) | ty::TyBool | ty::TyFloat(_) |
 -            ty::TyFnDef(..) | ty::TyFnPtr(_) | ty::TyChar |
 -            ty::TyRawPtr(..) | ty::TyError | ty::TyNever |
 +            ty::TyChar | ty::TyRawPtr(..) | ty::TyNever |
              ty::TyRef(_, ty::TypeAndMut { ty: _, mutbl: hir::MutImmutable }) => {
 -                Where(ty::Binder(Vec::new()))
 +                // Implementations provided in libcore
 +                None
              }
  
              ty::TyDynamic(..) | ty::TyStr | ty::TySlice(..) |