From 04da856c8464e9ed25645f8ef4426a322c168c2e Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 1 Mar 2018 14:50:50 -0800 Subject: [PATCH 01/14] Update sccache to its master branch Ideally I'd like to soon enable sccache for rustbuild itself and some of the stage0 tools, but for that to work we'll need some better Rust support than the pretty old version we were previously using! --- .travis.yml | 13 +------------ appveyor.yml | 10 ++-------- src/ci/docker/run.sh | 2 -- src/ci/docker/scripts/sccache.sh | 2 +- 4 files changed, 4 insertions(+), 23 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0d8641e45ed15..2d823815a3010 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,7 +30,6 @@ matrix: SRC=. DEPLOY_ALT=1 RUSTC_RETRY_LINKER_ON_SEGFAULT=1 - SCCACHE_ERROR_LOG=/tmp/sccache.log MACOSX_DEPLOYMENT_TARGET=10.7 NO_LLVM_ASSERTIONS=1 NO_DEBUG_ASSERTIONS=1 @@ -50,7 +49,6 @@ matrix: RUST_CONFIGURE_ARGS="--build=x86_64-apple-darwin --enable-sanitizers --enable-profiler" SRC=. RUSTC_RETRY_LINKER_ON_SEGFAULT=1 - SCCACHE_ERROR_LOG=/tmp/sccache.log MACOSX_DEPLOYMENT_TARGET=10.8 MACOSX_STD_DEPLOYMENT_TARGET=10.7 NO_LLVM_ASSERTIONS=1 @@ -64,7 +62,6 @@ matrix: RUST_CONFIGURE_ARGS=--build=i686-apple-darwin SRC=. RUSTC_RETRY_LINKER_ON_SEGFAULT=1 - SCCACHE_ERROR_LOG=/tmp/sccache.log MACOSX_DEPLOYMENT_TARGET=10.8 MACOSX_STD_DEPLOYMENT_TARGET=10.7 NO_LLVM_ASSERTIONS=1 @@ -85,7 +82,6 @@ matrix: SRC=. DEPLOY=1 RUSTC_RETRY_LINKER_ON_SEGFAULT=1 - SCCACHE_ERROR_LOG=/tmp/sccache.log MACOSX_DEPLOYMENT_TARGET=10.7 NO_LLVM_ASSERTIONS=1 NO_DEBUG_ASSERTIONS=1 @@ -99,7 +95,6 @@ matrix: SRC=. DEPLOY=1 RUSTC_RETRY_LINKER_ON_SEGFAULT=1 - SCCACHE_ERROR_LOG=/tmp/sccache.log MACOSX_DEPLOYMENT_TARGET=10.7 NO_LLVM_ASSERTIONS=1 NO_DEBUG_ASSERTIONS=1 @@ -223,7 +218,7 @@ install: travis_retry brew update && travis_retry brew install xz; fi && - travis_retry curl -fo /usr/local/bin/sccache https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/2017-05-12-sccache-x86_64-apple-darwin && + travis_retry curl -fo /usr/local/bin/sccache https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/2018-03-01-sccache-x86_64-apple-darwin && chmod +x /usr/local/bin/sccache && travis_retry curl -fo /usr/local/bin/stamp https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/2017-03-17-stamp-x86_64-apple-darwin && chmod +x /usr/local/bin/stamp @@ -264,12 +259,6 @@ after_failure: df -h; du . | sort -nr | head -n100 - # One of these is the linux sccache log, one is the OSX sccache log. Instead - # of worrying about what system we are just cat both. One of these commands - # will fail but that's ok, they'll both get executed. - - cat obj/tmp/sccache.log - - cat /tmp/sccache.log - # Random attempt at debugging currently. Just poking around in here to see if # anything shows up. - ls -lat $HOME/Library/Logs/DiagnosticReports/ diff --git a/appveyor.yml b/appveyor.yml index 0ea15dd671c8b..9c4d66c7ee33b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -148,8 +148,8 @@ install: - set PATH=C:\Python27;%PATH% # Download and install sccache - - appveyor-retry appveyor DownloadFile https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/2017-05-12-sccache-x86_64-pc-windows-msvc - - mv 2017-05-12-sccache-x86_64-pc-windows-msvc sccache.exe + - appveyor-retry appveyor DownloadFile https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/2018-03-01-sccache-x86_64-pc-windows-msvc + - mv 2018-03-01-sccache-x86_64-pc-windows-msvc sccache.exe - set PATH=%PATH%;%CD% # Download and install ninja @@ -172,9 +172,6 @@ install: - set PATH=%PATH%;%CD%\handle - handle.exe -accepteula -help - # Attempt to debug sccache failures - - set SCCACHE_ERROR_LOG=%CD%/sccache.log - test_script: - if not exist C:\cache\rustsrc\NUL mkdir C:\cache\rustsrc - sh src/ci/init_repo.sh . /c/cache/rustsrc @@ -182,9 +179,6 @@ test_script: - set NO_CCACHE=1 - sh src/ci/run.sh -on_failure: - - cat %CD%\sccache.log || exit 0 - branches: only: - auto diff --git a/src/ci/docker/run.sh b/src/ci/docker/run.sh index f743c976f91a2..83cc95d3c2cd0 100755 --- a/src/ci/docker/run.sh +++ b/src/ci/docker/run.sh @@ -72,8 +72,6 @@ if [ "$SCCACHE_BUCKET" != "" ]; then args="$args --env SCCACHE_REGION" args="$args --env AWS_ACCESS_KEY_ID" args="$args --env AWS_SECRET_ACCESS_KEY" - args="$args --env SCCACHE_ERROR_LOG=/tmp/sccache/sccache.log" - args="$args --volume $objdir/tmp:/tmp/sccache" else mkdir -p $HOME/.cache/sccache args="$args --env SCCACHE_DIR=/sccache --volume $HOME/.cache/sccache:/sccache" diff --git a/src/ci/docker/scripts/sccache.sh b/src/ci/docker/scripts/sccache.sh index ce2d45563f7b5..593314b34a518 100644 --- a/src/ci/docker/scripts/sccache.sh +++ b/src/ci/docker/scripts/sccache.sh @@ -13,6 +13,6 @@ set -ex curl -fo /usr/local/bin/sccache \ - https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/2017-05-12-sccache-x86_64-unknown-linux-musl + https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/2018-03-01-sccache-x86_64-unknown-linux-musl chmod +x /usr/local/bin/sccache From a628543891c94e0e9b7d1ac57dc7add832dcefea Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 5 Mar 2018 20:17:34 +0100 Subject: [PATCH 02/14] Don't generate '[+]'/'[-]' on 'empty' traits --- src/librustdoc/html/static/main.js | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 960f2f198d8b0..36ca1e06f241c 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -1776,22 +1776,33 @@ referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling); } + function checkIfThereAreMethods(elems) { + var areThereMethods = false; + + onEach(elems, function(e) { + if (hasClass(e, "method")) { + areThereMethods = true; + return true; + } + }); + return areThereMethods; + } + var toggle = document.createElement('a'); toggle.href = 'javascript:void(0)'; toggle.className = 'collapse-toggle'; - toggle.innerHTML = "["+labelForToggleButton(false)+"]"; + toggle.innerHTML = "[" + labelForToggleButton(false) + "]"; var func = function(e) { var next = e.nextElementSibling; if (!next) { return; } - if (hasClass(next, 'docblock') || - (hasClass(next, 'stability') && - hasClass(next.nextElementSibling, 'docblock'))) { - insertAfter(toggle.cloneNode(true), e.childNodes[e.childNodes.length - 1]); - } - if (hasClass(e, 'impl')) { + if (checkIfThereAreMethods(next.childNodes) && + (hasClass(next, 'docblock') || + hasClass(e, 'impl') || + (hasClass(next, 'stability') && + hasClass(next.nextElementSibling, 'docblock')))) { insertAfter(toggle.cloneNode(true), e.childNodes[e.childNodes.length - 1]); } } From 55a2fdf2cf5408edba890ad1702462414899f40b Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 6 Mar 2018 14:37:08 -0800 Subject: [PATCH 03/14] travis: Upgrade OSX builders This upgrades the OSX builders to the `xcode9.3-moar` image which has 3 cores as opposed to the 2 that our builders currently have. Should help make those OSX builds a bit speedier! --- .travis.yml | 4 +- .../debuginfo/lexical-scope-with-macro.rs | 1 + .../long-linker-command-lines/Makefile | 2 +- src/test/run-make/reproducible-build/Makefile | 28 +++++----- .../run-make/reproducible-build/linker.rs | 54 +++++++++++++++++++ 5 files changed, 70 insertions(+), 19 deletions(-) create mode 100644 src/test/run-make/reproducible-build/linker.rs diff --git a/.travis.yml b/.travis.yml index 4738f91665dbe..074149cf17118 100644 --- a/.travis.yml +++ b/.travis.yml @@ -56,7 +56,7 @@ matrix: NO_LLVM_ASSERTIONS=1 NO_DEBUG_ASSERTIONS=1 os: osx - osx_image: xcode9.2 + osx_image: xcode9.3-moar if: branch = auto - env: > @@ -70,7 +70,7 @@ matrix: NO_LLVM_ASSERTIONS=1 NO_DEBUG_ASSERTIONS=1 os: osx - osx_image: xcode9.2 + osx_image: xcode9.3-moar if: branch = auto # OSX builders producing releases. These do not run the full test suite and diff --git a/src/test/debuginfo/lexical-scope-with-macro.rs b/src/test/debuginfo/lexical-scope-with-macro.rs index eb5798dc7cc48..32d775168692b 100644 --- a/src/test/debuginfo/lexical-scope-with-macro.rs +++ b/src/test/debuginfo/lexical-scope-with-macro.rs @@ -9,6 +9,7 @@ // except according to those terms. // min-lldb-version: 310 +// ignore-macos FIXME #48807 // compile-flags:-g -Zdebug-macros diff --git a/src/test/run-make/long-linker-command-lines/Makefile b/src/test/run-make/long-linker-command-lines/Makefile index 309a27fe503ad..5876fbc94bc98 100644 --- a/src/test/run-make/long-linker-command-lines/Makefile +++ b/src/test/run-make/long-linker-command-lines/Makefile @@ -1,5 +1,5 @@ -include ../tools.mk all: - $(RUSTC) foo.rs -g + $(RUSTC) foo.rs -g -O RUSTC="$(RUSTC_ORIGINAL)" $(call RUN,foo) diff --git a/src/test/run-make/reproducible-build/Makefile b/src/test/run-make/reproducible-build/Makefile index 629e618505129..ca76a5e5d77b6 100644 --- a/src/test/run-make/reproducible-build/Makefile +++ b/src/test/run-make/reproducible-build/Makefile @@ -10,31 +10,27 @@ all: \ smoke: rm -rf $(TMPDIR) && mkdir $(TMPDIR) + $(RUSTC) linker.rs -O $(RUSTC) reproducible-build-aux.rs - $(RUSTC) reproducible-build.rs -o"$(TMPDIR)/reproducible-build1" - $(RUSTC) reproducible-build.rs -o"$(TMPDIR)/reproducible-build2" - $(B2) - nm "$(TMPDIR)/reproducible-build1" | sort > "$(TMPDIR)/reproducible-build1.nm" - nm "$(TMPDIR)/reproducible-build2" | sort > "$(TMPDIR)/reproducible-build2.nm" - cmp "$(TMPDIR)/reproducible-build1.nm" "$(TMPDIR)/reproducible-build2.nm" || exit 1 + $(RUSTC) reproducible-build.rs -C linker=$(call RUN_BINFILE,linker) + $(RUSTC) reproducible-build.rs -C linker=$(call RUN_BINFILE,linker) + diff -u "$(TMPDIR)/linker-arguments1" "$(TMPDIR)/linker-arguments2" debug: rm -rf $(TMPDIR) && mkdir $(TMPDIR) + $(RUSTC) linker.rs -O $(RUSTC) reproducible-build-aux.rs -g - $(RUSTC) reproducible-build.rs -o"$(TMPDIR)/reproducible-build1" -g - $(RUSTC) reproducible-build.rs -o"$(TMPDIR)/reproducible-build2" -g - nm "$(TMPDIR)/reproducible-build1" | sort > "$(TMPDIR)/reproducible-build1-debug.nm" - nm "$(TMPDIR)/reproducible-build2" | sort > "$(TMPDIR)/reproducible-build2-debug.nm" - cmp "$(TMPDIR)/reproducible-build1-debug.nm" "$(TMPDIR)/reproducible-build2-debug.nm" || exit 1 + $(RUSTC) reproducible-build.rs -C linker=$(call RUN_BINFILE,linker) -g + $(RUSTC) reproducible-build.rs -C linker=$(call RUN_BINFILE,linker) -g + diff -u "$(TMPDIR)/linker-arguments1" "$(TMPDIR)/linker-arguments2" opt: rm -rf $(TMPDIR) && mkdir $(TMPDIR) + $(RUSTC) linker.rs -O $(RUSTC) reproducible-build-aux.rs -O - $(RUSTC) reproducible-build.rs -o"$(TMPDIR)/reproducible-build1" -O - $(RUSTC) reproducible-build.rs -o"$(TMPDIR)/reproducible-build2" -O - nm "$(TMPDIR)/reproducible-build1" | sort > "$(TMPDIR)/reproducible-build1-opt.nm" - nm "$(TMPDIR)/reproducible-build2" | sort > "$(TMPDIR)/reproducible-build2-opt.nm" - cmp "$(TMPDIR)/reproducible-build1-opt.nm" "$(TMPDIR)/reproducible-build2-opt.nm" || exit 1 + $(RUSTC) reproducible-build.rs -C linker=$(call RUN_BINFILE,linker) -O + $(RUSTC) reproducible-build.rs -C linker=$(call RUN_BINFILE,linker) -O + diff -u "$(TMPDIR)/linker-arguments1" "$(TMPDIR)/linker-arguments2" link_paths: rm -rf $(TMPDIR) && mkdir $(TMPDIR) diff --git a/src/test/run-make/reproducible-build/linker.rs b/src/test/run-make/reproducible-build/linker.rs new file mode 100644 index 0000000000000..fd8946708bffd --- /dev/null +++ b/src/test/run-make/reproducible-build/linker.rs @@ -0,0 +1,54 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::env; +use std::path::Path; +use std::fs::File; +use std::io::{Read, Write}; + +fn main() { + let mut dst = env::current_exe().unwrap(); + dst.pop(); + dst.push("linker-arguments1"); + if dst.exists() { + dst.pop(); + dst.push("linker-arguments2"); + assert!(!dst.exists()); + } + + let mut out = String::new(); + for arg in env::args().skip(1) { + let path = Path::new(&arg); + if !path.is_file() { + out.push_str(&arg); + out.push_str("\n"); + continue + } + + let mut contents = Vec::new(); + File::open(path).unwrap().read_to_end(&mut contents).unwrap(); + + out.push_str(&format!("{}: {}\n", arg, hash(&contents))); + } + + File::create(dst).unwrap().write_all(out.as_bytes()).unwrap(); +} + +// fnv hash for now +fn hash(contents: &[u8]) -> u64 { + let mut hash = 0xcbf29ce484222325; + + for byte in contents { + hash = hash ^ (*byte as u64); + hash = hash.wrapping_mul(0x100000001b3); + } + + hash +} From d14f07e08916d3dbb3ff77b756bde324aeb05190 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Perennou Date: Sat, 17 Feb 2018 09:54:11 +0100 Subject: [PATCH 04/14] bootstrap: pass datadir to rust-installer Signed-off-by: Marc-Antoine Perennou --- src/bootstrap/config.rs | 4 +++- src/bootstrap/install.rs | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index f15d4d3585839..a4193ea8b8f30 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -127,6 +127,7 @@ pub struct Config { pub musl_root: Option, pub prefix: Option, pub sysconfdir: Option, + pub datadir: Option, pub docdir: Option, pub bindir: Option, pub libdir: Option, @@ -212,13 +213,13 @@ struct Build { struct Install { prefix: Option, sysconfdir: Option, + datadir: Option, docdir: Option, bindir: Option, libdir: Option, mandir: Option, // standard paths, currently unused - datadir: Option, infodir: Option, localstatedir: Option, } @@ -419,6 +420,7 @@ impl Config { if let Some(ref install) = toml.install { config.prefix = install.prefix.clone().map(PathBuf::from); config.sysconfdir = install.sysconfdir.clone().map(PathBuf::from); + config.datadir = install.datadir.clone().map(PathBuf::from); config.docdir = install.docdir.clone().map(PathBuf::from); config.bindir = install.bindir.clone().map(PathBuf::from); config.libdir = install.libdir.clone().map(PathBuf::from); diff --git a/src/bootstrap/install.rs b/src/bootstrap/install.rs index 20f7d379a6967..540c07748b9a0 100644 --- a/src/bootstrap/install.rs +++ b/src/bootstrap/install.rs @@ -67,18 +67,21 @@ fn install_sh( let prefix_default = PathBuf::from("/usr/local"); let sysconfdir_default = PathBuf::from("/etc"); - let docdir_default = PathBuf::from("share/doc/rust"); + let datadir_default = PathBuf::from("share"); + let docdir_default = datadir_default.join("doc/rust"); let bindir_default = PathBuf::from("bin"); let libdir_default = PathBuf::from("lib"); - let mandir_default = PathBuf::from("share/man"); + let mandir_default = datadir_default.join("man"); let prefix = build.config.prefix.as_ref().unwrap_or(&prefix_default); let sysconfdir = build.config.sysconfdir.as_ref().unwrap_or(&sysconfdir_default); + let datadir = build.config.datadir.as_ref().unwrap_or(&datadir_default); let docdir = build.config.docdir.as_ref().unwrap_or(&docdir_default); let bindir = build.config.bindir.as_ref().unwrap_or(&bindir_default); let libdir = build.config.libdir.as_ref().unwrap_or(&libdir_default); let mandir = build.config.mandir.as_ref().unwrap_or(&mandir_default); let sysconfdir = prefix.join(sysconfdir); + let datadir = prefix.join(datadir); let docdir = prefix.join(docdir); let bindir = prefix.join(bindir); let libdir = prefix.join(libdir); @@ -88,6 +91,7 @@ fn install_sh( let prefix = add_destdir(&prefix, &destdir); let sysconfdir = add_destdir(&sysconfdir, &destdir); + let datadir = add_destdir(&datadir, &destdir); let docdir = add_destdir(&docdir, &destdir); let bindir = add_destdir(&bindir, &destdir); let libdir = add_destdir(&libdir, &destdir); @@ -107,6 +111,7 @@ fn install_sh( .arg(sanitize_sh(&tmpdir(build).join(&package_name).join("install.sh"))) .arg(format!("--prefix={}", sanitize_sh(&prefix))) .arg(format!("--sysconfdir={}", sanitize_sh(&sysconfdir))) + .arg(format!("--datadir={}", sanitize_sh(&datadir))) .arg(format!("--docdir={}", sanitize_sh(&docdir))) .arg(format!("--bindir={}", sanitize_sh(&bindir))) .arg(format!("--libdir={}", sanitize_sh(&libdir))) From 11915108810250f74e0d30ac6f12948a7e94e648 Mon Sep 17 00:00:00 2001 From: Mark Simulacrum Date: Sun, 11 Feb 2018 15:39:09 -0700 Subject: [PATCH 05/14] Remove ONLY_BUILD_TARGETS. All cases where it is used can be replaced by substituing run.host for run.builder.build.build; that is its only effect. As such, it is removable. --- src/bootstrap/builder.rs | 7 +------ src/bootstrap/dist.rs | 21 +++------------------ src/bootstrap/install.rs | 3 +-- 3 files changed, 5 insertions(+), 26 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 22656e5a9da4c..1e15d5393829f 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -60,9 +60,6 @@ pub trait Step: 'static + Clone + Debug + PartialEq + Eq + Hash { /// Run this rule for all hosts without cross compiling. const ONLY_HOSTS: bool = false; - /// Run this rule for all targets, but only with the native host. - const ONLY_BUILD_TARGETS: bool = false; - /// Only run this step with the build triple as host and target. const ONLY_BUILD: bool = false; @@ -101,7 +98,6 @@ pub struct RunConfig<'a> { struct StepDescription { default: bool, only_hosts: bool, - only_build_targets: bool, only_build: bool, should_run: fn(ShouldRun) -> ShouldRun, make_run: fn(RunConfig), @@ -138,7 +134,6 @@ impl StepDescription { StepDescription { default: S::DEFAULT, only_hosts: S::ONLY_HOSTS, - only_build_targets: S::ONLY_BUILD_TARGETS, only_build: S::ONLY_BUILD, should_run: S::should_run, make_run: S::make_run, @@ -155,7 +150,7 @@ impl StepDescription { self.name, builder.config.exclude); } let build = builder.build; - let hosts = if self.only_build_targets || self.only_build { + let hosts = if self.only_build { build.build_triple() } else { &build.hosts diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index aa0a7c52246ba..c3d8c9f8c010d 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -70,7 +70,6 @@ pub struct Docs { impl Step for Docs { type Output = PathBuf; const DEFAULT: bool = true; - const ONLY_BUILD_TARGETS: bool = true; fn should_run(run: ShouldRun) -> ShouldRun { run.path("src/doc") @@ -271,7 +270,6 @@ pub struct Mingw { impl Step for Mingw { type Output = Option; const DEFAULT: bool = true; - const ONLY_BUILD_TARGETS: bool = true; fn should_run(run: ShouldRun) -> ShouldRun { run.never() @@ -331,7 +329,6 @@ impl Step for Rustc { type Output = PathBuf; const DEFAULT: bool = true; const ONLY_HOSTS: bool = true; - const ONLY_BUILD_TARGETS: bool = true; fn should_run(run: ShouldRun) -> ShouldRun { run.path("src/librustc") @@ -561,7 +558,6 @@ pub struct Std { impl Step for Std { type Output = PathBuf; const DEFAULT: bool = true; - const ONLY_BUILD_TARGETS: bool = true; fn should_run(run: ShouldRun) -> ShouldRun { run.path("src/libstd") @@ -569,7 +565,7 @@ impl Step for Std { fn make_run(run: RunConfig) { run.builder.ensure(Std { - compiler: run.builder.compiler(run.builder.top_stage, run.host), + compiler: run.builder.compiler(run.builder.top_stage, run.builder.build.build), target: run.target, }); } @@ -638,7 +634,6 @@ pub struct Analysis { impl Step for Analysis { type Output = PathBuf; const DEFAULT: bool = true; - const ONLY_BUILD_TARGETS: bool = true; fn should_run(run: ShouldRun) -> ShouldRun { let builder = run.builder; @@ -647,7 +642,7 @@ impl Step for Analysis { fn make_run(run: RunConfig) { run.builder.ensure(Analysis { - compiler: run.builder.compiler(run.builder.top_stage, run.host), + compiler: run.builder.compiler(run.builder.top_stage, run.builder.build.build), target: run.target, }); } @@ -755,8 +750,6 @@ impl Step for Src { type Output = PathBuf; const DEFAULT: bool = true; const ONLY_HOSTS: bool = true; - const ONLY_BUILD_TARGETS: bool = true; - const ONLY_BUILD: bool = true; fn should_run(run: ShouldRun) -> ShouldRun { run.path("src") @@ -851,8 +844,6 @@ impl Step for PlainSourceTarball { type Output = PathBuf; const DEFAULT: bool = true; const ONLY_HOSTS: bool = true; - const ONLY_BUILD_TARGETS: bool = true; - const ONLY_BUILD: bool = true; fn should_run(run: ShouldRun) -> ShouldRun { let builder = run.builder; @@ -1007,7 +998,6 @@ pub struct Cargo { impl Step for Cargo { type Output = PathBuf; - const ONLY_BUILD_TARGETS: bool = true; const ONLY_HOSTS: bool = true; fn should_run(run: ShouldRun) -> ShouldRun { @@ -1095,7 +1085,6 @@ pub struct Rls { impl Step for Rls { type Output = Option; - const ONLY_BUILD_TARGETS: bool = true; const ONLY_HOSTS: bool = true; fn should_run(run: ShouldRun) -> ShouldRun { @@ -1177,7 +1166,6 @@ pub struct Rustfmt { impl Step for Rustfmt { type Output = Option; - const ONLY_BUILD_TARGETS: bool = true; const ONLY_HOSTS: bool = true; fn should_run(run: ShouldRun) -> ShouldRun { @@ -1263,7 +1251,6 @@ pub struct Extended { impl Step for Extended { type Output = (); const DEFAULT: bool = true; - const ONLY_BUILD_TARGETS: bool = true; const ONLY_HOSTS: bool = true; fn should_run(run: ShouldRun) -> ShouldRun { @@ -1274,7 +1261,7 @@ impl Step for Extended { fn make_run(run: RunConfig) { run.builder.ensure(Extended { stage: run.builder.top_stage, - host: run.host, + host: run.builder.build.build, target: run.target, }); } @@ -1692,9 +1679,7 @@ pub struct HashSign; impl Step for HashSign { type Output = (); - const ONLY_BUILD_TARGETS: bool = true; const ONLY_HOSTS: bool = true; - const ONLY_BUILD: bool = true; fn should_run(run: ShouldRun) -> ShouldRun { run.path("hash-and-sign") diff --git a/src/bootstrap/install.rs b/src/bootstrap/install.rs index 20f7d379a6967..fa48902d55893 100644 --- a/src/bootstrap/install.rs +++ b/src/bootstrap/install.rs @@ -161,7 +161,6 @@ macro_rules! install { impl Step for $name { type Output = (); const DEFAULT: bool = true; - const ONLY_BUILD_TARGETS: bool = true; const ONLY_HOSTS: bool = $only_hosts; $(const $c: bool = true;)* @@ -174,7 +173,7 @@ macro_rules! install { run.builder.ensure($name { stage: run.builder.top_stage, target: run.target, - host: run.host, + host: run.builder.build.build, }); } From 1c8f3b011cacdc2e5c614f9b05c509db4a4217db Mon Sep 17 00:00:00 2001 From: Mark Simulacrum Date: Sun, 11 Feb 2018 15:41:06 -0700 Subject: [PATCH 06/14] Remove ONLY_BUILD. All uses are replaced with not accessing run.target/run.host, and instead directly using run.builder.build.build. --- src/bootstrap/builder.rs | 13 +------------ src/bootstrap/install.rs | 33 +++++++++++++++++++++++++++++---- src/bootstrap/test.rs | 16 ++++------------ 3 files changed, 34 insertions(+), 28 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 1e15d5393829f..7da88bffa4b4a 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -60,9 +60,6 @@ pub trait Step: 'static + Clone + Debug + PartialEq + Eq + Hash { /// Run this rule for all hosts without cross compiling. const ONLY_HOSTS: bool = false; - /// Only run this step with the build triple as host and target. - const ONLY_BUILD: bool = false; - /// Primary function to execute this rule. Can call `builder.ensure(...)` /// with other steps to run those. fn run(self, builder: &Builder) -> Self::Output; @@ -98,7 +95,6 @@ pub struct RunConfig<'a> { struct StepDescription { default: bool, only_hosts: bool, - only_build: bool, should_run: fn(ShouldRun) -> ShouldRun, make_run: fn(RunConfig), name: &'static str, @@ -134,7 +130,6 @@ impl StepDescription { StepDescription { default: S::DEFAULT, only_hosts: S::ONLY_HOSTS, - only_build: S::ONLY_BUILD, should_run: S::should_run, make_run: S::make_run, name: unsafe { ::std::intrinsics::type_name::() }, @@ -150,18 +145,12 @@ impl StepDescription { self.name, builder.config.exclude); } let build = builder.build; - let hosts = if self.only_build { - build.build_triple() - } else { - &build.hosts - }; + let hosts = &build.hosts; // Determine the targets participating in this rule. let targets = if self.only_hosts { if build.config.run_host_only { &[] - } else if self.only_build { - build.build_triple() } else { &build.hosts } diff --git a/src/bootstrap/install.rs b/src/bootstrap/install.rs index fa48902d55893..17900fc35e095 100644 --- a/src/bootstrap/install.rs +++ b/src/bootstrap/install.rs @@ -225,10 +225,6 @@ install!((self, builder, _config), }); install_analysis(builder, self.stage, self.target); }; - Src, "src", Self::should_build(_config) , only_hosts: true, { - builder.ensure(dist::Src); - install_src(builder, self.stage); - }, ONLY_BUILD; Rustc, "src/librustc", true, only_hosts: true, { builder.ensure(dist::Rustc { compiler: builder.compiler(self.stage, self.target), @@ -236,3 +232,32 @@ install!((self, builder, _config), install_rustc(builder, self.stage, self.target); }; ); + +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct Src { + pub stage: u32, +} + +impl Step for Src { + type Output = (); + const DEFAULT: bool = true; + const ONLY_HOSTS: bool = true; + + fn should_run(run: ShouldRun) -> ShouldRun { + let config = &run.builder.config; + let cond = config.extended && + config.tools.as_ref().map_or(true, |t| t.contains("src")); + run.path("src").default_condition(cond) + } + + fn make_run(run: RunConfig) { + run.builder.ensure(Src { + stage: run.builder.top_stage, + }); + } + + fn run(self, builder: &Builder) { + builder.ensure(dist::Src); + install_src(builder, self.stage); + } +} diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 48490493525f9..7054c8005060c 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -505,27 +505,23 @@ impl Step for RustdocJS { } #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub struct Tidy { - host: Interned, -} +pub struct Tidy; impl Step for Tidy { type Output = (); const DEFAULT: bool = true; const ONLY_HOSTS: bool = true; - const ONLY_BUILD: bool = true; - /// Runs the `tidy` tool as compiled in `stage` by the `host` compiler. + /// Runs the `tidy` tool. /// /// This tool in `src/tools` checks up on various bits and pieces of style and /// otherwise just implements a few lint-like checks that are specific to the /// compiler itself. fn run(self, builder: &Builder) { let build = builder.build; - let host = self.host; let _folder = build.fold_output(|| "tidy"); - println!("tidy check ({})", host); + println!("tidy check"); let mut cmd = builder.tool_cmd(Tool::Tidy); cmd.arg(build.src.join("src")); cmd.arg(&build.initial_cargo); @@ -543,9 +539,7 @@ impl Step for Tidy { } fn make_run(run: RunConfig) { - run.builder.ensure(Tidy { - host: run.builder.build.build, - }); + run.builder.ensure(Tidy); } } @@ -1607,7 +1601,6 @@ pub struct Distcheck; impl Step for Distcheck { type Output = (); - const ONLY_BUILD: bool = true; fn should_run(run: ShouldRun) -> ShouldRun { run.path("distcheck") @@ -1673,7 +1666,6 @@ impl Step for Bootstrap { type Output = (); const DEFAULT: bool = true; const ONLY_HOSTS: bool = true; - const ONLY_BUILD: bool = true; /// Test the build system itself fn run(self, builder: &Builder) { From c8edb3652096bc3d294593375a5333503e6e86b1 Mon Sep 17 00:00:00 2001 From: Mark Simulacrum Date: Wed, 14 Feb 2018 18:50:11 -0700 Subject: [PATCH 07/14] Print out the sysroot and libdir on verbose builds. --- src/bootstrap/bin/rustc.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs index 6c3c48aba72f1..40e2ef41144f3 100644 --- a/src/bootstrap/bin/rustc.rs +++ b/src/bootstrap/bin/rustc.rs @@ -95,7 +95,7 @@ fn main() { let rustc = env::var_os(rustc).unwrap_or_else(|| panic!("{:?} was not set", rustc)); let libdir = env::var_os(libdir).unwrap_or_else(|| panic!("{:?} was not set", libdir)); let mut dylib_path = bootstrap::util::dylib_path(); - dylib_path.insert(0, PathBuf::from(libdir)); + dylib_path.insert(0, PathBuf::from(&libdir)); let mut cmd = Command::new(rustc); cmd.args(&args) @@ -107,7 +107,7 @@ fn main() { if let Some(target) = target { // The stage0 compiler has a special sysroot distinct from what we // actually downloaded, so we just always pass the `--sysroot` option. - cmd.arg("--sysroot").arg(sysroot); + cmd.arg("--sysroot").arg(&sysroot); // When we build Rust dylibs they're all intended for intermediate // usage, so make sure we pass the -Cprefer-dynamic flag instead of @@ -280,6 +280,8 @@ fn main() { if verbose > 1 { eprintln!("rustc command: {:?}", cmd); + eprintln!("sysroot: {:?}", sysroot); + eprintln!("libdir: {:?}", libdir); } // Actually run the compiler! From 9cfc73cd3ff9aa845b699eb6d66e76cd4e0cdef0 Mon Sep 17 00:00:00 2001 From: Mark Simulacrum Date: Thu, 15 Feb 2018 18:31:17 -0700 Subject: [PATCH 08/14] Deny warnings --- src/bootstrap/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index f3d9246c6fc6c..5cba65f7f0ad2 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -113,7 +113,7 @@ //! More documentation can be found in each respective module below, and you can //! also check out the `src/bootstrap/README.md` file for more information. -//#![deny(warnings)] +#![deny(warnings)] #![feature(core_intrinsics)] #[macro_use] From 29a852970bf6ac9abee1a637727ed03d1888d582 Mon Sep 17 00:00:00 2001 From: Mark Simulacrum Date: Sun, 11 Feb 2018 15:42:05 -0700 Subject: [PATCH 09/14] Refactor run_host_only to have the proper effect. Previously it was set to true when we didn't run HOSTS steps. --- src/bootstrap/builder.rs | 4 ++-- src/bootstrap/config.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 7da88bffa4b4a..74b9978a8373c 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -149,8 +149,8 @@ impl StepDescription { // Determine the targets participating in this rule. let targets = if self.only_hosts { - if build.config.run_host_only { - &[] + if !build.config.run_host_only { + return; // don't run anything } else { &build.hosts } diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index f15d4d3585839..eeafa6891cc87 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -347,7 +347,7 @@ impl Config { config.keep_stage = flags.keep_stage; // If --target was specified but --host wasn't specified, don't run any host-only tests. - config.run_host_only = flags.host.is_empty() && !flags.target.is_empty(); + config.run_host_only = !(flags.host.is_empty() && !flags.target.is_empty()); let toml = file.map(|file| { let mut f = t!(File::open(&file)); From a63bf3bb10117af94cc8189e9f228a81da5b432d Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 9 Mar 2018 14:08:59 +0100 Subject: [PATCH 10/14] Add missing urls --- src/liballoc/vec.rs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index 2f57c53a6d834..1bb2bed463b09 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -1212,8 +1212,9 @@ impl Vec { /// difference, with each additional slot filled with `value`. /// If `new_len` is less than `len`, the `Vec` is simply truncated. /// - /// This method requires `Clone` to clone the passed value. If you'd - /// rather create a value with `Default` instead, see [`resize_default`]. + /// This method requires [`Clone`] to be able clone the passed value. If + /// you'd rather create a value with [`Default`] instead, see + /// [`resize_default`]. /// /// # Examples /// @@ -1227,6 +1228,8 @@ impl Vec { /// assert_eq!(vec, [1, 2]); /// ``` /// + /// [`Clone`]: ../../std/clone/trait.Clone.html + /// [`Default`]: ../../std/default/trait.Default.html /// [`resize_default`]: #method.resize_default #[stable(feature = "vec_resize", since = "1.5.0")] pub fn resize(&mut self, new_len: usize, value: T) { @@ -1244,7 +1247,7 @@ impl Vec { /// Iterates over the slice `other`, clones each element, and then appends /// it to this `Vec`. The `other` vector is traversed in-order. /// - /// Note that this function is same as `extend` except that it is + /// Note that this function is same as [`extend`] except that it is /// specialized to work with slices instead. If and when Rust gets /// specialization this function will likely be deprecated (but still /// available). @@ -1256,6 +1259,8 @@ impl Vec { /// vec.extend_from_slice(&[2, 3, 4]); /// assert_eq!(vec, [1, 2, 3, 4]); /// ``` + /// + /// [`extend`]: #method.extend #[stable(feature = "vec_extend_from_slice", since = "1.6.0")] pub fn extend_from_slice(&mut self, other: &[T]) { self.spec_extend(other.iter()) @@ -1266,12 +1271,11 @@ impl Vec { /// Resizes the `Vec` in-place so that `len` is equal to `new_len`. /// /// If `new_len` is greater than `len`, the `Vec` is extended by the - /// difference, with each additional slot filled with `Default::default()`. + /// difference, with each additional slot filled with [`Default::default()`]. /// If `new_len` is less than `len`, the `Vec` is simply truncated. /// - /// This method uses `Default` to create new values on every push. If - /// you'd rather `Clone` a given value, use [`resize`]. - /// + /// This method uses [`Default`] to create new values on every push. If + /// you'd rather [`Clone`] a given value, use [`resize`]. /// /// # Examples /// @@ -1288,6 +1292,9 @@ impl Vec { /// ``` /// /// [`resize`]: #method.resize + /// [`Default::default()`]: ../../std/default/trait.Default.html#tymethod.default + /// [`Default`]: ../../std/default/trait.Default.html + /// [`Clone`]: ../../std/clone/trait.Clone.html #[unstable(feature = "vec_resize_default", issue = "41758")] pub fn resize_default(&mut self, new_len: usize) { let len = self.len(); From c1a73d2f4a8ef0003b93c4307930438be4aae9a5 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Fri, 9 Mar 2018 17:11:06 +0300 Subject: [PATCH 11/14] tidy: Add a check for stray `.stderr` and `.stdout` files in UI test directories --- .../ex3-both-anon-regions-4.stderr | 19 ------ .../propagate-approximated-to-empty.stderr | 45 -------------- src/test/ui/resolve-error.stderr | 62 ------------------- src/test/ui/span/loan-extend.stderr | 14 ----- src/tools/tidy/src/lib.rs | 1 + src/tools/tidy/src/main.rs | 1 + src/tools/tidy/src/ui_tests.rs | 26 ++++++++ 7 files changed, 28 insertions(+), 140 deletions(-) delete mode 100644 src/test/ui/lifetime-errors/ex3-both-anon-regions-4.stderr delete mode 100644 src/test/ui/nll/closure-requirements/propagate-approximated-to-empty.stderr delete mode 100644 src/test/ui/resolve-error.stderr delete mode 100644 src/test/ui/span/loan-extend.stderr create mode 100644 src/tools/tidy/src/ui_tests.rs diff --git a/src/test/ui/lifetime-errors/ex3-both-anon-regions-4.stderr b/src/test/ui/lifetime-errors/ex3-both-anon-regions-4.stderr deleted file mode 100644 index 19339800a7a98..0000000000000 --- a/src/test/ui/lifetime-errors/ex3-both-anon-regions-4.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0623]: lifetime mismatch - --> $DIR/ex3-both-anon-regions-4.rs:12:13 - | -11 | fn foo(z: &mut Vec<(&u8,&u8)>, (x, y): (&u8, &u8)) { - | --- --- these references are declared with different lifetimes... -12 | z.push((x,y)); - | ^ ...but data flows into `z` here - -error[E0623]: lifetime mismatch - --> $DIR/ex3-both-anon-regions-4.rs:12:15 - | -11 | fn foo(z: &mut Vec<(&u8,&u8)>, (x, y): (&u8, &u8)) { - | --- --- these references are declared with different lifetimes... -12 | z.push((x,y)); - | ^ ...but data flows into `z` here - -error: aborting due to 2 previous errors - -If you want more information on this error, try using "rustc --explain E0623" diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-to-empty.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-to-empty.stderr deleted file mode 100644 index 502b344c89e44..0000000000000 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-to-empty.stderr +++ /dev/null @@ -1,45 +0,0 @@ -warning: not reporting region error due to -Znll - --> $DIR/propagate-approximated-to-empty.rs:41:9 - | -41 | demand_y(x, y, x.get()) - | ^^^^^^^^^^^^^^^^^^^^^^^ - -error: free region `'_#6r` does not outlive free region `'_#4r` - --> $DIR/propagate-approximated-to-empty.rs:41:18 - | -41 | demand_y(x, y, x.get()) - | ^ - -note: No external requirements - --> $DIR/propagate-approximated-to-empty.rs:39:47 - | -39 | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { - | _______________________________________________^ -40 | | // Only works if 'x: 'y: -41 | | demand_y(x, y, x.get()) -42 | | //~^ WARN not reporting region error due to -Znll -43 | | //~| ERROR free region `'_#6r` does not outlive free region `'_#4r` -44 | | }); - | |_____^ - | - = note: defining type: DefId(0/1:18 ~ propagate_approximated_to_empty[317d]::supply[0]::{{closure}}[0]) with closure substs [ - i16, - for<'r, 's, 't0, 't1, 't2> extern "rust-call" fn((&ReLateBound(DebruijnIndex { depth: 1 }, BrNamed(crate0:DefIndex(0:0), 'r)) std::cell::Cell<&ReLateBound(DebruijnIndex { depth: 1 }, BrNamed(crate0:DefIndex(0:0), 's)) &'_#1r u32>, &ReLateBound(DebruijnIndex { depth: 1 }, BrNamed(crate0:DefIndex(0:0), 't0)) std::cell::Cell<&ReLateBound(DebruijnIndex { depth: 1 }, BrNamed(crate0:DefIndex(0:0), 't1)) u32>, &ReLateBound(DebruijnIndex { depth: 1 }, BrNamed(crate0:DefIndex(0:0), 't2)) std::cell::Cell<&ReLateBound(DebruijnIndex { depth: 1 }, BrNamed(crate0:DefIndex(0:0), 's)) u32>)) - ] - -note: No external requirements - --> $DIR/propagate-approximated-to-empty.rs:38:1 - | -38 | / fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { -39 | | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { -40 | | // Only works if 'x: 'y: -41 | | demand_y(x, y, x.get()) -... | -44 | | }); -45 | | } - | |_^ - | - = note: defining type: DefId(0/0:6 ~ propagate_approximated_to_empty[317d]::supply[0]) with substs [] - -error: aborting due to previous error - diff --git a/src/test/ui/resolve-error.stderr b/src/test/ui/resolve-error.stderr deleted file mode 100644 index 27f93939246c0..0000000000000 --- a/src/test/ui/resolve-error.stderr +++ /dev/null @@ -1,62 +0,0 @@ -error: cannot find derive macro `FooWithLongNan` in this scope - --> $DIR/resolve-error.rs:37:10 - | -37 | #[derive(FooWithLongNan)] - | ^^^^^^^^^^^^^^ help: try: `FooWithLongName` - -error: cannot find attribute macro `attr_proc_macra` in this scope - --> $DIR/resolve-error.rs:40:3 - | -40 | #[attr_proc_macra] - | ^^^^^^^^^^^^^^^ help: try: `attr_proc_macro` - -error: cannot find attribute macro `FooWithLongNan` in this scope - --> $DIR/resolve-error.rs:43:3 - | -43 | #[FooWithLongNan] - | ^^^^^^^^^^^^^^ - -error: cannot find derive macro `Dlone` in this scope - --> $DIR/resolve-error.rs:46:10 - | -46 | #[derive(Dlone)] - | ^^^^^ help: try: `Clone` - -error: cannot find derive macro `Dlona` in this scope - --> $DIR/resolve-error.rs:49:10 - | -49 | #[derive(Dlona)] - | ^^^^^ help: try: `Clona` - -error: cannot find derive macro `attr_proc_macra` in this scope - --> $DIR/resolve-error.rs:52:10 - | -52 | #[derive(attr_proc_macra)] - | ^^^^^^^^^^^^^^^ - -error: cannot find macro `FooWithLongNama!` in this scope - --> $DIR/resolve-error.rs:56:5 - | -56 | FooWithLongNama!(); - | ^^^^^^^^^^^^^^^ help: you could try the macro: `FooWithLongNam!` - -error: cannot find macro `attr_proc_macra!` in this scope - --> $DIR/resolve-error.rs:58:5 - | -58 | attr_proc_macra!(); - | ^^^^^^^^^^^^^^^ help: you could try the macro: `attr_proc_mac!` - -error: cannot find macro `Dlona!` in this scope - --> $DIR/resolve-error.rs:60:5 - | -60 | Dlona!(); - | ^^^^^ - -error: cannot find macro `bang_proc_macrp!` in this scope - --> $DIR/resolve-error.rs:62:5 - | -62 | bang_proc_macrp!(); - | ^^^^^^^^^^^^^^^ help: you could try the macro: `bang_proc_macro!` - -error: aborting due to previous error(s) - diff --git a/src/test/ui/span/loan-extend.stderr b/src/test/ui/span/loan-extend.stderr deleted file mode 100644 index af498129fc440..0000000000000 --- a/src/test/ui/span/loan-extend.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0597]: `short` does not live long enough - --> $DIR/loan-extend.rs:21:1 - | -19 | long = borrow(&mut short); - | ----- borrow occurs here -20 | -21 | } - | ^ `short` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error: aborting due to previous error - -If you want more information on this error, try using "rustc --explain E0597" diff --git a/src/tools/tidy/src/lib.rs b/src/tools/tidy/src/lib.rs index c927ff19b279b..06eb055f68e06 100644 --- a/src/tools/tidy/src/lib.rs +++ b/src/tools/tidy/src/lib.rs @@ -51,6 +51,7 @@ pub mod features; pub mod cargo; pub mod pal; pub mod deps; +pub mod ui_tests; pub mod unstable_book; fn filter_dirs(path: &Path) -> bool { diff --git a/src/tools/tidy/src/main.rs b/src/tools/tidy/src/main.rs index afa3ebd198319..2497419279560 100644 --- a/src/tools/tidy/src/main.rs +++ b/src/tools/tidy/src/main.rs @@ -45,6 +45,7 @@ fn main() { deps::check(&path, &mut bad); } deps::check_whitelist(&path, &cargo, &mut bad); + ui_tests::check(&path, &mut bad); if bad { eprintln!("some tidy checks failed"); diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs new file mode 100644 index 0000000000000..f7fec2e667ab9 --- /dev/null +++ b/src/tools/tidy/src/ui_tests.rs @@ -0,0 +1,26 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Tidy check to ensure that there are no stray `.stderr` files in UI test directories. + +use std::path::Path; + +pub fn check(path: &Path, bad: &mut bool) { + super::walk_many(&[&path.join("test/ui"), &path.join("test/ui-fulldeps")], + &mut |_| false, + &mut |file_path| { + if let Some(ext) = file_path.extension() { + if (ext == "stderr" || ext == "stdout") && !file_path.with_extension("rs").exists() { + println!("Stray file with UI testing output: {:?}", file_path); + *bad = true; + } + } + }); +} From 6235ef04222d33aa9a48876098ba335f867856da Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 5 Mar 2018 22:40:43 +0100 Subject: [PATCH 12/14] Add missing items in the sidebar for functions --- src/librustdoc/html/render.rs | 51 ++++++++++++--------------- src/librustdoc/html/static/main.js | 56 ++++++++++++++++-------------- src/test/rustdoc/fn-sidebar.rs | 19 ++++++++++ 3 files changed, 71 insertions(+), 55 deletions(-) create mode 100644 src/test/rustdoc/fn-sidebar.rs diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index e7bb0b03ce248..96bba956c5d55 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -3500,11 +3500,9 @@ impl<'a> fmt::Display for Sidebar<'a> { let cx = self.cx; let it = self.item; let parentlen = cx.current.len() - if it.is_mod() {1} else {0}; - let mut should_close = false; if it.is_struct() || it.is_trait() || it.is_primitive() || it.is_union() - || it.is_enum() || it.is_mod() || it.is_typedef() - { + || it.is_enum() || it.is_mod() || it.is_typedef() { write!(fmt, "

