Skip to content

Commit b489252

Browse files
committed
Auto merge of rust-lang#106621 - ozkanonur:enable-elided-lifetimes-for-doctests, r=Mark-Simulacrum
enable `rust_2018_idioms` lint group for doctests With this change, `rust_2018_idioms` lint group will be enabled for compiler/libstd doctests. Resolves rust-lang#106086 Resolves rust-lang#99144 Signed-off-by: ozkanonur <[email protected]>
2 parents f5a2b38 + 99a18df commit b489252

File tree

23 files changed

+62
-66
lines changed

23 files changed

+62
-66
lines changed

alloc/src/borrow.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ where
115115
/// ```
116116
/// use std::borrow::Cow;
117117
///
118-
/// fn abs_all(input: &mut Cow<[i32]>) {
118+
/// fn abs_all(input: &mut Cow<'_, [i32]>) {
119119
/// for i in 0..input.len() {
120120
/// let v = input[i];
121121
/// if v < 0 {
@@ -145,7 +145,7 @@ where
145145
/// ```
146146
/// use std::borrow::Cow;
147147
///
148-
/// struct Items<'a, X: 'a> where [X]: ToOwned<Owned = Vec<X>> {
148+
/// struct Items<'a, X> where [X]: ToOwned<Owned = Vec<X>> {
149149
/// values: Cow<'a, [X]>,
150150
/// }
151151
///
@@ -267,7 +267,7 @@ impl<B: ?Sized + ToOwned> Cow<'_, B> {
267267
///
268268
/// assert_eq!(
269269
/// cow,
270-
/// Cow::Owned(String::from("FOO")) as Cow<str>
270+
/// Cow::Owned(String::from("FOO")) as Cow<'_, str>
271271
/// );
272272
/// ```
273273
#[stable(feature = "rust1", since = "1.0.0")]
@@ -311,7 +311,7 @@ impl<B: ?Sized + ToOwned> Cow<'_, B> {
311311
/// use std::borrow::Cow;
312312
///
313313
/// let s = "Hello world!";
314-
/// let cow: Cow<str> = Cow::Owned(String::from(s));
314+
/// let cow: Cow<'_, str> = Cow::Owned(String::from(s));
315315
///
316316
/// assert_eq!(
317317
/// cow.into_owned(),

alloc/src/fmt.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@
363363
//! # use std::fmt;
364364
//! # struct Foo; // our custom type
365365
//! # impl fmt::Display for Foo {
366-
//! fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
366+
//! fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
367367
//! # write!(f, "testing, testing")
368368
//! # } }
369369
//! ```
@@ -399,7 +399,7 @@
399399
//! }
400400
//!
401401
//! impl fmt::Display for Vector2D {
402-
//! fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
402+
//! fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
403403
//! // The `f` value implements the `Write` trait, which is what the
404404
//! // write! macro is expecting. Note that this formatting ignores the
405405
//! // various flags provided to format strings.
@@ -410,7 +410,7 @@
410410
//! // Different traits allow different forms of output of a type. The meaning
411411
//! // of this format is to print the magnitude of a vector.
412412
//! impl fmt::Binary for Vector2D {
413-
//! fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
413+
//! fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
414414
//! let magnitude = (self.x * self.x + self.y * self.y) as f64;
415415
//! let magnitude = magnitude.sqrt();
416416
//!
@@ -517,7 +517,7 @@
517517
//! let mut some_writer = io::stdout();
518518
//! write!(&mut some_writer, "{}", format_args!("print with a {}", "macro"));
519519
//!
520-
//! fn my_fmt_fn(args: fmt::Arguments) {
520+
//! fn my_fmt_fn(args: fmt::Arguments<'_>) {
521521
//! write!(&mut io::stdout(), "{args}");
522522
//! }
523523
//! my_fmt_fn(format_args!(", or a {} too", "function"));

alloc/src/rc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2039,7 +2039,7 @@ where
20392039
/// ```rust
20402040
/// # use std::rc::Rc;
20412041
/// # use std::borrow::Cow;
2042-
/// let cow: Cow<str> = Cow::Borrowed("eggplant");
2042+
/// let cow: Cow<'_, str> = Cow::Borrowed("eggplant");
20432043
/// let shared: Rc<str> = Rc::from(cow);
20442044
/// assert_eq!("eggplant", &shared[..]);
20452045
/// ```

