Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 8 pull requests #68101

Merged
merged 20 commits into from
Jan 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
a20013b
Add Result::unwrap_infallible
mzabaluev Nov 2, 2019
9a99a21
libcore: test Result::unwrap_infallible
mzabaluev Nov 2, 2019
6f0672c
Rename Result::unwrap_infallible to into_ok
mzabaluev Nov 4, 2019
2c5766f
Unify output of "variant not found" errors
estebank Jan 8, 2020
7c52718
Remove obsolete llvm_tools flag
cuviper Jan 8, 2020
51b7044
Build compiletest with in-tree libtest
cuviper Jan 8, 2020
686d5f8
Comment on allowing only feature(test) in compiletest
cuviper Jan 8, 2020
8267807
remove strip-hidden pass from compiler doc generation
euclio Jan 9, 2020
870ca31
rustbuild: Cleanup book generation
ollie27 Jan 9, 2020
d5598aa
Introduce `#![feature(half_open_range_patterns)]`.
Centril Dec 11, 2019
8bd3d24
nix syntax::errors & prefer rustc_errors over errors
Centril Jan 9, 2020
afced94
Allow specifying LLVM args in target specifications
Jan 9, 2020
2dbcf08
Rollup merge of #66045 - mzabaluev:unwrap-infallible, r=dtolnay
JohnTitor Jan 10, 2020
793b1be
Rollup merge of #67258 - Centril:open-ended-ranges, r=oli-obk
JohnTitor Jan 10, 2020
a491100
Rollup merge of #68014 - estebank:unify-e0599, r=cramertj
JohnTitor Jan 10, 2020
a74c790
Rollup merge of #68019 - cuviper:in-tree-compiletest, r=Mark-Simulacrum
JohnTitor Jan 10, 2020
93f0ba9
Rollup merge of #68039 - euclio:remove-strip-hidden, r=dtolnay
JohnTitor Jan 10, 2020
7ae0618
Rollup merge of #68050 - Centril:canon-error, r=Mark-Simulacrum
JohnTitor Jan 10, 2020
1af7524
Rollup merge of #68059 - jethrogb:jb/target-llvm-args, r=alexcrichton
JohnTitor Jan 10, 2020
bcfb380
Rollup merge of #68075 - ollie27:rustbuild_books, r=Mark-Simulacrum
JohnTitor Jan 10, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
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