diff options
| author | bors <bors@rust-lang.org> | 2017-06-23 13:46:43 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-06-23 13:46:43 +0000 |
| commit | 229d0d3266002d343cdd2f4a3bf7f2fe9da15f38 (patch) | |
| tree | 013df87f8b1813e88368ac8c1728bc4c9b6bfb76 /src/libcore | |
| parent | bd32b1ba0d2d51a7e8505c1d3e37d17d3ba12843 (diff) | |
| parent | 9037ef2c782c9890e84285e81a183109ef1293f0 (diff) | |
| download | rust-229d0d3266002d343cdd2f4a3bf7f2fe9da15f38.tar.gz rust-229d0d3266002d343cdd2f4a3bf7f2fe9da15f38.zip | |
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:
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/cell.rs | 14 | ||||
| -rw-r--r-- | src/libcore/iter/mod.rs | 2 | ||||
| -rw-r--r-- | src/libcore/marker.rs | 2 | ||||
| -rw-r--r-- | src/libcore/mem.rs | 15 | ||||
| -rw-r--r-- | src/libcore/ops/place.rs | 18 | ||||
| -rw-r--r-- | src/libcore/ops/range.rs | 7 | ||||
| -rw-r--r-- | src/libcore/panicking.rs | 6 | ||||
| -rw-r--r-- | src/libcore/ptr.rs | 12 |
8 files changed, 57 insertions, 19 deletions
diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index e75401f6ce0..1eebf67ad04 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -942,6 +942,13 @@ impl<'b, T: ?Sized> Ref<'b, T> { #[unstable(feature = "coerce_unsized", issue = "27732")] impl<'b, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Ref<'b, U>> for Ref<'b, T> {} +#[stable(feature = "std_guard_impls", since = "1.20")] +impl<'a, T: ?Sized + fmt::Display> fmt::Display for Ref<'a, T> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.value.fmt(f) + } +} + impl<'b, T: ?Sized> RefMut<'b, T> { /// Make a new `RefMut` for a component of the borrowed data, e.g. an enum /// variant. @@ -1034,6 +1041,13 @@ impl<'b, T: ?Sized> DerefMut for RefMut<'b, T> { #[unstable(feature = "coerce_unsized", issue = "27732")] impl<'b, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<RefMut<'b, U>> for RefMut<'b, T> {} +#[stable(feature = "std_guard_impls", since = "1.20")] +impl<'a, T: ?Sized + fmt::Display> fmt::Display for RefMut<'a, T> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.value.fmt(f) + } +} + /// The core primitive for interior mutability in Rust. /// /// `UnsafeCell<T>` is a type that wraps some `T` and indicates unsafe interior operations on the diff --git a/src/libcore/iter/mod.rs b/src/libcore/iter/mod.rs index c91fd16391a..d6a9be4437d 100644 --- a/src/libcore/iter/mod.rs +++ b/src/libcore/iter/mod.rs @@ -211,7 +211,7 @@ //! There's one more subtle bit here: the standard library contains an //! interesting implementation of [`IntoIterator`]: //! -//! ```ignore +//! ```ignore (only-for-syntax-highlight) //! impl<I: Iterator> IntoIterator for I //! ``` //! diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs index 3bed425943f..e8fd729b638 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -434,7 +434,7 @@ macro_rules! impls{ /// example, here is a struct `Slice` that has two pointers of type `*const T`, /// presumably pointing into an array somewhere: /// -/// ```ignore +/// ```compile_fail,E0392 /// struct Slice<'a, T> { /// start: *const T, /// end: *const T, diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index 509b396f211..bba42752f50 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -328,11 +328,18 @@ pub fn align_of_val<T: ?Sized>(val: &T) -> usize { /// /// Here's an example of how a collection might make use of needs_drop: /// -/// ```ignore +/// ``` /// #![feature(needs_drop)] /// use std::{mem, ptr}; /// -/// pub struct MyCollection<T> { /* ... */ } +/// pub struct MyCollection<T> { +/// # data: [T; 1], +/// /* ... */ +/// } +/// # impl<T> MyCollection<T> { +/// # fn iter_mut(&mut self) -> &mut [T] { &mut self.data } +/// # fn free_buffer(&mut self) {} +/// # } /// /// impl<T> Drop for MyCollection<T> { /// fn drop(&mut self) { @@ -575,7 +582,7 @@ pub fn swap<T>(x: &mut T, y: &mut T) { /// `replace` allows consumption of a struct field by replacing it with another value. /// Without `replace` you can run into issues like these: /// -/// ```ignore +/// ```compile_fail,E0507 /// struct Buffer<T> { buf: Vec<T> } /// /// impl<T> Buffer<T> { @@ -645,7 +652,7 @@ pub fn replace<T>(dest: &mut T, mut src: T) -> T { /// /// Borrows are based on lexical scope, so this produces an error: /// -/// ```ignore +/// ```compile_fail,E0502 /// let mut v = vec![1, 2, 3]; /// let x = &v[0]; /// diff --git a/src/libcore/ops/place.rs b/src/libcore/ops/place.rs index 996a741c96f..19da887cbbf 100644 --- a/src/libcore/ops/place.rs +++ b/src/libcore/ops/place.rs @@ -38,7 +38,13 @@ pub trait Place<Data: ?Sized> { /// /// `PLACE <- EXPR` effectively desugars into: /// -/// ```rust,ignore +/// ``` +/// # #![feature(placement_new_protocol, box_heap)] +/// # use std::ops::{Placer, Place, InPlace}; +/// # #[allow(non_snake_case)] +/// # fn main() { +/// # let PLACE = std::boxed::HEAP; +/// # let EXPR = 1; /// let p = PLACE; /// let mut place = Placer::make_place(p); /// let raw_place = Place::pointer(&mut place); @@ -47,6 +53,7 @@ pub trait Place<Data: ?Sized> { /// std::ptr::write(raw_place, value); /// InPlace::finalize(place) /// } +/// # ; } /// ``` /// /// The type of `PLACE <- EXPR` is derived from the type of `PLACE`; @@ -89,14 +96,21 @@ pub trait InPlace<Data: ?Sized>: Place<Data> { /// /// `box EXPR` effectively desugars into: /// -/// ```rust,ignore +/// ``` +/// # #![feature(placement_new_protocol)] +/// # use std::ops::{BoxPlace, Place, Boxed}; +/// # #[allow(non_snake_case)] +/// # fn main() { +/// # let EXPR = 1; /// let mut place = BoxPlace::make_place(); /// let raw_place = Place::pointer(&mut place); /// let value = EXPR; +/// # let _: Box<_> = /// unsafe { /// ::std::ptr::write(raw_place, value); /// Boxed::finalize(place) /// } +/// # ; } /// ``` /// /// The type of `box EXPR` is supplied from its surrounding diff --git a/src/libcore/ops/range.rs b/src/libcore/ops/range.rs index 70c35df87dd..33258b7a875 100644 --- a/src/libcore/ops/range.rs +++ b/src/libcore/ops/range.rs @@ -26,7 +26,7 @@ use fmt; /// It does not have an `IntoIterator` implementation, so you can't use it in a /// `for` loop directly. This won't compile: /// -/// ```ignore +/// ```compile_fail,E0277 /// for i in .. { /// // ... /// } @@ -184,7 +184,7 @@ impl<Idx: PartialOrd<Idx>> RangeFrom<Idx> { /// It does not have an `IntoIterator` implementation, so you can't use it in a /// `for` loop directly. This won't compile: /// -/// ```ignore +/// ```compile_fail,E0277 /// for i in ..5 { /// // ... /// } @@ -313,7 +313,8 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> { /// It does not have an `IntoIterator` implementation, so you can't use it in a /// `for` loop directly. This won't compile: /// -/// ```ignore +/// ```compile_fail,E0277 +/// #![feature(inclusive_range_syntax)] /// for i in ...5 { /// // ... /// } diff --git a/src/libcore/panicking.rs b/src/libcore/panicking.rs index 93ddfa72f63..60b7669f3b2 100644 --- a/src/libcore/panicking.rs +++ b/src/libcore/panicking.rs @@ -15,8 +15,10 @@ //! useful an upstream crate must define panicking for libcore to use. The current //! interface for panicking is: //! -//! ```ignore -//! fn panic_impl(fmt: fmt::Arguments, &(&'static str, u32)) -> !; +//! ``` +//! # use std::fmt; +//! fn panic_impl(fmt: fmt::Arguments, file_line: &(&'static str, u32)) -> ! +//! # { loop {} } //! ``` //! //! This definition allows for panicking with any general message, but it does not diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index f89f86e18a1..54ae9e0d628 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -408,11 +408,11 @@ impl<T: ?Sized> *const T { /// /// Basic usage: /// - /// ```ignore - /// let val: *const u8 = &10u8 as *const u8; + /// ``` + /// let ptr: *const u8 = &10u8 as *const u8; /// /// unsafe { - /// if let Some(val_back) = val.as_ref() { + /// if let Some(val_back) = ptr.as_ref() { /// println!("We got back the value: {}!", val_back); /// } /// } @@ -570,11 +570,11 @@ impl<T: ?Sized> *mut T { /// /// Basic usage: /// - /// ```ignore - /// let val: *mut u8 = &mut 10u8 as *mut u8; + /// ``` + /// let ptr: *mut u8 = &mut 10u8 as *mut u8; /// /// unsafe { - /// if let Some(val_back) = val.as_ref() { + /// if let Some(val_back) = ptr.as_ref() { /// println!("We got back the value: {}!", val_back); /// } /// } |
