Skip to content

Commit 229d0d3

Browse files
committed
Auto merge of #42856 - Mark-Simulacrum:rollup, r=Mark-Simulacrum
Rollup of 8 pull requests - Successful merges: #42777, #42783, #42787, #42821, #42822, #42825, #42829, #42833 - Failed merges:
2 parents bd32b1b + 9037ef2 commit 229d0d3

File tree

68 files changed

+668
-286
lines changed

Some content is hidden

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

68 files changed

+668
-286
lines changed

src/bootstrap/check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ pub fn compiletest(build: &Build,
265265
let llvm_components = output(Command::new(&llvm_config).arg("--components"));
266266
let llvm_cxxflags = output(Command::new(&llvm_config).arg("--cxxflags"));
267267
cmd.arg("--cc").arg(build.cc(target))
268-
.arg("--cxx").arg(build.cxx(target))
268+
.arg("--cxx").arg(build.cxx(target).unwrap())
269269
.arg("--cflags").arg(build.cflags(target).join(" "))
270270
.arg("--llvm-components").arg(llvm_components.trim())
271271
.arg("--llvm-cxxflags").arg(llvm_cxxflags.trim());

src/bootstrap/compile.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ pub fn rustc(build: &Build, target: &str, compiler: &Compiler) {
291291
!target.contains("windows") &&
292292
!target.contains("apple") {
293293
cargo.env("LLVM_STATIC_STDCPP",
294-
compiler_file(build.cxx(target), "libstdc++.a"));
294+
compiler_file(build.cxx(target).unwrap(), "libstdc++.a"));
295295
}
296296
if build.config.llvm_link_shared {
297297
cargo.env("LLVM_LINK_SHARED", "1");

src/bootstrap/lib.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,10 @@ impl Build {
452452
cargo.env(format!("CC_{}", target), self.cc(target))
453453
.env(format!("AR_{}", target), self.ar(target).unwrap()) // only msvc is None
454454
.env(format!("CFLAGS_{}", target), self.cflags(target).join(" "));
455+
456+
if let Ok(cxx) = self.cxx(target) {
457+
cargo.env(format!("CXX_{}", target), cxx);
458+
}
455459
}
456460

457461
if self.config.extended && compiler.is_final_stage(self) {
@@ -838,13 +842,13 @@ impl Build {
838842
self.cc[target].1.as_ref().map(|p| &**p)
839843
}
840844

841-
/// Returns the path to the C++ compiler for the target specified, may panic
842-
/// if no C++ compiler was configured for the target.
843-
fn cxx(&self, target: &str) -> &Path {
845+
/// Returns the path to the C++ compiler for the target specified.
846+
fn cxx(&self, target: &str) -> Result<&Path, String> {
844847
match self.cxx.get(target) {
845-
Some(p) => p.path(),
846-
None => panic!("\n\ntarget `{}` is not configured as a host,
847-
only as a target\n\n", target),
848+
Some(p) => Ok(p.path()),
849+
None => Err(format!(
850+
"target `{}` is not configured as a host, only as a target",
851+
target))
848852
}
849853
}
850854

src/bootstrap/native.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ pub fn llvm(build: &Build, target: &str) {
155155
}
156156

157157
let cc = build.cc(target);
158-
let cxx = build.cxx(target);
158+
let cxx = build.cxx(target).unwrap();
159159

160160
// Handle msvc + ninja + ccache specially (this is what the bots use)
161161
if target.contains("msvc") &&

src/bootstrap/sanity.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ pub fn check(build: &mut Build) {
139139
}
140140
}
141141
for host in build.config.host.iter() {
142-
need_cmd(build.cxx(host).as_ref());
142+
need_cmd(build.cxx(host).unwrap().as_ref());
143143
}
144144

145145
// The msvc hosts don't use jemalloc, turn it off globally to

src/liballoc/boxed.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,10 @@
4242
//! Recursive structures must be boxed, because if the definition of `Cons`
4343
//! looked like this:
4444
//!
45-
//! ```rust,ignore
45+
//! ```compile_fail,E0072
46+
//! # enum List<T> {
4647
//! Cons(T, List<T>),
48+
//! # }
4749
//! ```
4850
//!
4951
//! It wouldn't work. This is because the size of a `List` depends on how many

src/liballoc/fmt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@
230230
//! There are a number of related macros in the `format!` family. The ones that
231231
//! are currently implemented are:
232232
//!
233-
//! ```ignore
233+
//! ```ignore (only-for-syntax-highlight)
234234
//! format! // described above
235235
//! write! // first argument is a &mut io::Write, the destination
236236
//! writeln! // same as write but appends a newline

src/liballoc/raw_vec.rs

+19-3
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,11 @@ impl<T, A: Alloc> RawVec<T, A> {
244244
///
245245
/// # Examples
246246
///
247-
/// ```ignore
247+
/// ```
248+
/// # #![feature(alloc)]
249+
/// # extern crate alloc;
250+
/// # use std::ptr;
251+
/// # use alloc::raw_vec::RawVec;
248252
/// struct MyVec<T> {
249253
/// buf: RawVec<T>,
250254
/// len: usize,
@@ -261,6 +265,10 @@ impl<T, A: Alloc> RawVec<T, A> {
261265
/// self.len += 1;
262266
/// }
263267
/// }
268+
/// # fn main() {
269+
/// # let mut vec = MyVec { buf: RawVec::new(), len: 0 };
270+
/// # vec.push(1);
271+
/// # }
264272
/// ```
265273
#[inline(never)]
266274
#[cold]
@@ -440,13 +448,17 @@ impl<T, A: Alloc> RawVec<T, A> {
440448
///
441449
/// # Examples
442450
///
443-
/// ```ignore
451+
/// ```
452+
/// # #![feature(alloc)]
453+
/// # extern crate alloc;
454+
/// # use std::ptr;
455+
/// # use alloc::raw_vec::RawVec;
444456
/// struct MyVec<T> {
445457
/// buf: RawVec<T>,
446458
/// len: usize,
447459
/// }
448460
///
449-
/// impl<T> MyVec<T> {
461+
/// impl<T: Clone> MyVec<T> {
450462
/// pub fn push_all(&mut self, elems: &[T]) {
451463
/// self.buf.reserve(self.len, elems.len());
452464
/// // reserve would have aborted or panicked if the len exceeded
@@ -459,6 +471,10 @@ impl<T, A: Alloc> RawVec<T, A> {
459471
/// }
460472
/// }
461473
/// }
474+
/// # fn main() {
475+
/// # let mut vector = MyVec { buf: RawVec::new(), len: 0 };
476+
/// # vector.push_all(&[1, 3, 5, 7, 9]);
477+
/// # }
462478
/// ```
463479
pub fn reserve(&mut self, used_cap: usize, needed_extra_cap: usize) {
464480
unsafe {

src/liballoc/rc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ struct RcBox<T: ?Sized> {
273273
/// See the [module-level documentation](./index.html) for more details.
274274
///
275275
/// The inherent methods of `Rc` are all associated functions, which means
276-
/// that you have to call them as e.g. [`Rc::get_mut(&value)`][get_mut] instead of
276+
/// that you have to call them as e.g. [`Rc::get_mut(&mut value)`][get_mut] instead of
277277
/// `value.get_mut()`. This avoids conflicts with methods of the inner
278278
/// type `T`.
279279
///

src/liballoc/string.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ use boxed::Box;
124124
/// similar, but without the UTF-8 constraint. The second implication is that
125125
/// you cannot index into a `String`:
126126
///
127-
/// ```ignore
127+
/// ```compile_fail,E0277
128128
/// let s = "hello";
129129
///
130130
/// println!("The first letter of s is {}", s[0]); // ERROR!!!

src/liballoc/vec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ use Bound::{Excluded, Included, Unbounded};
156156
/// However be careful: if you try to access an index which isn't in the `Vec`,
157157
/// your software will panic! You cannot do this:
158158
///
159-
/// ```ignore
159+
/// ```should_panic
160160
/// let v = vec![0, 2, 4, 6];
161161
/// println!("{}", v[6]); // it will panic!
162162
/// ```

src/libcore/cell.rs

+14
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,13 @@ impl<'b, T: ?Sized> Ref<'b, T> {
942942
#[unstable(feature = "coerce_unsized", issue = "27732")]
943943
impl<'b, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Ref<'b, U>> for Ref<'b, T> {}
944944

945+
#[stable(feature = "std_guard_impls", since = "1.20")]
946+
impl<'a, T: ?Sized + fmt::Display> fmt::Display for Ref<'a, T> {
947+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
948+
self.value.fmt(f)
949+
}
950+
}
951+
945952
impl<'b, T: ?Sized> RefMut<'b, T> {
946953
/// Make a new `RefMut` for a component of the borrowed data, e.g. an enum
947954
/// variant.
@@ -1034,6 +1041,13 @@ impl<'b, T: ?Sized> DerefMut for RefMut<'b, T> {
10341041
#[unstable(feature = "coerce_unsized", issue = "27732")]
10351042
impl<'b, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<RefMut<'b, U>> for RefMut<'b, T> {}
10361043

1044+
#[stable(feature = "std_guard_impls", since = "1.20")]
1045+
impl<'a, T: ?Sized + fmt::Display> fmt::Display for RefMut<'a, T> {
1046+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1047+
self.value.fmt(f)
1048+
}
1049+
}
1050+
10371051
/// The core primitive for interior mutability in Rust.
10381052
///
10391053
/// `UnsafeCell<T>` is a type that wraps some `T` and indicates unsafe interior operations on the

src/libcore/iter/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@
211211
//! There's one more subtle bit here: the standard library contains an
212212
//! interesting implementation of [`IntoIterator`]:
213213
//!
214-
//! ```ignore
214+
//! ```ignore (only-for-syntax-highlight)
215215
//! impl<I: Iterator> IntoIterator for I
216216
//! ```
217217
//!

src/libcore/marker.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ macro_rules! impls{
434434
/// example, here is a struct `Slice` that has two pointers of type `*const T`,
435435
/// presumably pointing into an array somewhere:
436436
///
437-
/// ```ignore
437+
/// ```compile_fail,E0392
438438
/// struct Slice<'a, T> {
439439
/// start: *const T,
440440
/// end: *const T,

src/libcore/mem.rs

+11-4
Original file line numberDiff line numberDiff line change
@@ -328,11 +328,18 @@ pub fn align_of_val<T: ?Sized>(val: &T) -> usize {
328328
///
329329
/// Here's an example of how a collection might make use of needs_drop:
330330
///
331-
/// ```ignore
331+
/// ```
332332
/// #![feature(needs_drop)]
333333
/// use std::{mem, ptr};
334334
///
335-
/// pub struct MyCollection<T> { /* ... */ }
335+
/// pub struct MyCollection<T> {
336+
/// # data: [T; 1],
337+
/// /* ... */
338+
/// }
339+
/// # impl<T> MyCollection<T> {
340+
/// # fn iter_mut(&mut self) -> &mut [T] { &mut self.data }
341+
/// # fn free_buffer(&mut self) {}
342+
/// # }
336343
///
337344
/// impl<T> Drop for MyCollection<T> {
338345
/// fn drop(&mut self) {
@@ -575,7 +582,7 @@ pub fn swap<T>(x: &mut T, y: &mut T) {
575582
/// `replace` allows consumption of a struct field by replacing it with another value.
576583
/// Without `replace` you can run into issues like these:
577584
///
578-
/// ```ignore
585+
/// ```compile_fail,E0507
579586
/// struct Buffer<T> { buf: Vec<T> }
580587
///
581588
/// impl<T> Buffer<T> {
@@ -645,7 +652,7 @@ pub fn replace<T>(dest: &mut T, mut src: T) -> T {
645652
///
646653
/// Borrows are based on lexical scope, so this produces an error:
647654
///
648-
/// ```ignore
655+
/// ```compile_fail,E0502
649656
/// let mut v = vec![1, 2, 3];
650657
/// let x = &v[0];
651658
///

src/libcore/ops/place.rs

+16-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,13 @@ pub trait Place<Data: ?Sized> {
3838
///
3939
/// `PLACE <- EXPR` effectively desugars into:
4040
///
41-
/// ```rust,ignore
41+
/// ```
42+
/// # #![feature(placement_new_protocol, box_heap)]
43+
/// # use std::ops::{Placer, Place, InPlace};
44+
/// # #[allow(non_snake_case)]
45+
/// # fn main() {
46+
/// # let PLACE = std::boxed::HEAP;
47+
/// # let EXPR = 1;
4248
/// let p = PLACE;
4349
/// let mut place = Placer::make_place(p);
4450
/// let raw_place = Place::pointer(&mut place);
@@ -47,6 +53,7 @@ pub trait Place<Data: ?Sized> {
4753
/// std::ptr::write(raw_place, value);
4854
/// InPlace::finalize(place)
4955
/// }
56+
/// # ; }
5057
/// ```
5158
///
5259
/// The type of `PLACE <- EXPR` is derived from the type of `PLACE`;
@@ -89,14 +96,21 @@ pub trait InPlace<Data: ?Sized>: Place<Data> {
8996
///
9097
/// `box EXPR` effectively desugars into:
9198
///
92-
/// ```rust,ignore
99+
/// ```
100+
/// # #![feature(placement_new_protocol)]
101+
/// # use std::ops::{BoxPlace, Place, Boxed};
102+
/// # #[allow(non_snake_case)]
103+
/// # fn main() {
104+
/// # let EXPR = 1;
93105
/// let mut place = BoxPlace::make_place();
94106
/// let raw_place = Place::pointer(&mut place);
95107
/// let value = EXPR;
108+
/// # let _: Box<_> =
96109
/// unsafe {
97110
/// ::std::ptr::write(raw_place, value);
98111
/// Boxed::finalize(place)
99112
/// }
113+
/// # ; }
100114
/// ```
101115
///
102116
/// The type of `box EXPR` is supplied from its surrounding

src/libcore/ops/range.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use fmt;
2626
/// It does not have an `IntoIterator` implementation, so you can't use it in a
2727
/// `for` loop directly. This won't compile:
2828
///
29-
/// ```ignore
29+
/// ```compile_fail,E0277
3030
/// for i in .. {
3131
/// // ...
3232
/// }
@@ -184,7 +184,7 @@ impl<Idx: PartialOrd<Idx>> RangeFrom<Idx> {
184184
/// It does not have an `IntoIterator` implementation, so you can't use it in a
185185
/// `for` loop directly. This won't compile:
186186
///
187-
/// ```ignore
187+
/// ```compile_fail,E0277
188188
/// for i in ..5 {
189189
/// // ...
190190
/// }
@@ -313,7 +313,8 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
313313
/// It does not have an `IntoIterator` implementation, so you can't use it in a
314314
/// `for` loop directly. This won't compile:
315315
///
316-
/// ```ignore
316+
/// ```compile_fail,E0277
317+
/// #![feature(inclusive_range_syntax)]
317318
/// for i in ...5 {
318319
/// // ...
319320
/// }

src/libcore/panicking.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
//! useful an upstream crate must define panicking for libcore to use. The current
1616
//! interface for panicking is:
1717
//!
18-
//! ```ignore
19-
//! fn panic_impl(fmt: fmt::Arguments, &(&'static str, u32)) -> !;
18+
//! ```
19+
//! # use std::fmt;
20+
//! fn panic_impl(fmt: fmt::Arguments, file_line: &(&'static str, u32)) -> !
21+
//! # { loop {} }
2022
//! ```
2123
//!
2224
//! This definition allows for panicking with any general message, but it does not

src/libcore/ptr.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -408,11 +408,11 @@ impl<T: ?Sized> *const T {
408408
///
409409
/// Basic usage:
410410
///
411-
/// ```ignore
412-
/// let val: *const u8 = &10u8 as *const u8;
411+
/// ```
412+
/// let ptr: *const u8 = &10u8 as *const u8;
413413
///
414414
/// unsafe {
415-
/// if let Some(val_back) = val.as_ref() {
415+
/// if let Some(val_back) = ptr.as_ref() {
416416
/// println!("We got back the value: {}!", val_back);
417417
/// }
418418
/// }
@@ -570,11 +570,11 @@ impl<T: ?Sized> *mut T {
570570
///
571571
/// Basic usage:
572572
///
573-
/// ```ignore
574-
/// let val: *mut u8 = &mut 10u8 as *mut u8;
573+
/// ```
574+
/// let ptr: *mut u8 = &mut 10u8 as *mut u8;
575575
///
576576
/// unsafe {
577-
/// if let Some(val_back) = val.as_ref() {
577+
/// if let Some(val_back) = ptr.as_ref() {
578578
/// println!("We got back the value: {}!", val_back);
579579
/// }
580580
/// }

src/libgraphviz/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
//!
112112
//! Output from first example (in `example1.dot`):
113113
//!
114-
//! ```ignore
114+
//! ```dot
115115
//! digraph example1 {
116116
//! N0[label="N0"];
117117
//! N1[label="N1"];

0 commit comments

Comments
 (0)