Skip to content

Commit

Permalink
Auto merge of #68101 - JohnTitor:rollup-mvmjukr, r=JohnTitor
Browse files Browse the repository at this point in the history
Rollup of 8 pull requests

Successful merges:

 - #66045 (Add method Result::into_ok)
 - #67258 (Introduce `X..`, `..X`, and `..=X` range patterns)
 - #68014 (Unify output of "variant not found" errors)
 - #68019 (Build compiletest with in-tree libtest)
 - #68039 (remove explicit strip-hidden pass from compiler doc generation)
 - #68050 (Canonicalize rustc_error imports)
 - #68059 (Allow specifying LLVM args in target specifications)
 - #68075 (rustbuild: Cleanup book generation)

Failed merges:

 - #68089 (Unstabilize `Vec::remove_item`)

r? @ghost
  • Loading branch information
bors committed Jan 10, 2020
2 parents ac6eb0d + bcfb380 commit 1756313
Show file tree
Hide file tree
Showing 352 changed files with 2,785 additions and 1,474 deletions.
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3654,6 +3654,7 @@ dependencies = [
"log",
"rustc",
"rustc_data_structures",
"rustc_errors",
"rustc_feature",
"rustc_hir",
"rustc_index",
Expand Down
88 changes: 15 additions & 73 deletions src/bootstrap/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ macro_rules! book {
builder.ensure(RustbookSrc {
target: self.target,
name: INTERNER.intern_str($book_name),
src: doc_src(builder),
src: INTERNER.intern_path(builder.src.join($path)),
})
}
}
Expand All @@ -60,6 +60,7 @@ macro_rules! book {
// NOTE: When adding a book here, make sure to ALSO build the book by
// adding a build step in `src/bootstrap/builder.rs`!
book!(
CargoBook, "src/tools/cargo/src/doc", "cargo";
EditionGuide, "src/doc/edition-guide", "edition-guide";
EmbeddedBook, "src/doc/embedded-book", "embedded-book";
Nomicon, "src/doc/nomicon", "nomicon";
Expand All @@ -69,10 +70,6 @@ book!(
RustdocBook, "src/doc/rustdoc", "rustdoc";
);

fn doc_src(builder: &Builder<'_>) -> Interned<PathBuf> {
INTERNER.intern_path(builder.src.join("src/doc"))
}

#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct UnstableBook {
target: Interned<String>,
Expand All @@ -96,48 +93,11 @@ impl Step for UnstableBook {
builder.ensure(RustbookSrc {
target: self.target,
name: INTERNER.intern_str("unstable-book"),
src: builder.md_doc_out(self.target),
src: INTERNER.intern_path(builder.md_doc_out(self.target).join("unstable-book")),
})
}
}

#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct CargoBook {
target: Interned<String>,
name: Interned<String>,
}

impl Step for CargoBook {
type Output = ();
const DEFAULT: bool = true;

fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
let builder = run.builder;
run.path("src/tools/cargo/src/doc/book").default_condition(builder.config.docs)
}

fn make_run(run: RunConfig<'_>) {
run.builder.ensure(CargoBook { target: run.target, name: INTERNER.intern_str("cargo") });
}

fn run(self, builder: &Builder<'_>) {
let target = self.target;
let name = self.name;
let src = builder.src.join("src/tools/cargo/src/doc");

let out = builder.doc_out(target);
t!(fs::create_dir_all(&out));

let out = out.join(name);

builder.info(&format!("Cargo Book ({}) - {}", target, name));

let _ = fs::remove_dir_all(&out);

builder.run(builder.tool_cmd(Tool::Rustbook).arg("build").arg(&src).arg("-d").arg(out));
}
}