")?; match it.inner { clean::StructItem(..) => write!(fmt, "Struct ")?, @@ -3523,30 +3521,29 @@ impl<'a> fmt::Display for Sidebar<'a> { } write!(fmt, "{}", it.name.as_ref().unwrap())?; write!(fmt, "

")?; + } - if it.is_crate() { - if let Some(ref version) = cache().crate_version { - write!(fmt, - "
\ -

Version {}

\ -
", - version)?; - } + if it.is_crate() { + if let Some(ref version) = cache().crate_version { + write!(fmt, + "
\ +

Version {}

\ +
", + version)?; } + } - write!(fmt, "
")?; - should_close = true; - match it.inner { - clean::StructItem(ref s) => sidebar_struct(fmt, it, s)?, - clean::TraitItem(ref t) => sidebar_trait(fmt, it, t)?, - clean::PrimitiveItem(ref p) => sidebar_primitive(fmt, it, p)?, - clean::UnionItem(ref u) => sidebar_union(fmt, it, u)?, - clean::EnumItem(ref e) => sidebar_enum(fmt, it, e)?, - clean::TypedefItem(ref t, _) => sidebar_typedef(fmt, it, t)?, - clean::ModuleItem(ref m) => sidebar_module(fmt, it, &m.items)?, - clean::ForeignTypeItem => sidebar_foreign_type(fmt, it)?, - _ => (), - } + write!(fmt, "
")?; + match it.inner { + clean::StructItem(ref s) => sidebar_struct(fmt, it, s)?, + clean::TraitItem(ref t) => sidebar_trait(fmt, it, t)?, + clean::PrimitiveItem(ref p) => sidebar_primitive(fmt, it, p)?, + clean::UnionItem(ref u) => sidebar_union(fmt, it, u)?, + clean::EnumItem(ref e) => sidebar_enum(fmt, it, e)?, + clean::TypedefItem(ref t, _) => sidebar_typedef(fmt, it, t)?, + clean::ModuleItem(ref m) => sidebar_module(fmt, it, &m.items)?, + clean::ForeignTypeItem => sidebar_foreign_type(fmt, it)?, + _ => (), } // The sidebar is designed to display sibling functions, modules and @@ -3586,10 +3583,8 @@ impl<'a> fmt::Display for Sidebar<'a> { write!(fmt, "", path = relpath)?; } - if should_close { - // Closes sidebar-elems div. - write!(fmt, "
")?; - } + // Closes sidebar-elems div. + write!(fmt, "
")?; Ok(()) } diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 36ca1e06f241c..3f74ffbbe0b16 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -1457,36 +1457,38 @@ // Draw a convenient sidebar of known crates if we have a listing if (rootPath === '../') { var sidebar = document.getElementsByClassName('sidebar-elems')[0]; - var div = document.createElement('div'); - div.className = 'block crate'; - div.innerHTML = '

