Skip to content

Rollup of 11 pull requests #59293

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

Merged
merged 26 commits into from
Mar 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
6fb5b73
dbg!() without parameters.
Jan 22, 2019
ea9e2c4
Test behaviour
Jan 31, 2019
988b3d5
Implement ExactSizeIterator for ToLowercase and ToUppercase
KamilaBorowska Feb 27, 2019
911a633
Remove copy paste error in char tests
ollie27 Feb 27, 2019
c5fe405
Clarify distinction between floor() and trunc()
jonhoo Feb 28, 2019
b91ab62
Fix a tiny error in documentation of std::pin.
taeguk Mar 5, 2019
b9d12ed
Be more discerning on when to attempt suggesting a comma in a macro i…
estebank Mar 11, 2019
27abd52
Fix operator precedence
estebank Mar 13, 2019
4e5692d
test that wildcard type `_` is not duplicated by `type Foo<X> = (X, X…
pnkfelix Jan 18, 2019
98b2672
update mailmap for Bastian Kauschke
lcnr Mar 17, 2019
698bbe5
Replaced self-reflective explicit types with clearer `Self` or `Self:…
regexident Mar 18, 2019
9d408d9
Add todo!() macro
matklad Nov 29, 2018
de4be2c
Stabilize refcell_map_split feature
joshlf Mar 18, 2019
8f261a6
Update since annotation for ExactSizeIterator for ToUppercase/Lowercase
KamilaBorowska Mar 19, 2019
ab41023
Run branch cleanup after copy prop
oli-obk Mar 19, 2019
d4dd860
Rollup merge of #56348 - matklad:todo-macro, r=withoutboats
Centril Mar 19, 2019
c1975db
Rollup merge of #57729 - pnkfelix:issue-55748-pat-types-are-constrain…
Centril Mar 19, 2019
d4ef74b
Rollup merge of #57847 - clarcharr:dbg_no_params, r=Centril
Centril Mar 19, 2019
fff8586
Rollup merge of #58778 - xfix:exact_size_case_mapping_iter, r=SimonSapin
Centril Mar 19, 2019
5abd9c7
Rollup merge of #58812 - jonhoo:floor_v_trunc, r=alexcrichton
Centril Mar 19, 2019
61ff887
Rollup merge of #58939 - taeguk:fix-doc-about-pin, r=rkruppe
Centril Mar 19, 2019
8ebe2ac
Rollup merge of #59116 - estebank:comma-sugg, r=petrochenkov
Centril Mar 19, 2019
05e8051
Rollup merge of #59252 - lcnr:mailmap, r=Centril
Centril Mar 19, 2019
1ec1c5d
Rollup merge of #59275 - regexident:docs-self, r=joshtriplett
Centril Mar 19, 2019
a3581ac
Rollup merge of #59280 - joshlf:sandbox/joshlf/stabilize-refcell-map-…
Centril Mar 19, 2019
7f7829f
Rollup merge of #59290 - oli-obk:trivial_move_prop, r=davidtwco
Centril Mar 19, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Ariel Ben-Yehuda <[email protected]> Ariel Ben-Yehuda <[email protected]>
Ariel Ben-Yehuda <[email protected]> arielb1 <[email protected]>
Austin Seipp <[email protected]> <[email protected]>
Aydin Kim <[email protected]> aydin.kim <[email protected]>
Bastian Kauschke <[email protected]>
Barosl Lee <[email protected]> Barosl LEE <[email protected]>
Ben Alpert <[email protected]> <[email protected]>
Ben Sago <[email protected]> Ben S <[email protected]>
Expand Down
6 changes: 2 additions & 4 deletions src/libcore/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1186,7 +1186,6 @@ impl<'b, T: ?Sized> Ref<'b, T> {
/// # Examples
///
/// ```
/// #![feature(refcell_map_split)]
/// use std::cell::{Ref, RefCell};
///
/// let cell = RefCell::new([1, 2, 3, 4]);
Expand All @@ -1195,7 +1194,7 @@ impl<'b, T: ?Sized> Ref<'b, T> {
/// assert_eq!(*begin, [1, 2]);
/// assert_eq!(*end, [3, 4]);
/// ```
#[unstable(feature = "refcell_map_split", issue = "51476")]
#[stable(feature = "refcell_map_split", since = "1.35.0")]
#[inline]
pub fn map_split<U: ?Sized, V: ?Sized, F>(orig: Ref<'b, T>, f: F) -> (Ref<'b, U>, Ref<'b, V>)
where F: FnOnce(&T) -> (&U, &V)
Expand Down Expand Up @@ -1268,7 +1267,6 @@ impl<'b, T: ?Sized> RefMut<'b, T> {
/// # Examples
///
/// ```
/// #![feature(refcell_map_split)]
/// use std::cell::{RefCell, RefMut};
///
/// let cell = RefCell::new([1, 2, 3, 4]);
Expand All @@ -1279,7 +1277,7 @@ impl<'b, T: ?Sized> RefMut<'b, T> {
/// begin.copy_from_slice(&[4, 3]);
/// end.copy_from_slice(&[2, 1]);
/// ```
#[unstable(feature = "refcell_map_split", issue = "51476")]
#[stable(feature = "refcell_map_split", since = "1.35.0")]
#[inline]
pub fn map_split<U: ?Sized, V: ?Sized, F>(
orig: RefMut<'b, T>, f: F
Expand Down
22 changes: 22 additions & 0 deletions src/libcore/char/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,11 +389,17 @@ impl Iterator for ToLowercase {
fn next(&mut self) -> Option<char> {
self.0.next()
}
fn size_hint(&self) -> (usize, Option<usize>) {
self.0.size_hint()
}
}

#[stable(feature = "fused", since = "1.26.0")]
impl FusedIterator for ToLowercase {}

#[stable(feature = "exact_size_case_mapping_iter", since = "1.35.0")]
impl ExactSizeIterator for ToLowercase {}

/// Returns an iterator that yields the uppercase equivalent of a `char`.
///
/// This `struct` is created by the [`to_uppercase`] method on [`char`]. See
Expand All @@ -411,11 +417,17 @@ impl Iterator for ToUppercase {
fn next(&mut self) -> Option<char> {
self.0.next()
}
fn size_hint(&self) -> (usize, Option<usize>) {
self.0.size_hint()
}
}

#[stable(feature = "fused", since = "1.26.0")]
impl FusedIterator for ToUppercase {}

#[stable(feature = "exact_size_case_mapping_iter", since = "1.35.0")]
impl ExactSizeIterator for ToUppercase {}

#[derive(Debug, Clone)]
enum CaseMappingIter {
Three(char, char, char),
Expand Down Expand Up @@ -457,6 +469,16 @@ impl Iterator for CaseMappingIter {
CaseMappingIter::Zero => None,
}
}

fn size_hint(&self) -> (usize, Option<usize>) {
let size = match self {
CaseMappingIter::Three(..) => 3,
CaseMappingIter::Two(..) => 2,
CaseMappingIter::One(_) => 1,
CaseMappingIter::Zero => 0,
};
(size, Some(size))
}
}

impl fmt::Display for CaseMappingIter {
Expand Down
14 changes: 7 additions & 7 deletions src/libcore/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ use self::Ordering::*;
/// }
///
/// impl PartialEq for Book {
/// fn eq(&self, other: &Book) -> bool {
/// fn eq(&self, other: &Self) -> bool {
/// self.isbn == other.isbn
/// }
/// }
Expand Down Expand Up @@ -233,7 +233,7 @@ pub trait PartialEq<Rhs: ?Sized = Self> {
/// format: BookFormat,
/// }
/// impl PartialEq for Book {
/// fn eq(&self, other: &Book) -> bool {
/// fn eq(&self, other: &Self) -> bool {
/// self.isbn == other.isbn
/// }
/// }
Expand Down Expand Up @@ -493,19 +493,19 @@ impl<T: Ord> Ord for Reverse<T> {
/// }
///
/// impl Ord for Person {
/// fn cmp(&self, other: &Person) -> Ordering {
/// fn cmp(&self, other: &Self) -> Ordering {
/// self.height.cmp(&other.height)
/// }
/// }
///
/// impl PartialOrd for Person {
/// fn partial_cmp(&self, other: &Person) -> Option<Ordering> {
/// fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
/// Some(self.cmp(other))
/// }
/// }
///
/// impl PartialEq for Person {
/// fn eq(&self, other: &Person) -> bool {
/// fn eq(&self, other: &Self) -> bool {
/// self.height == other.height
/// }
/// }
Expand Down Expand Up @@ -691,13 +691,13 @@ impl PartialOrd for Ordering {
/// }
///
/// impl PartialOrd for Person {
/// fn partial_cmp(&self, other: &Person) -> Option<Ordering> {
/// fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
/// self.height.partial_cmp(&other.height)
/// }
/// }
///
/// impl PartialEq for Person {
/// fn eq(&self, other: &Person) -> bool {
/// fn eq(&self, other: &Self) -> bool {
/// self.height == other.height
/// }
/// }
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/iter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
//! type Item = usize;
//!
//! // next() is the only required method
//! fn next(&mut self) -> Option<usize> {
//! fn next(&mut self) -> Option<Self::Item> {
//! // Increment our count. This is why we started at zero.
//! self.count += 1;
//!
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/iter/traits/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ pub trait FromIterator<A>: Sized {
/// // and we'll implement IntoIterator
/// impl IntoIterator for MyCollection {
/// type Item = i32;
/// type IntoIter = ::std::vec::IntoIter<i32>;
/// type IntoIter = ::std::vec::IntoIter<Self::Item>;
///
/// fn into_iter(self) -> Self::IntoIter {
/// self.0.into_iter()
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/iter/traits/exact_size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
/// # }
/// # impl Iterator for Counter {
/// # type Item = usize;
/// # fn next(&mut self) -> Option<usize> {
/// # fn next(&mut self) -> Option<Self::Item> {
/// # self.count += 1;
/// # if self.count < 6 {
/// # Some(self.count)
Expand Down
59 changes: 59 additions & 0 deletions src/libcore/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,65 @@ macro_rules! unimplemented {
($($arg:tt)+) => (panic!("not yet implemented: {}", format_args!($($arg)*)));
}

/// A standardized placeholder for marking unfinished code.
///
/// This can be useful if you are prototyping and are just looking to have your
/// code typecheck. `todo!` works exactly like `unimplemented!`, there only
/// difference between the two macros is the name.
///
/// # Panics
///
/// This will always [panic!](macro.panic.html)
///
/// # Examples
///
/// Here's an example of some in-progress code. We have a trait `Foo`:
///
/// ```
/// trait Foo {
/// fn bar(&self);
/// fn baz(&self);
/// }
/// ```
///
/// We want to implement `Foo` on one of our types, but we also want to work on
/// just `bar()` first. In order for our code to compile, we need to implement
/// `baz()`, so we can use `todo!`:
///
/// ```
/// #![feature(todo_macro)]
///
/// # trait Foo {
/// # fn bar(&self);
/// # fn baz(&self);
/// # }
/// struct MyStruct;
///
/// impl Foo for MyStruct {
/// fn bar(&self) {
/// // implementation goes here
/// }
///
/// fn baz(&self) {
/// // let's not worry about implementing baz() for now
/// todo!();
/// }
/// }
///
/// fn main() {
/// let s = MyStruct;
/// s.bar();
///
/// // we aren't even using baz() yet, so this is fine.
/// }
/// ```
#[macro_export]
#[unstable(feature = "todo_macro", issue = "59277")]
macro_rules! todo {
() => (panic!("not yet implemented"));
($($arg:tt)+) => (panic!("not yet implemented: {}", format_args!($($arg)*)));
}

/// A macro to create an array of [`MaybeUninit`]
///
/// This macro constructs an uninitialized array of the type `[MaybeUninit<K>; N]`.
Expand Down
40 changes: 20 additions & 20 deletions src/libcore/ops/arith.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
/// }
///
/// impl Add for Point {
/// type Output = Point;
/// type Output = Self;
///
/// fn add(self, other: Point) -> Point {
/// Point {
/// fn add(self, other: Self) -> Self {
/// Self {
/// x: self.x + other.x,
/// y: self.y + other.y,
/// }
Expand All @@ -50,10 +50,10 @@
///
/// // Notice that the implementation uses the associated type `Output`.
/// impl<T: Add<Output = T>> Add for Point<T> {
/// type Output = Point<T>;
/// type Output = Self;
///
/// fn add(self, other: Point<T>) -> Point<T> {
/// Point {
/// fn add(self, other: Self) -> Self::Output {
/// Self {
/// x: self.x + other.x,
/// y: self.y + other.y,
/// }
Expand Down Expand Up @@ -158,9 +158,9 @@ add_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
///
/// // Notice that the implementation uses the associated type `Output`.
/// impl<T: Sub<Output = T>> Sub for Point<T> {
/// type Output = Point<T>;
/// type Output = Self;
///
/// fn sub(self, other: Point<T>) -> Point<T> {
/// fn sub(self, other: Self) -> Self::Output {
/// Point {
/// x: self.x - other.x,
/// y: self.y - other.y,
Expand Down Expand Up @@ -280,9 +280,9 @@ sub_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
/// struct Vector { value: Vec<usize> }
///
/// impl Mul<Scalar> for Vector {
/// type Output = Vector;
/// type Output = Self;
///
/// fn mul(self, rhs: Scalar) -> Vector {
/// fn mul(self, rhs: Scalar) -> Self::Output {
/// Vector { value: self.value.iter().map(|v| v * rhs.value).collect() }
/// }
/// }
Expand Down Expand Up @@ -364,7 +364,7 @@ mul_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
/// // The division of rational numbers is a closed operation.
/// type Output = Self;
///
/// fn div(self, rhs: Self) -> Self {
/// fn div(self, rhs: Self) -> Self::Output {
/// if rhs.nominator == 0 {
/// panic!("Cannot divide by zero-valued `Rational`!");
/// }
Expand Down Expand Up @@ -404,9 +404,9 @@ mul_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
/// struct Vector { value: Vec<f32> }
///
/// impl Div<Scalar> for Vector {
/// type Output = Vector;
/// type Output = Self;
///
/// fn div(self, rhs: Scalar) -> Vector {
/// fn div(self, rhs: Scalar) -> Self::Output {
/// Vector { value: self.value.iter().map(|v| v / rhs.value).collect() }
/// }
/// }
Expand Down Expand Up @@ -485,9 +485,9 @@ div_impl_float! { f32 f64 }
/// }
///
/// impl<'a, T> Rem<usize> for SplitSlice<'a, T> {
/// type Output = SplitSlice<'a, T>;
/// type Output = Self;
///
/// fn rem(self, modulus: usize) -> Self {
/// fn rem(self, modulus: usize) -> Self::Output {
/// let len = self.slice.len();
/// let rem = len % modulus;
/// let start = len - rem;
Expand Down Expand Up @@ -571,7 +571,7 @@ rem_impl_float! { f32 f64 }
/// impl Neg for Sign {
/// type Output = Sign;
///
/// fn neg(self) -> Sign {
/// fn neg(self) -> Self::Output {
/// match self {
/// Sign::Negative => Sign::Positive,
/// Sign::Zero => Sign::Zero,
Expand Down Expand Up @@ -650,8 +650,8 @@ neg_impl_numeric! { isize i8 i16 i32 i64 i128 f32 f64 }
/// }
///
/// impl AddAssign for Point {
/// fn add_assign(&mut self, other: Point) {
/// *self = Point {
/// fn add_assign(&mut self, other: Self) {
/// *self = Self {
/// x: self.x + other.x,
/// y: self.y + other.y,
/// };
Expand Down Expand Up @@ -706,8 +706,8 @@ add_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
/// }
///
/// impl SubAssign for Point {
/// fn sub_assign(&mut self, other: Point) {
/// *self = Point {
/// fn sub_assign(&mut self, other: Self) {
/// *self = Self {
/// x: self.x - other.x,
/// y: self.y - other.y,
/// };
Expand Down
Loading