#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
struct RustbookSrc {
target: Interned<String>,
Expand All @@ -164,7 +124,6 @@ impl Step for RustbookSrc {
t!(fs::create_dir_all(&out));

let out = out.join(name);
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);
Expand All @@ -182,7 +141,6 @@ impl Step for RustbookSrc {
pub struct TheBook {
compiler: Compiler,
target: Interned<String>,
name: &'static str,
}

impl Step for TheBook {
Expand All @@ -198,53 +156,37 @@ impl Step for TheBook {
run.builder.ensure(TheBook {
compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build),
target: run.target,
name: "book",
});
}

/// Builds the book and associated stuff.
///
/// We need to build:
///
/// * Book (first edition)
/// * Book (second edition)
/// * Book
/// * Older edition redirects
/// * Version info and CSS
/// * Index page
/// * Redirect pages
fn run(self, builder: &Builder<'_>) {
let compiler = self.compiler;
let target = self.target;
let name = self.name;

// build book
builder.ensure(RustbookSrc {
target,
name: INTERNER.intern_string(name.to_string()),
src: doc_src(builder),
name: INTERNER.intern_str("book"),
src: INTERNER.intern_path(builder.src.join("src/doc/book")),
});

// building older edition redirects

let source_name = format!("{}/first-edition", name);
builder.ensure(RustbookSrc {
target,
name: INTERNER.intern_string(source_name),
src: doc_src(builder),
});

let source_name = format!("{}/second-edition", name);
builder.ensure(RustbookSrc {
target,
name: INTERNER.intern_string(source_name),
src: doc_src(builder),
});

let source_name = format!("{}/2018-edition", name);
builder.ensure(RustbookSrc {
target,
name: INTERNER.intern_string(source_name),
src: doc_src(builder),
});
for edition in &["first-edition", "second-edition", "2018-edition"] {
builder.ensure(RustbookSrc {
target,
name: INTERNER.intern_string(format!("book/{}", edition)),
src: INTERNER.intern_path(builder.src.join("src/doc/book").join(edition)),
});
}

// build the version info page and CSS
builder.ensure(Standalone { compiler, target });
Expand Down Expand Up @@ -531,7 +473,7 @@ impl Step for Rustc {

// Build cargo command.
let mut cargo = builder.cargo(compiler, Mode::Rustc, target, "doc");
cargo.env("RUSTDOCFLAGS", "--document-private-items --passes strip-hidden");
cargo.env("RUSTDOCFLAGS", "--document-private-items");
compile::rustc_cargo(builder, &mut cargo, target);

// Only include compiler crates, no dependencies of those, such as `libc`.
Expand Down
20 changes: 8 additions & 12 deletions src/bootstrap/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,8 @@ fn rustbook_features() -> Vec<String> {
macro_rules! bootstrap_tool {
($(
$name:ident, $path:expr, $tool_name:expr
$(,llvm_tools = $llvm:expr)*
$(,is_external_tool = $external:expr)*
$(,is_unstable_tool = $unstable:expr)*
$(,features = $features:expr)*
;
)+) => {
Expand All @@ -301,15 +301,6 @@ macro_rules! bootstrap_tool {
)+
}

impl Tool {
/// Whether this tool requires LLVM to run
pub fn uses_llvm_tools(&self) -> bool {
match self {
$(Tool::$name => false $(|| $llvm)*,)+
}
}
}

impl<'a> Builder<'a> {
pub fn tool_exe(&self, tool: Tool) -> PathBuf {
match tool {
Expand Down Expand Up @@ -350,7 +341,12 @@ macro_rules! bootstrap_tool {
compiler: self.compiler,
target: self.target,
tool: $tool_name,
mode: Mode::ToolBootstrap,
mode: if false $(|| $unstable)* {
// use in-tree libraries for unstable features
Mode::ToolStd
} else {
Mode::ToolBootstrap
},
path: $path,
is_optional_tool: false,
source_type: if false $(|| $external)* {
Expand All @@ -377,7 +373,7 @@ bootstrap_tool!(
Tidy, "src/tools/tidy", "tidy";
Linkchecker, "src/tools/linkchecker", "linkchecker";
CargoTest, "src/tools/cargotest", "cargotest";
Compiletest, "src/tools/compiletest", "compiletest", llvm_tools = true;
Compiletest, "src/tools/compiletest", "compiletest", is_unstable_tool = true;
BuildManifest, "src/tools/build-manifest", "build-manifest";
RemoteTestClient, "src/tools/remote-test-client", "remote-test-client";
RustInstaller, "src/tools/rust-installer", "fabricate", is_external_tool = true;
Expand Down
38 changes: 38 additions & 0 deletions src/libcore/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,44 @@ impl<T: Default, E> Result<T, E> {
}
}

#[unstable(feature = "unwrap_infallible", reason = "newly added", issue = "61695")]
impl<T, E: Into<!>> Result<T, E> {
/// Unwraps a result that can never be an [`Err`], yielding the content of the [`Ok`].
///
/// Unlike [`unwrap`], this method is known to never panic on the
/// result types it is implemented for. Therefore, it can be used
/// instead of `unwrap` as a maintainability safeguard that will fail
/// to compile if the error type of the `Result` is later changed
/// to an error that can actually occur.
///
/// [`Ok`]: enum.Result.html#variant.Ok
/// [`Err`]: enum.Result.html#variant.Err
/// [`unwrap`]: enum.Result.html#method.unwrap
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// # #![feature(never_type)]
/// # #![feature(unwrap_infallible)]
///
/// fn only_good_news() -> Result<String, !> {
/// Ok("this is fine".into())
/// }
///
/// let s: String = only_good_news().into_ok();
/// println!("{}", s);
/// ```
#[inline]
pub fn into_ok(self) -> T {
match self {
Ok(x) => x,
Err(e) => e.into(),
}
}
}

#[unstable(feature = "inner_deref", reason = "newly added", issue = "50264")]
impl<T: Deref, E> Result<T, E> {
/// Converts from `Result<T, E>` (or `&Result<T, E>`) to `Result<&T::Target, &E>`.
Expand Down
2 changes: 2 additions & 0 deletions src/libcore/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
#![feature(slice_from_raw_parts)]
#![feature(const_slice_from_raw_parts)]
#![feature(const_raw_ptr_deref)]
#![feature(never_type)]
#![feature(unwrap_infallible)]

extern crate test;

Expand Down
22 changes: 22 additions & 0 deletions src/libcore/tests/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,28 @@ pub fn test_unwrap_or_default() {
assert_eq!(op2().unwrap_or_default(), 0);
}

#[test]
pub fn test_into_ok() {
fn infallible_op() -> Result<isize, !> {
Ok(666)
}

assert_eq!(infallible_op().into_ok(), 666);

enum MyNeverToken {}
impl From<MyNeverToken> for ! {
fn from(never: MyNeverToken) -> ! {
match never {}
}
}

fn infallible_op2() -> Result<isize, MyNeverToken> {
Ok(667)
}

assert_eq!(infallible_op2().into_ok(), 667);
}

#[test]
fn test_try() {
fn try_result_some() -> Option<u8> {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ rustc_hir = { path = "../librustc_hir" }
rustc_target = { path = "../librustc_target" }
rustc_macros = { path = "../librustc_macros" }
rustc_data_structures = { path = "../librustc_data_structures" }
rustc_errors = { path = "../librustc_errors" }
rustc_index = { path = "../librustc_index" }
errors = { path = "../librustc_errors", package = "rustc_errors" }
rustc_serialize = { path = "../libserialize", package = "serialize" }
syntax = { path = "../libsyntax" }
rustc_span = { path = "../librustc_span" }
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/dep_graph/graph.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::ty::{self, TyCtxt};
use errors::Diagnostic;
use parking_lot::{Condvar, Mutex};
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::profiling::QueryInvocationId;
use rustc_data_structures::sharded::{self, Sharded};
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::{AtomicU32, AtomicU64, Lock, Lrc, Ordering};
use rustc_errors::Diagnostic;
use rustc_index::vec::{Idx, IndexVec};
use smallvec::SmallVec;
use std::collections::hash_map::Entry;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use crate::lint::builtin::UNUSED_ATTRIBUTES;
use crate::ty::query::Providers;
use crate::ty::TyCtxt;

use errors::struct_span_err;
use rustc_error_codes::*;
use rustc_errors::struct_span_err;
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
Expand Down
10 changes: 4 additions & 6 deletions src/librustc/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,13 @@ use crate::ty::{
subst::{Subst, SubstsRef},
Region, Ty, TyCtxt, TypeFoldable,
};
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_error_codes::*;
use rustc_errors::{pluralize, struct_span_err};
use rustc_errors::{Applicability, DiagnosticBuilder, DiagnosticStyledString};
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
use rustc_hir::Node;

use errors::{
pluralize, struct_span_err, Applicability, DiagnosticBuilder, DiagnosticStyledString,
};
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_error_codes::*;
use rustc_span::{DesugaringKind, Pos, Span};
use rustc_target::spec::abi;
use std::{cmp, fmt};
Expand Down
12 changes: 6 additions & 6 deletions src/librustc/infer/error_reporting/need_type_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::infer::type_variable::TypeVariableOriginKind;
use crate::infer::InferCtxt;
use crate::ty::print::Print;
use crate::ty::{self, DefIdTree, Infer, Ty, TyVar};
use errors::{struct_span_err, Applicability, DiagnosticBuilder};
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder};
use rustc_hir as hir;
use rustc_hir::def::{DefKind, Namespace};
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
Expand Down Expand Up @@ -151,12 +151,12 @@ pub enum TypeAnnotationNeeded {
E0284,
}

impl Into<errors::DiagnosticId> for TypeAnnotationNeeded {
fn into(self) -> errors::DiagnosticId {
impl Into<rustc_errors::DiagnosticId> for TypeAnnotationNeeded {
fn into(self) -> rustc_errors::DiagnosticId {
match self {
Self::E0282 => errors::error_code!(E0282),
Self::E0283 => errors::error_code!(E0283),
Self::E0284 => errors::error_code!(E0284),
Self::E0282 => rustc_errors::error_code!(E0282),
Self::E0283 => rustc_errors::error_code!(E0283),
Self::E0284 => rustc_errors::error_code!(E0284),
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use crate::infer::error_reporting::nice_region_error::util::AnonymousParamInfo;
use crate::infer::error_reporting::nice_region_error::NiceRegionError;
use crate::util::common::ErrorReported;

use errors::struct_span_err;
use rustc_error_codes::*;
use rustc_errors::struct_span_err;

impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
/// Print the error message for lifetime errors when both the concerned regions are anonymous.
Expand Down
Loading

0 comments on commit 1756313

Please sign in to comment.