Crates

'; - var ul = document.createElement('ul'); - div.appendChild(ul); - - var crates = []; - for (var crate in rawSearchIndex) { - if (!rawSearchIndex.hasOwnProperty(crate)) { - continue; + if (sidebar) { + var div = document.createElement('div'); + div.className = 'block crate'; + div.innerHTML = '

Crates

'; + var ul = document.createElement('ul'); + div.appendChild(ul); + + var crates = []; + for (var crate in rawSearchIndex) { + if (!rawSearchIndex.hasOwnProperty(crate)) { + continue; + } + crates.push(crate); } - crates.push(crate); - } - crates.sort(); - for (var i = 0; i < crates.length; ++i) { - var klass = 'crate'; - if (crates[i] === window.currentCrate) { - klass += ' current'; + crates.sort(); + for (var i = 0; i < crates.length; ++i) { + var klass = 'crate'; + if (crates[i] === window.currentCrate) { + klass += ' current'; + } + var link = document.createElement('a'); + link.href = '../' + crates[i] + '/index.html'; + link.title = rawSearchIndex[crates[i]].doc; + link.className = klass; + link.textContent = crates[i]; + + var li = document.createElement('li'); + li.appendChild(link); + ul.appendChild(li); } - var link = document.createElement('a'); - link.href = '../' + crates[i] + '/index.html'; - link.title = rawSearchIndex[crates[i]].doc; - link.className = klass; - link.textContent = crates[i]; - - var li = document.createElement('li'); - li.appendChild(link); - ul.appendChild(li); + sidebar.appendChild(div); } - sidebar.appendChild(div); } } diff --git a/src/test/rustdoc/fn-sidebar.rs b/src/test/rustdoc/fn-sidebar.rs new file mode 100644 index 0000000000000..4da277a204b71 --- /dev/null +++ b/src/test/rustdoc/fn-sidebar.rs @@ -0,0 +1,19 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name = "foo"] + +// @has foo/fn.bar.html +// @has - '//*[@class="sidebar-elems"]' '' +pub fn bar() {} + +// @has foo/constant.BAR.html +// @has - '//*[@class="sidebar-elems"]' '' +pub const BAR: u32 = 0; From 9e0ccc5a479644bf35ffe04717d6e100fde74fcc Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 5 Mar 2018 23:37:33 +0100 Subject: [PATCH 13/14] Fix escape not working when searchbar selected --- src/librustdoc/html/static/main.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 3f74ffbbe0b16..f1c9c58a4ebcf 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -240,12 +240,15 @@ } function handleShortcut(ev) { - if (document.activeElement.tagName === "INPUT") + if (document.activeElement.tagName === "INPUT" && + hasClass(document.getElementById('main'), "hidden")) { return; + } // Don't interfere with browser shortcuts - if (ev.ctrlKey || ev.altKey || ev.metaKey) + if (ev.ctrlKey || ev.altKey || ev.metaKey) { return; + } var help = document.getElementById("help"); switch (getVirtualKey(ev)) { @@ -1800,7 +1803,7 @@ if (!next) { return; } - if (checkIfThereAreMethods(next.childNodes) && + if ((checkIfThereAreMethods(next.childNodes) || hasClass(e, 'method')) && (hasClass(next, 'docblock') || hasClass(e, 'impl') || (hasClass(next, 'stability') && From 89f4f1bca1267ae42fcd2aa85dcdf5d348565038 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 6 Mar 2018 22:05:41 +0100 Subject: [PATCH 14/14] Fix anchor not always being put at the right place --- src/librustdoc/html/static/rustdoc.css | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index b70dc37fdd55e..8060fbc1ee043 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -528,6 +528,9 @@ a { .anchor.field { left: -5px; } +.small-section-header > .anchor { + left: -28px; +} .anchor:before { content: '\2002\00a7\2002'; }