Skip to content

Commit 7a4df3b

Browse files
committed
Auto merge of #59293 - Centril:rollup, r=Centril
Rollup of 11 pull requests Successful merges: - #56348 (Add todo!() macro) - #57729 (extra testing of how NLL handles wildcard type `_`) - #57847 (dbg!() without parameters) - #58778 (Implement ExactSizeIterator for ToLowercase and ToUppercase) - #58812 (Clarify distinction between floor() and trunc()) - #58939 (Fix a tiny error in documentation of std::pin.) - #59116 (Be more discerning on when to attempt suggesting a comma in a macro invocation) - #59252 (add self to mailmap) - #59275 (Replaced self-reflective explicit types with clearer `Self` or `Self::…` in stdlib docs) - #59280 (Stabilize refcell_map_split feature) - #59290 (Run branch cleanup after copy prop) Failed merges: r? @ghost
2 parents ef4d1c4 + 7f7829f commit 7a4df3b

27 files changed

+315
-72
lines changed

.mailmap

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Ariel Ben-Yehuda <arielb1@mail.tau.ac.il> Ariel Ben-Yehuda <ariel.byd@gmail.com>
2929
Ariel Ben-Yehuda <arielb1@mail.tau.ac.il> arielb1 <arielb1@mail.tau.ac.il>
3030
Austin Seipp <mad.one@gmail.com> <as@hacks.yi.org>
3131
Aydin Kim <ladinjin@hanmail.net> aydin.kim <aydin.kim@samsung.com>
32+
Bastian Kauschke <bastian_kauschke@hotmail.de>
3233
Barosl Lee <vcs@barosl.com> Barosl LEE <github@barosl.com>
3334
Ben Alpert <ben@benalpert.com> <spicyjalapeno@gmail.com>
3435
Ben Sago <ogham@users.noreply.github.com> Ben S <ogham@bsago.me>

