Skip to content

Commit 1756313

Browse files
committed
Auto merge of #68101 - JohnTitor:rollup-mvmjukr, r=JohnTitor
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
2 parents ac6eb0d + bcfb380 commit 1756313

File tree

352 files changed

+2785
-1474
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

352 files changed

+2785
-1474
lines changed

Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -3654,6 +3654,7 @@ dependencies = [
36543654
"log",
36553655
"rustc",
36563656
"rustc_data_structures",
3657+
"rustc_errors",
36573658
"rustc_feature",
36583659
"rustc_hir",
36593660
"rustc_index",

src/bootstrap/doc.rs

+15-73
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ macro_rules! book {
4949
builder.ensure(RustbookSrc {
5050
target: self.target,
5151
name: INTERNER.intern_str($book_name),
52-
src: doc_src(builder),
52+
src: INTERNER.intern_path(builder.src.join($path)),
5353
})
5454
}
5555
}
@@ -60,6 +60,7 @@ macro_rules! book {
6060
// NOTE: When adding a book here, make sure to ALSO build the book by
6161
// adding a build step in `src/bootstrap/builder.rs`!
6262
book!(
63+
CargoBook, "src/tools/cargo/src/doc", "cargo";
6364
EditionGuide, "src/doc/edition-guide", "edition-guide";
6465
EmbeddedBook, "src/doc/embedded-book", "embedded-book";
6566
Nomicon, "src/doc/nomicon", "nomicon";
@@ -69,10 +70,6 @@ book!(
6970
RustdocBook, "src/doc/rustdoc", "rustdoc";
7071
);
7172

72-
fn doc_src(builder: &Builder<'_>) -> Interned<PathBuf> {
73-
INTERNER.intern_path(builder.src.join("src/doc"))
74-
}
75-
7673
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
7774
pub struct UnstableBook {
7875
target: Interned<String>,
@@ -96,48 +93,11 @@ impl Step for UnstableBook {
9693
builder.ensure(RustbookSrc {
9794
target: self.target,
9895
name: INTERNER.intern_str("unstable-book"),
99-
src: builder.md_doc_out(self.target),
96+
src: INTERNER.intern_path(builder.md_doc_out(self.target).join("unstable-book")),
10097
})
10198
}
10299
}
103100

104-
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
105-
pub struct CargoBook {
106-
target: Interned<String>,
107-
name: Interned<String>,
108-
}
109-
110-
impl Step for CargoBook {
111-
type Output = ();
112-
const DEFAULT: bool = true;
113-
114-
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
115-
let builder = run.builder;
116-
run.path("src/tools/cargo/src/doc/book").default_condition(builder.config.docs)
117-
}
118-
119-
fn make_run(run: RunConfig<'_>) {
120-
run.builder.ensure(CargoBook { target: run.target, name: INTERNER.intern_str("cargo") });
121-
}
122-
123-
fn run(self, builder: &Builder<'_>) {
124-
let target = self.target;
125-
let name = self.name;
126-
let src = builder.src.join("src/tools/cargo/src/doc");
127-
128-
let out = builder.doc_out(target);
129-
t!(fs::create_dir_all(&out));
130-
131-
let out = out.join(name);
132-
133-
builder.info(&format!("Cargo Book ({}) - {}", target, name));
134-
135-
let _ = fs::remove_dir_all(&out);
136-
137-
builder.run(builder.tool_cmd(Tool::Rustbook).arg("build").arg(&src).arg("-d").arg(out));
138-
}
139-
}
140-
141101
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
142102
struct RustbookSrc {
143103
target: Interned<String>,
@@ -164,7 +124,6 @@ impl Step for RustbookSrc {
164124
t!(fs::create_dir_all(&out));
165125

166126
let out = out.join(name);
167-
let src = src.join(name);
168127
let index = out.join("index.html");
169128
let rustbook = builder.tool_exe(Tool::Rustbook);
170129
let mut rustbook_cmd = builder.tool_cmd(Tool::Rustbook);
@@ -182,7 +141,6 @@ impl Step for RustbookSrc {
182141
pub struct TheBook {
183142
compiler: Compiler,
184143
target: Interned<String>,
185-
name: &'static str,
186144
}
187145

188146
impl Step for TheBook {
@@ -198,53 +156,37 @@ impl Step for TheBook {
198156
run.builder.ensure(TheBook {
199157
compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build),
200158
target: run.target,
201-
name: "book",
202159
});
203160
}
204161

205162
/// Builds the book and associated stuff.
206163
///
207164
/// We need to build:
208165
///
209-
/// * Book (first edition)
210-
/// * Book (second edition)
166+
/// * Book
167+
/// * Older edition redirects
211168
/// * Version info and CSS
212169
/// * Index page
213170
/// * Redirect pages
214171
fn run(self, builder: &Builder<'_>) {
215172
let compiler = self.compiler;
216173
let target = self.target;
217-
let name = self.name;
218174

219175
// build book
220176
builder.ensure(RustbookSrc {
221177
target,
222-
name: INTERNER.intern_string(name.to_string()),
223-
src: doc_src(builder),
178+
name: INTERNER.intern_str("book"),
179+
src: INTERNER.intern_path(builder.src.join("src/doc/book")),
224180
});
225181

226182
// building older edition redirects
227-
228-
let source_name = format!("{}/first-edition", name);
229-
builder.ensure(RustbookSrc {
230-
target,
231-
name: INTERNER.intern_string(source_name),
232-
src: doc_src(builder),
233-
});
234-
235-
let source_name = format!("{}/second-edition", name);
236-
builder.ensure(RustbookSrc {
237-
target,
238-
name: INTERNER.intern_string(source_name),
239-
src: doc_src(builder),
240-
});
241-
242-
let source_name = format!("{}/2018-edition", name);
243-
builder.ensure(RustbookSrc {
244-
target,
245-
name: INTERNER.intern_string(source_name),
246-
src: doc_src(builder),
247-
});
183+
for edition in &["first-edition", "second-edition", "2018-edition"] {
184+
builder.ensure(RustbookSrc {
185+
target,
186+
name: INTERNER.intern_string(format!("book/{}", edition)),
187+
src: INTERNER.intern_path(builder.src.join("src/doc/book").join(edition)),
188+
});
189+
}
248190

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

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

537479
// Only include compiler crates, no dependencies of those, such as `libc`.

src/bootstrap/tool.rs

+8-12
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,8 @@ fn rustbook_features() -> Vec<String> {
289289
macro_rules! bootstrap_tool {
290290
($(
291291
$name:ident, $path:expr, $tool_name:expr
292-
$(,llvm_tools = $llvm:expr)*
293292
$(,is_external_tool = $external:expr)*
293+
$(,is_unstable_tool = $unstable:expr)*
294294
$(,features = $features:expr)*
295295
;
296296
)+) => {
@@ -301,15 +301,6 @@ macro_rules! bootstrap_tool {
301301
)+
302302
}
303303

304-
impl Tool {
305-
/// Whether this tool requires LLVM to run
306-
pub fn uses_llvm_tools(&self) -> bool {
307-
match self {
308-
$(Tool::$name => false $(|| $llvm)*,)+
309-
}
310-
}
311-
}
312-
313304
impl<'a> Builder<'a> {
314305
pub fn tool_exe(&self, tool: Tool) -> PathBuf {
315306
match tool {
@@ -350,7 +341,12 @@ macro_rules! bootstrap_tool {
350341
compiler: self.compiler,
351342
target: self.target,
352343
tool: $tool_name,
353-
mode: Mode::ToolBootstrap,
344+
mode: if false $(|| $unstable)* {
345+
// use in-tree libraries for unstable features
346+
Mode::ToolStd
347+
} else {
348+
Mode::ToolBootstrap
349+
},
354350
path: $path,
355351
is_optional_tool: false,
356352
source_type: if false $(|| $external)* {
@@ -377,7 +373,7 @@ bootstrap_tool!(
377373
Tidy, "src/tools/tidy", "tidy";
378374
Linkchecker, "src/tools/linkchecker", "linkchecker";
379375
CargoTest, "src/tools/cargotest", "cargotest";
380-
Compiletest, "src/tools/compiletest", "compiletest", llvm_tools = true;
376+
Compiletest, "src/tools/compiletest", "compiletest", is_unstable_tool = true;
381377
BuildManifest, "src/tools/build-manifest", "build-manifest";
382378
RemoteTestClient, "src/tools/remote-test-client", "remote-test-client";
383379
RustInstaller, "src/tools/rust-installer", "fabricate", is_external_tool = true;

src/libcore/result.rs

+38
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,44 @@ impl<T: Default, E> Result<T, E> {
10921092
}
10931093
}
10941094

1095+
#[unstable(feature = "unwrap_infallible", reason = "newly added", issue = "61695")]
1096+
impl<T, E: Into<!>> Result<T, E> {
1097+
/// Unwraps a result that can never be an [`Err`], yielding the content of the [`Ok`].
1098+
///
1099+
/// Unlike [`unwrap`], this method is known to never panic on the
1100+
/// result types it is implemented for. Therefore, it can be used
1101+
/// instead of `unwrap` as a maintainability safeguard that will fail
1102+
/// to compile if the error type of the `Result` is later changed
1103+
/// to an error that can actually occur.
1104+
///
1105+
/// [`Ok`]: enum.Result.html#variant.Ok
1106+
/// [`Err`]: enum.Result.html#variant.Err
1107+
/// [`unwrap`]: enum.Result.html#method.unwrap
1108+
///
1109+
/// # Examples
1110+
///
1111+
/// Basic usage:
1112+
///
1113+
/// ```
1114+
/// # #![feature(never_type)]
1115+
/// # #![feature(unwrap_infallible)]
1116+
///
1117+
/// fn only_good_news() -> Result<String, !> {
1118+
/// Ok("this is fine".into())
1119+
/// }
1120+
///
1121+
/// let s: String = only_good_news().into_ok();
1122+
/// println!("{}", s);
1123+
/// ```
1124+
#[inline]
1125+
pub fn into_ok(self) -> T {
1126+
match self {
1127+
Ok(x) => x,
1128+
Err(e) => e.into(),
1129+
}
1130+
}
1131+
}
1132+
10951133
#[unstable(feature = "inner_deref", reason = "newly added", issue = "50264")]
10961134
impl<T: Deref, E> Result<T, E> {
10971135
/// Converts from `Result<T, E>` (or `&Result<T, E>`) to `Result<&T::Target, &E>`.

src/libcore/tests/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
#![feature(slice_from_raw_parts)]
4141
#![feature(const_slice_from_raw_parts)]
4242
#![feature(const_raw_ptr_deref)]
43+
#![feature(never_type)]
44+
#![feature(unwrap_infallible)]
4345

4446
extern crate test;
4547

src/libcore/tests/result.rs

+22
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,28 @@ pub fn test_unwrap_or_default() {
183183
assert_eq!(op2().unwrap_or_default(), 0);
184184
}
185185

186+
#[test]
187+
pub fn test_into_ok() {
188+
fn infallible_op() -> Result<isize, !> {
189+
Ok(666)
190+
}
191+
192+
assert_eq!(infallible_op().into_ok(), 666);
193+
194+
enum MyNeverToken {}
195+
impl From<MyNeverToken> for ! {
196+
fn from(never: MyNeverToken) -> ! {
197+
match never {}
198+
}
199+
}
200+
201+
fn infallible_op2() -> Result<isize, MyNeverToken> {
202+
Ok(667)
203+
}
204+
205+
assert_eq!(infallible_op2().into_ok(), 667);
206+
}
207+
186208
#[test]
187209
fn test_try() {
188210
fn try_result_some() -> Option<u8> {

src/librustc/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ rustc_hir = { path = "../librustc_hir" }
2626
rustc_target = { path = "../librustc_target" }
2727
rustc_macros = { path = "../librustc_macros" }
2828
rustc_data_structures = { path = "../librustc_data_structures" }
29+
rustc_errors = { path = "../librustc_errors" }
2930
rustc_index = { path = "../librustc_index" }
30-
errors = { path = "../librustc_errors", package = "rustc_errors" }
3131
rustc_serialize = { path = "../libserialize", package = "serialize" }
3232
syntax = { path = "../libsyntax" }
3333
rustc_span = { path = "../librustc_span" }

src/librustc/dep_graph/graph.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use crate::ty::{self, TyCtxt};
2-
use errors::Diagnostic;
32
use parking_lot::{Condvar, Mutex};
43
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
54
use rustc_data_structures::profiling::QueryInvocationId;
65
use rustc_data_structures::sharded::{self, Sharded};
76
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
87
use rustc_data_structures::sync::{AtomicU32, AtomicU64, Lock, Lrc, Ordering};
8+
use rustc_errors::Diagnostic;
99
use rustc_index::vec::{Idx, IndexVec};
1010
use smallvec::SmallVec;
1111
use std::collections::hash_map::Entry;

src/librustc/hir/check_attr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use crate::lint::builtin::UNUSED_ATTRIBUTES;
99
use crate::ty::query::Providers;
1010
use crate::ty::TyCtxt;
1111

12-
use errors::struct_span_err;
1312
use rustc_error_codes::*;
13+
use rustc_errors::struct_span_err;
1414
use rustc_hir as hir;
1515
use rustc_hir::def_id::DefId;
1616
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};

src/librustc/infer/error_reporting/mod.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,13 @@ use crate::ty::{
6464
subst::{Subst, SubstsRef},
6565
Region, Ty, TyCtxt, TypeFoldable,
6666
};
67+
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
68+
use rustc_error_codes::*;
69+
use rustc_errors::{pluralize, struct_span_err};
70+
use rustc_errors::{Applicability, DiagnosticBuilder, DiagnosticStyledString};
6771
use rustc_hir as hir;
6872
use rustc_hir::def_id::DefId;
6973
use rustc_hir::Node;
70-
71-
use errors::{
72-
pluralize, struct_span_err, Applicability, DiagnosticBuilder, DiagnosticStyledString,
73-
};
74-
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
75-
use rustc_error_codes::*;
7674
use rustc_span::{DesugaringKind, Pos, Span};
7775
use rustc_target::spec::abi;
7876
use std::{cmp, fmt};

src/librustc/infer/error_reporting/need_type_info.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::infer::type_variable::TypeVariableOriginKind;
33
use crate::infer::InferCtxt;
44
use crate::ty::print::Print;
55
use crate::ty::{self, DefIdTree, Infer, Ty, TyVar};
6-
use errors::{struct_span_err, Applicability, DiagnosticBuilder};
6+
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder};
77
use rustc_hir as hir;
88
use rustc_hir::def::{DefKind, Namespace};
99
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
@@ -151,12 +151,12 @@ pub enum TypeAnnotationNeeded {
151151
E0284,
152152
}
153153

154-
impl Into<errors::DiagnosticId> for TypeAnnotationNeeded {
155-
fn into(self) -> errors::DiagnosticId {
154+
impl Into<rustc_errors::DiagnosticId> for TypeAnnotationNeeded {
155+
fn into(self) -> rustc_errors::DiagnosticId {
156156
match self {
157-
Self::E0282 => errors::error_code!(E0282),
158-
Self::E0283 => errors::error_code!(E0283),
159-
Self::E0284 => errors::error_code!(E0284),
157+
Self::E0282 => rustc_errors::error_code!(E0282),
158+
Self::E0283 => rustc_errors::error_code!(E0283),
159+
Self::E0284 => rustc_errors::error_code!(E0284),
160160
}
161161
}
162162
}

src/librustc/infer/error_reporting/nice_region_error/different_lifetimes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use crate::infer::error_reporting::nice_region_error::util::AnonymousParamInfo;
55
use crate::infer::error_reporting::nice_region_error::NiceRegionError;
66
use crate::util::common::ErrorReported;
77

8-
use errors::struct_span_err;
98
use rustc_error_codes::*;
9+
use rustc_errors::struct_span_err;
1010

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

0 commit comments

Comments
 (0)