alloc/src/string.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2741,7 +2741,7 @@ impl<'a> From<Cow<'a, str>> for String {
27412741
/// ```
27422742
/// # use std::borrow::Cow;
27432743
/// // If the string is not owned...
2744-
/// let cow: Cow<str> = Cow::Borrowed("eggplant");
2744+
/// let cow: Cow<'_, str> = Cow::Borrowed("eggplant");
27452745
/// // It will allocate on the heap and copy the string.
27462746
/// let owned: String = String::from(cow);
27472747
/// assert_eq!(&owned[..], "eggplant");

alloc/src/sync.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2768,7 +2768,7 @@ where
27682768
/// ```rust
27692769
/// # use std::sync::Arc;
27702770
/// # use std::borrow::Cow;
2771-
/// let cow: Cow<str> = Cow::Borrowed("eggplant");
2771+
/// let cow: Cow<'_, str> = Cow::Borrowed("eggplant");
27722772
/// let shared: Arc<str> = Arc::from(cow);
27732773
/// assert_eq!("eggplant", &shared[..]);
27742774
/// ```

alloc/src/vec/drain.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use super::Vec;
1616
///
1717
/// ```
1818
/// let mut v = vec![0, 1, 2];
19-
/// let iter: std::vec::Drain<_> = v.drain(..);
19+
/// let iter: std::vec::Drain<'_, _> = v.drain(..);
2020
/// ```
2121
#[stable(feature = "drain", since = "1.6.0")]
2222
pub struct Drain<

alloc/src/vec/drain_filter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use super::Vec;
1616
/// #![feature(drain_filter)]
1717
///
1818
/// let mut v = vec![0, 1, 2];
19-
/// let iter: std::vec::DrainFilter<_, _> = v.drain_filter(|x| *x % 2 == 0);
19+
/// let iter: std::vec::DrainFilter<'_, _, _> = v.drain_filter(|x| *x % 2 == 0);
2020
/// ```
2121
#[unstable(feature = "drain_filter", reason = "recently added", issue = "43244")]
2222
#[derive(Debug)]

alloc/src/vec/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3142,8 +3142,8 @@ where
31423142
///
31433143
/// ```
31443144
/// # use std::borrow::Cow;
3145-
/// let o: Cow<[i32]> = Cow::Owned(vec![1, 2, 3]);
3146-
/// let b: Cow<[i32]> = Cow::Borrowed(&[1, 2, 3]);
3145+
/// let o: Cow<'_, [i32]> = Cow::Owned(vec![1, 2, 3]);
3146+
/// let b: Cow<'_, [i32]> = Cow::Borrowed(&[1, 2, 3]);
31473147
/// assert_eq!(Vec::from(o), Vec::from(b));
31483148
/// ```
31493149
fn from(s: Cow<'a, [T]>) -> Vec<T> {

alloc/src/vec/splice.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use super::{Drain, Vec};
1414
/// ```
1515
/// let mut v = vec![0, 1, 2];
1616
/// let new = [7, 8];
17-
/// let iter: std::vec::Splice<_> = v.splice(1.., new);
17+
/// let iter: std::vec::Splice<'_, _> = v.splice(1.., new);
1818
/// ```
1919
#[derive(Debug)]
2020
#[stable(feature = "vec_splice", since = "1.21.0")]

core/src/cell.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
//! let shared_map: Rc<RefCell<_>> = Rc::new(RefCell::new(HashMap::new()));
116116
//! // Create a new block to limit the scope of the dynamic borrow
117117
//! {
118-
//! let mut map: RefMut<_> = shared_map.borrow_mut();
118+
//! let mut map: RefMut<'_, _> = shared_map.borrow_mut();
119119
//! map.insert("africa", 92388);
120120
//! map.insert("kyoto", 11837);
121121
//! map.insert("piccadilly", 11826);
@@ -1435,8 +1435,8 @@ impl<'b, T: ?Sized> Ref<'b, T> {
14351435
/// use std::cell::{RefCell, Ref};
14361436
///
14371437
/// let c = RefCell::new((5, 'b'));
1438-
/// let b1: Ref<(u32, char)> = c.borrow();
1439-
/// let b2: Ref<u32> = Ref::map(b1, |t| &t.0);
1438+
/// let b1: Ref<'_, (u32, char)> = c.borrow();
1439+
/// let b2: Ref<'_, u32> = Ref::map(b1, |t| &t.0);
14401440
/// assert_eq!(*b2, 5)
14411441
/// ```
14421442
#[stable(feature = "cell_map", since = "1.8.0")]
@@ -1464,8 +1464,8 @@ impl<'b, T: ?Sized> Ref<'b, T> {
14641464
/// use std::cell::{RefCell, Ref};
14651465
///
14661466
/// let c = RefCell::new(vec![1, 2, 3]);
1467-
/// let b1: Ref<Vec<u32>> = c.borrow();
1468-
/// let b2: Result<Ref<u32>, _> = Ref::filter_map(b1, |v| v.get(1));
1467+
/// let b1: Ref<'_, Vec<u32>> = c.borrow();
1468+
/// let b2: Result<Ref<'_, u32>, _> = Ref::filter_map(b1, |v| v.get(1));
14691469
/// assert_eq!(*b2.unwrap(), 2);
14701470
/// ```
14711471
#[stable(feature = "cell_filter_map", since = "1.63.0")]
@@ -1577,8 +1577,8 @@ impl<'b, T: ?Sized> RefMut<'b, T> {
15771577
///
15781578
/// let c = RefCell::new((5, 'b'));
15791579
/// {
1580-
/// let b1: RefMut<(u32, char)> = c.borrow_mut();
1581-
/// let mut b2: RefMut<u32> = RefMut::map(b1, |t| &mut t.0);
1580+
/// let b1: RefMut<'_, (u32, char)> = c.borrow_mut();
1581+
/// let mut b2: RefMut<'_, u32> = RefMut::map(b1, |t| &mut t.0);
15821582
/// assert_eq!(*b2, 5);
15831583
/// *b2 = 42;
15841584
/// }
@@ -1612,8 +1612,8 @@ impl<'b, T: ?Sized> RefMut<'b, T> {
16121612
/// let c = RefCell::new(vec![1, 2, 3]);
16131613
///
16141614
/// {
1615-
/// let b1: RefMut<Vec<u32>> = c.borrow_mut();
1616-
/// let mut b2: Result<RefMut<u32>, _> = RefMut::filter_map(b1, |v| v.get_mut(1));
1615+
/// let b1: RefMut<'_, Vec<u32>> = c.borrow_mut();
1616+
/// let mut b2: Result<RefMut<'_, u32>, _> = RefMut::filter_map(b1, |v| v.get_mut(1));
16171617
///
16181618
/// if let Ok(mut b2) = b2 {
16191619
/// *b2 += 2;

0 commit comments

Comments
 (0)