src/libcore/cell.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1186,7 +1186,6 @@ impl<'b, T: ?Sized> Ref<'b, T> {
11861186
/// # Examples
11871187
///
11881188
/// ```
1189-
/// #![feature(refcell_map_split)]
11901189
/// use std::cell::{Ref, RefCell};
11911190
///
11921191
/// let cell = RefCell::new([1, 2, 3, 4]);
@@ -1195,7 +1194,7 @@ impl<'b, T: ?Sized> Ref<'b, T> {
11951194
/// assert_eq!(*begin, [1, 2]);
11961195
/// assert_eq!(*end, [3, 4]);
11971196
/// ```
1198-
#[unstable(feature = "refcell_map_split", issue = "51476")]
1197+
#[stable(feature = "refcell_map_split", since = "1.35.0")]
11991198
#[inline]
12001199
pub fn map_split<U: ?Sized, V: ?Sized, F>(orig: Ref<'b, T>, f: F) -> (Ref<'b, U>, Ref<'b, V>)
12011200
where F: FnOnce(&T) -> (&U, &V)
@@ -1268,7 +1267,6 @@ impl<'b, T: ?Sized> RefMut<'b, T> {
12681267
/// # Examples
12691268
///
12701269
/// ```
1271-
/// #![feature(refcell_map_split)]
12721270
/// use std::cell::{RefCell, RefMut};
12731271
///
12741272
/// let cell = RefCell::new([1, 2, 3, 4]);
@@ -1279,7 +1277,7 @@ impl<'b, T: ?Sized> RefMut<'b, T> {
12791277
/// begin.copy_from_slice(&[4, 3]);
12801278
/// end.copy_from_slice(&[2, 1]);
12811279
/// ```
1282-
#[unstable(feature = "refcell_map_split", issue = "51476")]
1280+
#[stable(feature = "refcell_map_split", since = "1.35.0")]
12831281
#[inline]
12841282
pub fn map_split<U: ?Sized, V: ?Sized, F>(
12851283
orig: RefMut<'b, T>, f: F

src/libcore/char/mod.rs

+22
Original file line numberDiff line numberDiff line change
@@ -389,11 +389,17 @@ impl Iterator for ToLowercase {
389389
fn next(&mut self) -> Option<char> {
390390
self.0.next()
391391
}
392+
fn size_hint(&self) -> (usize, Option<usize>) {
393+
self.0.size_hint()
394+
}
392395
}
393396

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

400+
#[stable(feature = "exact_size_case_mapping_iter", since = "1.35.0")]
401+
impl ExactSizeIterator for ToLowercase {}
402+
397403
/// Returns an iterator that yields the uppercase equivalent of a `char`.
398404
///
399405
/// This `struct` is created by the [`to_uppercase`] method on [`char`]. See
@@ -411,11 +417,17 @@ impl Iterator for ToUppercase {
411417
fn next(&mut self) -> Option<char> {
412418
self.0.next()
413419
}
420+
fn size_hint(&self) -> (usize, Option<usize>) {
421+
self.0.size_hint()
422+
}
414423
}
415424

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

428+
#[stable(feature = "exact_size_case_mapping_iter", since = "1.35.0")]
429+
impl ExactSizeIterator for ToUppercase {}
430+
419431
#[derive(Debug, Clone)]
420432
enum CaseMappingIter {
421433
Three(char, char, char),
@@ -457,6 +469,16 @@ impl Iterator for CaseMappingIter {
457469
CaseMappingIter::Zero => None,
458470
}
459471
}
472+
473+
fn size_hint(&self) -> (usize, Option<usize>) {
474+
let size = match self {
475+
CaseMappingIter::Three(..) => 3,
476+
CaseMappingIter::Two(..) => 2,
477+
CaseMappingIter::One(_) => 1,
478+
CaseMappingIter::Zero => 0,
479+
};
480+
(size, Some(size))
481+
}
460482
}
461483

462484
impl fmt::Display for CaseMappingIter {

src/libcore/cmp.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ use self::Ordering::*;
7272
/// }
7373
///
7474
/// impl PartialEq for Book {
75-
/// fn eq(&self, other: &Book) -> bool {
75+
/// fn eq(&self, other: &Self) -> bool {
7676
/// self.isbn == other.isbn
7777
/// }
7878
/// }
@@ -233,7 +233,7 @@ pub trait PartialEq<Rhs: ?Sized = Self> {
233233
/// format: BookFormat,
234234
/// }
235235
/// impl PartialEq for Book {
236-
/// fn eq(&self, other: &Book) -> bool {
236+
/// fn eq(&self, other: &Self) -> bool {
237237
/// self.isbn == other.isbn
238238
/// }
239239
/// }
@@ -493,19 +493,19 @@ impl<T: Ord> Ord for Reverse<T> {
493493
/// }
494494
///
495495
/// impl Ord for Person {
496-
/// fn cmp(&self, other: &Person) -> Ordering {
496+
/// fn cmp(&self, other: &Self) -> Ordering {
497497
/// self.height.cmp(&other.height)
498498
/// }
499499
/// }
500500
///
501501
/// impl PartialOrd for Person {
502-
/// fn partial_cmp(&self, other: &Person) -> Option<Ordering> {
502+
/// fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
503503
/// Some(self.cmp(other))
504504
/// }
505505
/// }
506506
///
507507
/// impl PartialEq for Person {
508-
/// fn eq(&self, other: &Person) -> bool {
508+
/// fn eq(&self, other: &Self) -> bool {
509509
/// self.height == other.height
510510
/// }
511511
/// }
@@ -691,13 +691,13 @@ impl PartialOrd for Ordering {
691691
/// }
692692
///
693693
/// impl PartialOrd for Person {
694-
/// fn partial_cmp(&self, other: &Person) -> Option<Ordering> {
694+
/// fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
695695
/// self.height.partial_cmp(&other.height)
696696
/// }
697697
/// }
698698
///
699699
/// impl PartialEq for Person {
700-
/// fn eq(&self, other: &Person) -> bool {
700+
/// fn eq(&self, other: &Self) -> bool {
701701
/// self.height == other.height
702702
/// }
703703
/// }

src/libcore/iter/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
//! type Item = usize;
102102
//!
103103
//! // next() is the only required method
104-
//! fn next(&mut self) -> Option<usize> {
104+
//! fn next(&mut self) -> Option<Self::Item> {
105105
//! // Increment our count. This is why we started at zero.
106106
//! self.count += 1;
107107
//!

src/libcore/iter/traits/collect.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ pub trait FromIterator<A>: Sized {
167167
/// // and we'll implement IntoIterator
168168
/// impl IntoIterator for MyCollection {
169169
/// type Item = i32;
170-
/// type IntoIter = ::std::vec::IntoIter<i32>;
170+
/// type IntoIter = ::std::vec::IntoIter<Self::Item>;
171171
///
172172
/// fn into_iter(self) -> Self::IntoIter {
173173
/// self.0.into_iter()

src/libcore/iter/traits/exact_size.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
/// # }
4646
/// # impl Iterator for Counter {
4747
/// # type Item = usize;
48-
/// # fn next(&mut self) -> Option<usize> {
48+
/// # fn next(&mut self) -> Option<Self::Item> {
4949
/// # self.count += 1;
5050
/// # if self.count < 6 {
5151
/// # Some(self.count)

src/libcore/macros.rs

+59
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,65 @@ macro_rules! unimplemented {
559559
($($arg:tt)+) => (panic!("not yet implemented: {}", format_args!($($arg)*)));
560560
}
561561

562+
/// A standardized placeholder for marking unfinished code.
563+
///
564+
/// This can be useful if you are prototyping and are just looking to have your
565+
/// code typecheck. `todo!` works exactly like `unimplemented!`, there only
566+
/// difference between the two macros is the name.
567+
///
568+
/// # Panics
569+
///
570+
/// This will always [panic!](macro.panic.html)
571+
///
572+
/// # Examples
573+
///
574+
/// Here's an example of some in-progress code. We have a trait `Foo`:
575+
///
576+
/// ```
577+
/// trait Foo {
578+
/// fn bar(&self);
579+
/// fn baz(&self);
580+
/// }
581+
/// ```
582+
///
583+
/// We want to implement `Foo` on one of our types, but we also want to work on
584+
/// just `bar()` first. In order for our code to compile, we need to implement
585+
/// `baz()`, so we can use `todo!`:
586+
///
587+
/// ```
588+
/// #![feature(todo_macro)]
589+
///
590+
/// # trait Foo {
591+
/// # fn bar(&self);
592+
/// # fn baz(&self);
593+
/// # }
594+
/// struct MyStruct;
595+
///
596+
/// impl Foo for MyStruct {
597+
/// fn bar(&self) {
598+
/// // implementation goes here
599+
/// }
600+
///
601+
/// fn baz(&self) {
602+
/// // let's not worry about implementing baz() for now
603+
/// todo!();
604+
/// }
605+
/// }
606+
///
607+
/// fn main() {
608+
/// let s = MyStruct;
609+
/// s.bar();
610+
///
611+
/// // we aren't even using baz() yet, so this is fine.
612+
/// }
613+
/// ```
614+
#[macro_export]
615+
#[unstable(feature = "todo_macro", issue = "59277")]
616+
macro_rules! todo {
617+
() => (panic!("not yet implemented"));
618+
($($arg:tt)+) => (panic!("not yet implemented: {}", format_args!($($arg)*)));
619+
}
620+
562621
/// A macro to create an array of [`MaybeUninit`]
563622
///
564623
/// This macro constructs an uninitialized array of the type `[MaybeUninit<K>; N]`.

src/libcore/ops/arith.rs

+20-20
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
/// }
2121
///
2222
/// impl Add for Point {
23-
/// type Output = Point;
23+
/// type Output = Self;
2424
///
25-
/// fn add(self, other: Point) -> Point {
26-
/// Point {
25+
/// fn add(self, other: Self) -> Self {
26+
/// Self {
2727
/// x: self.x + other.x,
2828
/// y: self.y + other.y,
2929
/// }
@@ -50,10 +50,10 @@
5050
///
5151
/// // Notice that the implementation uses the associated type `Output`.
5252
/// impl<T: Add<Output = T>> Add for Point<T> {
53-
/// type Output = Point<T>;
53+
/// type Output = Self;
5454
///
55-
/// fn add(self, other: Point<T>) -> Point<T> {
56-
/// Point {
55+
/// fn add(self, other: Self) -> Self::Output {
56+
/// Self {
5757
/// x: self.x + other.x,
5858
/// y: self.y + other.y,
5959
/// }
@@ -158,9 +158,9 @@ add_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
158158
///
159159
/// // Notice that the implementation uses the associated type `Output`.
160160
/// impl<T: Sub<Output = T>> Sub for Point<T> {
161-
/// type Output = Point<T>;
161+
/// type Output = Self;
162162
///
163-
/// fn sub(self, other: Point<T>) -> Point<T> {
163+
/// fn sub(self, other: Self) -> Self::Output {
164164
/// Point {
165165
/// x: self.x - other.x,
166166
/// y: self.y - other.y,
@@ -280,9 +280,9 @@ sub_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
280280
/// struct Vector { value: Vec<usize> }
281281
///
282282
/// impl Mul<Scalar> for Vector {
283-
/// type Output = Vector;
283+
/// type Output = Self;
284284
///
285-
/// fn mul(self, rhs: Scalar) -> Vector {
285+
/// fn mul(self, rhs: Scalar) -> Self::Output {
286286
/// Vector { value: self.value.iter().map(|v| v * rhs.value).collect() }
287287
/// }
288288
/// }
@@ -364,7 +364,7 @@ mul_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
364364
/// // The division of rational numbers is a closed operation.
365365
/// type Output = Self;
366366
///
367-
/// fn div(self, rhs: Self) -> Self {
367+
/// fn div(self, rhs: Self) -> Self::Output {
368368
/// if rhs.nominator == 0 {
369369
/// panic!("Cannot divide by zero-valued `Rational`!");
370370
/// }
@@ -404,9 +404,9 @@ mul_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
404404
/// struct Vector { value: Vec<f32> }
405405
///
406406
/// impl Div<Scalar> for Vector {
407-
/// type Output = Vector;
407+
/// type Output = Self;
408408
///
409-
/// fn div(self, rhs: Scalar) -> Vector {
409+
/// fn div(self, rhs: Scalar) -> Self::Output {
410410
/// Vector { value: self.value.iter().map(|v| v / rhs.value).collect() }
411411
/// }
412412
/// }
@@ -485,9 +485,9 @@ div_impl_float! { f32 f64 }
485485
/// }
486486
///
487487
/// impl<'a, T> Rem<usize> for SplitSlice<'a, T> {
488-
/// type Output = SplitSlice<'a, T>;
488+
/// type Output = Self;
489489
///
490-
/// fn rem(self, modulus: usize) -> Self {
490+
/// fn rem(self, modulus: usize) -> Self::Output {
491491
/// let len = self.slice.len();
492492
/// let rem = len % modulus;
493493
/// let start = len - rem;
@@ -571,7 +571,7 @@ rem_impl_float! { f32 f64 }
571571
/// impl Neg for Sign {
572572
/// type Output = Sign;
573573
///
574-
/// fn neg(self) -> Sign {
574+
/// fn neg(self) -> Self::Output {
575575
/// match self {
576576
/// Sign::Negative => Sign::Positive,
577577
/// Sign::Zero => Sign::Zero,
@@ -650,8 +650,8 @@ neg_impl_numeric! { isize i8 i16 i32 i64 i128 f32 f64 }
650650
/// }
651651
///
652652
/// impl AddAssign for Point {
653-
/// fn add_assign(&mut self, other: Point) {
654-
/// *self = Point {
653+
/// fn add_assign(&mut self, other: Self) {
654+
/// *self = Self {
655655
/// x: self.x + other.x,
656656
/// y: self.y + other.y,
657657
/// };
@@ -706,8 +706,8 @@ add_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
706706
/// }
707707
///
708708
/// impl SubAssign for Point {
709-
/// fn sub_assign(&mut self, other: Point) {
710-
/// *self = Point {
709+
/// fn sub_assign(&mut self, other: Self) {
710+
/// *self = Self {
711711
/// x: self.x - other.x,
712712
/// y: self.y - other.y,
713713
/// };

0 commit comments

Comments
 (0)