From 5d8058477e9f3a6bbff696b97ae2c06ccbd9133f Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Mon, 11 Feb 2019 23:00:01 -0800 Subject: Use less explicit shifting in std::net::ip Now that we have {to|from}_be_bytes the code can be simpler. (Inspired by PR #57740) --- src/libstd/net/ip.rs | 83 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 58 insertions(+), 25 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/net/ip.rs b/src/libstd/net/ip.rs index 4e064672fbc..df92462bd08 100644 --- a/src/libstd/net/ip.rs +++ b/src/libstd/net/ip.rs @@ -329,6 +329,8 @@ impl Ipv4Addr { /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub const fn new(a: u8, b: u8, c: u8, d: u8) -> Ipv4Addr { + // FIXME: should just be u32::from_be_bytes([a, b, c, d]), + // once that method is no longer rustc_const_unstable Ipv4Addr { inner: c::in_addr { s_addr: u32::to_be( @@ -392,6 +394,7 @@ impl Ipv4Addr { /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn octets(&self) -> [u8; 4] { + // This returns the order we want because s_addr is stored in big-endian. self.inner.s_addr.to_ne_bytes() } @@ -618,9 +621,13 @@ impl Ipv4Addr { /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn to_ipv6_compatible(&self) -> Ipv6Addr { - Ipv6Addr::new(0, 0, 0, 0, 0, 0, - ((self.octets()[0] as u16) << 8) | self.octets()[1] as u16, - ((self.octets()[2] as u16) << 8) | self.octets()[3] as u16) + let octets = self.octets(); + Ipv6Addr::from([ + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + octets[0], octets[1], octets[2], octets[3], + ]) } /// Converts this address to an IPv4-mapped [IPv6 address]. @@ -639,9 +646,13 @@ impl Ipv4Addr { /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn to_ipv6_mapped(&self) -> Ipv6Addr { - Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, - ((self.octets()[0] as u16) << 8) | self.octets()[1] as u16, - ((self.octets()[2] as u16) << 8) | self.octets()[3] as u16) + let octets = self.octets(); + Ipv6Addr::from([ + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0xFF, 0xFF, + octets[0], octets[1], octets[2], octets[3], + ]) } } @@ -784,7 +795,7 @@ impl From for u32 { /// ``` fn from(ip: Ipv4Addr) -> u32 { let ip = ip.octets(); - ((ip[0] as u32) << 24) + ((ip[1] as u32) << 16) + ((ip[2] as u32) << 8) + (ip[3] as u32) + u32::from_be_bytes(ip) } } @@ -801,7 +812,7 @@ impl From for Ipv4Addr { /// assert_eq!(Ipv4Addr::new(13, 12, 11, 10), addr); /// ``` fn from(ip: u32) -> Ipv4Addr { - Ipv4Addr::new((ip >> 24) as u8, (ip >> 16) as u8, (ip >> 8) as u8, ip as u8) + Ipv4Addr::from(ip.to_be_bytes()) } } @@ -909,14 +920,14 @@ impl Ipv6Addr { pub fn segments(&self) -> [u16; 8] { let arr = &self.inner.s6_addr; [ - (arr[0] as u16) << 8 | (arr[1] as u16), - (arr[2] as u16) << 8 | (arr[3] as u16), - (arr[4] as u16) << 8 | (arr[5] as u16), - (arr[6] as u16) << 8 | (arr[7] as u16), - (arr[8] as u16) << 8 | (arr[9] as u16), - (arr[10] as u16) << 8 | (arr[11] as u16), - (arr[12] as u16) << 8 | (arr[13] as u16), - (arr[14] as u16) << 8 | (arr[15] as u16), + u16::from_be_bytes([arr[0], arr[1]]), + u16::from_be_bytes([arr[2], arr[3]]), + u16::from_be_bytes([arr[4], arr[5]]), + u16::from_be_bytes([arr[6], arr[7]]), + u16::from_be_bytes([arr[8], arr[9]]), + u16::from_be_bytes([arr[10], arr[11]]), + u16::from_be_bytes([arr[12], arr[13]]), + u16::from_be_bytes([arr[14], arr[15]]), ] } @@ -1382,21 +1393,43 @@ impl FromInner for Ipv6Addr { #[stable(feature = "i128", since = "1.26.0")] impl From for u128 { + /// Convert an `Ipv6Addr` into a host byte order `u128`. + /// + /// # Examples + /// + /// ``` + /// use std::net::Ipv6Addr; + /// + /// let addr = Ipv6Addr::new( + /// 0x1020, 0x3040, 0x5060, 0x7080, + /// 0x90A0, 0xB0C0, 0xD0E0, 0xF00D, + /// ); + /// assert_eq!(0x102030405060708090A0B0C0D0E0F00D_u128, u128::from(addr)); + /// ``` fn from(ip: Ipv6Addr) -> u128 { - let ip = ip.segments(); - ((ip[0] as u128) << 112) + ((ip[1] as u128) << 96) + ((ip[2] as u128) << 80) + - ((ip[3] as u128) << 64) + ((ip[4] as u128) << 48) + ((ip[5] as u128) << 32) + - ((ip[6] as u128) << 16) + (ip[7] as u128) + let ip = ip.octets(); + u128::from_be_bytes(ip) } } #[stable(feature = "i128", since = "1.26.0")] impl From for Ipv6Addr { + /// Convert a host byte order `u128` into an `Ipv6Addr`. + /// + /// # Examples + /// + /// ``` + /// use std::net::Ipv6Addr; + /// + /// let addr = Ipv6Addr::from(0x102030405060708090A0B0C0D0E0F00D_u128); + /// assert_eq!( + /// Ipv6Addr::new( + /// 0x1020, 0x3040, 0x5060, 0x7080, + /// 0x90A0, 0xB0C0, 0xD0E0, 0xF00D, + /// ), + /// addr); + /// ``` fn from(ip: u128) -> Ipv6Addr { - Ipv6Addr::new( - (ip >> 112) as u16, (ip >> 96) as u16, (ip >> 80) as u16, - (ip >> 64) as u16, (ip >> 48) as u16, (ip >> 32) as u16, - (ip >> 16) as u16, ip as u16, - ) + Ipv6Addr::from(ip.to_be_bytes()) } } -- cgit 1.4.1-3-g733a5 From 564c569bcb1b85ec3b1f93de60b7f7b385c5bd17 Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Sat, 16 Feb 2019 23:18:43 -0800 Subject: Monomorphize less code in fs::{read|write} Since the generic-ness is only for the as_refs, might as well have std just compile the important part once instead of on every use. --- src/libstd/fs.rs | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 3538816c112..7074e08b9b9 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -254,10 +254,13 @@ fn initial_buffer_size(file: &File) -> usize { /// ``` #[stable(feature = "fs_read_write_bytes", since = "1.26.0")] pub fn read>(path: P) -> io::Result> { - let mut file = File::open(path)?; - let mut bytes = Vec::with_capacity(initial_buffer_size(&file)); - file.read_to_end(&mut bytes)?; - Ok(bytes) + fn inner(path: &Path) -> io::Result> { + let mut file = File::open(path)?; + let mut bytes = Vec::with_capacity(initial_buffer_size(&file)); + file.read_to_end(&mut bytes)?; + Ok(bytes) + } + inner(path.as_ref()) } /// Read the entire contents of a file into a string. @@ -296,10 +299,13 @@ pub fn read>(path: P) -> io::Result> { /// ``` #[stable(feature = "fs_read_write", since = "1.26.0")] pub fn read_to_string>(path: P) -> io::Result { - let mut file = File::open(path)?; - let mut string = String::with_capacity(initial_buffer_size(&file)); - file.read_to_string(&mut string)?; - Ok(string) + fn inner(path: &Path) -> io::Result { + let mut file = File::open(path)?; + let mut string = String::with_capacity(initial_buffer_size(&file)); + file.read_to_string(&mut string)?; + Ok(string) + } + inner(path.as_ref()) } /// Write a slice as the entire contents of a file. @@ -326,7 +332,10 @@ pub fn read_to_string>(path: P) -> io::Result { /// ``` #[stable(feature = "fs_read_write_bytes", since = "1.26.0")] pub fn write, C: AsRef<[u8]>>(path: P, contents: C) -> io::Result<()> { - File::create(path)?.write_all(contents.as_ref()) + fn inner(path: &Path, contents: &[u8]) -> io::Result<()> { + File::create(path)?.write_all(contents) + } + inner(path.as_ref(), contents.as_ref()) } impl File { -- cgit 1.4.1-3-g733a5 From a23c40ec9435dd7b784e833e876a133c627aff92 Mon Sep 17 00:00:00 2001 From: Aaron Stillwell Date: Sun, 17 Feb 2019 15:17:46 +0000 Subject: Add alias methods to PathBuf for underlying OsString Implemented the following methods on PathBuf which forward to the underlying OsString. - capacity - with_capacity - clear - reserve - reserve_exact - shrink_to_fit - shrink_to --- src/libstd/path.rs | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 81 insertions(+), 1 deletion(-) (limited to 'src/libstd') diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 0a9796d1a9c..3e794956550 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -1137,7 +1137,7 @@ impl PathBuf { /// /// ``` /// use std::path::PathBuf; - /// + /// /// let path = PathBuf::new(); /// ``` #[stable(feature = "rust1", since = "1.0.0")] @@ -1145,6 +1145,32 @@ impl PathBuf { PathBuf { inner: OsString::new() } } + /// Creates a new `PathBuf` with a given capacity used to create the + /// internal [`OsString`]. See [`with_capacity`] defined on [`OsString`]. + /// + /// # Examples + /// + /// ``` + /// use std::path::PathBuf; + /// + /// let path = PathBuf::with_capacity(10); + /// let capacity = path.capacity(); + /// + /// // This push is done without reallocating + /// path.push(r"C:\"); + /// + /// assert_eq!(capacity, path.capacity()); + /// ``` + /// + /// [`with_capacity`]: ../ffi/struct.OsString.html#method.with_capacity + /// [`OsString`]: ../ffi/struct.OsString.html + #[stable(feature = "path_buf_os_string_methods", since = "1.33.0")] + pub fn with_capacity(capacity: usize) -> PathBuf { + PathBuf { + inner: OsString::with_capacity(capacity) + } + } + /// Coerces to a [`Path`] slice. /// /// [`Path`]: struct.Path.html @@ -1373,6 +1399,60 @@ impl PathBuf { let rw = Box::into_raw(self.inner.into_boxed_os_str()) as *mut Path; unsafe { Box::from_raw(rw) } } + + /// Invokes [`capacity`] on the underlying instance of [`OsString`]. + /// + /// [`capacity`]: ../ffi/struct.OsString.html#method.capacity + /// [`OsString`]: ../ffi/struct.OsString.html + #[stable(feature = "path_buf_os_string_methods", since = "1.33.0")] + pub fn capacity(self) -> usize { + self.inner.capacity() + } + + /// Invokes [`clear`] on the underlying instance of [`OsString`]. + /// + /// [`clear`]: ../ffi/struct.OsString.html#method.clear + /// [`OsString`]: ../ffi/struct.OsString.html + #[stable(feature = "path_buf_os_string_methods", since = "1.33.0")] + pub fn clear(mut self) { + self.inner.clear() + } + + /// Invokes [`reserve`] on the underlying instance of [`OsString`]. + /// + /// [`reserve`]: ../ffi/struct.OsString.html#method.reserve + /// [`OsString`]: ../ffi/struct.OsString.html + #[stable(feature = "path_buf_os_string_methods", since = "1.33.0")] + pub fn reserve(mut self, additional: usize) { + self.inner.reserve(additional) + } + + /// Invokes [`reserve_exact`] on the underlying instance of [`OsString`]. + /// + /// [`reserve_exact`]: ../ffi/struct.OsString.html#method.reserve_exact + /// [`OsString`]: ../ffi/struct.OsString.html + #[stable(feature = "path_buf_os_string_methods", since = "1.33.0")] + pub fn reserve_exact(mut self, additional: usize) { + self.inner.reserve_exact(additional) + } + + /// Invokes [`shrink_to_fit`] on the underlying instance of [`OsString`]. + /// + /// [`shrink_to_fit`]: ../ffi/struct.OsString.html#method.shrink_to_fit + /// [`OsString`]: ../ffi/struct.OsString.html + #[stable(feature = "path_buf_os_string_methods", since = "1.33.0")] + pub fn shrink_to_fit(mut self) { + self.inner.shrink_to_fit() + } + + /// Invokes [`shrink_to`] on the underlying instance of [`OsString`]. + /// + /// [`shrink_to`]: ../ffi/struct.OsString.html#method.shrink_to + /// [`OsString`]: ../ffi/struct.OsString.html + #[stable(feature = "path_buf_os_string_methods", since = "1.33.0")] + pub fn shrink_to(mut self, min_capacity: usize) { + self.inner.shrink_to(min_capacity) + } } #[stable(feature = "box_from_path", since = "1.17.0")] -- cgit 1.4.1-3-g733a5 From dbf60d9ca1db6fb1ae296f25af02b27b8264577d Mon Sep 17 00:00:00 2001 From: Aaron Stillwell Date: Sun, 17 Feb 2019 16:41:05 +0000 Subject: Fixes for implementation of PathBuf methods (aliases for OsString) - Fixed incorrect `mut` usage - Fixed style in accordance with tidy - Marked all methods as unstable - Changed feature identifier to path_buf_alias_os_string_methods --- src/libstd/path.rs | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 3e794956550..0761b1d0a8f 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -1137,7 +1137,7 @@ impl PathBuf { /// /// ``` /// use std::path::PathBuf; - /// + /// /// let path = PathBuf::new(); /// ``` #[stable(feature = "rust1", since = "1.0.0")] @@ -1145,26 +1145,26 @@ impl PathBuf { PathBuf { inner: OsString::new() } } - /// Creates a new `PathBuf` with a given capacity used to create the + /// Creates a new `PathBuf` with a given capacity used to create the /// internal [`OsString`]. See [`with_capacity`] defined on [`OsString`]. /// /// # Examples - /// + /// /// ``` /// use std::path::PathBuf; - /// + /// /// let path = PathBuf::with_capacity(10); /// let capacity = path.capacity(); - /// + /// /// // This push is done without reallocating /// path.push(r"C:\"); /// /// assert_eq!(capacity, path.capacity()); /// ``` - /// + /// /// [`with_capacity`]: ../ffi/struct.OsString.html#method.with_capacity /// [`OsString`]: ../ffi/struct.OsString.html - #[stable(feature = "path_buf_os_string_methods", since = "1.33.0")] + #[unstable(feature = "path_buf_alias_os_string_methods", issue = "58234")] pub fn with_capacity(capacity: usize) -> PathBuf { PathBuf { inner: OsString::with_capacity(capacity) @@ -1404,8 +1404,8 @@ impl PathBuf { /// /// [`capacity`]: ../ffi/struct.OsString.html#method.capacity /// [`OsString`]: ../ffi/struct.OsString.html - #[stable(feature = "path_buf_os_string_methods", since = "1.33.0")] - pub fn capacity(self) -> usize { + #[unstable(feature = "path_buf_alias_os_string_methods", issue = "58234")] + pub fn capacity(&self) -> usize { self.inner.capacity() } @@ -1413,8 +1413,8 @@ impl PathBuf { /// /// [`clear`]: ../ffi/struct.OsString.html#method.clear /// [`OsString`]: ../ffi/struct.OsString.html - #[stable(feature = "path_buf_os_string_methods", since = "1.33.0")] - pub fn clear(mut self) { + #[unstable(feature = "path_buf_alias_os_string_methods", issue = "58234")] + pub fn clear(&mut self) { self.inner.clear() } @@ -1422,8 +1422,8 @@ impl PathBuf { /// /// [`reserve`]: ../ffi/struct.OsString.html#method.reserve /// [`OsString`]: ../ffi/struct.OsString.html - #[stable(feature = "path_buf_os_string_methods", since = "1.33.0")] - pub fn reserve(mut self, additional: usize) { + #[unstable(feature = "path_buf_alias_os_string_methods", issue = "58234")] + pub fn reserve(&mut self, additional: usize) { self.inner.reserve(additional) } @@ -1431,8 +1431,8 @@ impl PathBuf { /// /// [`reserve_exact`]: ../ffi/struct.OsString.html#method.reserve_exact /// [`OsString`]: ../ffi/struct.OsString.html - #[stable(feature = "path_buf_os_string_methods", since = "1.33.0")] - pub fn reserve_exact(mut self, additional: usize) { + #[unstable(feature = "path_buf_alias_os_string_methods", issue = "58234")] + pub fn reserve_exact(&mut self, additional: usize) { self.inner.reserve_exact(additional) } @@ -1440,8 +1440,8 @@ impl PathBuf { /// /// [`shrink_to_fit`]: ../ffi/struct.OsString.html#method.shrink_to_fit /// [`OsString`]: ../ffi/struct.OsString.html - #[stable(feature = "path_buf_os_string_methods", since = "1.33.0")] - pub fn shrink_to_fit(mut self) { + #[unstable(feature = "path_buf_alias_os_string_methods", issue = "58234")] + pub fn shrink_to_fit(&mut self) { self.inner.shrink_to_fit() } @@ -1449,8 +1449,8 @@ impl PathBuf { /// /// [`shrink_to`]: ../ffi/struct.OsString.html#method.shrink_to /// [`OsString`]: ../ffi/struct.OsString.html - #[stable(feature = "path_buf_os_string_methods", since = "1.33.0")] - pub fn shrink_to(mut self, min_capacity: usize) { + #[unstable(feature = "path_buf_alias_os_string_methods", issue = "58234")] + pub fn shrink_to(&mut self, min_capacity: usize) { self.inner.shrink_to(min_capacity) } } -- cgit 1.4.1-3-g733a5 From 35d8c4400dcf346bbddfe53ddc48125b148b29bb Mon Sep 17 00:00:00 2001 From: Aaron Stillwell Date: Sun, 17 Feb 2019 17:14:10 +0000 Subject: Changed feature gate for new PathBuf methods Feature gate changed to `path_buf_capacity` as per advice from @Mark-Simulacrum --- src/libstd/path.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 0761b1d0a8f..735714aca10 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -1164,7 +1164,7 @@ impl PathBuf { /// /// [`with_capacity`]: ../ffi/struct.OsString.html#method.with_capacity /// [`OsString`]: ../ffi/struct.OsString.html - #[unstable(feature = "path_buf_alias_os_string_methods", issue = "58234")] + #[unstable(feature = "path_buf_capacity", issue = "58234")] pub fn with_capacity(capacity: usize) -> PathBuf { PathBuf { inner: OsString::with_capacity(capacity) @@ -1404,7 +1404,7 @@ impl PathBuf { /// /// [`capacity`]: ../ffi/struct.OsString.html#method.capacity /// [`OsString`]: ../ffi/struct.OsString.html - #[unstable(feature = "path_buf_alias_os_string_methods", issue = "58234")] + #[unstable(feature = "path_buf_capacity", issue = "58234")] pub fn capacity(&self) -> usize { self.inner.capacity() } @@ -1413,7 +1413,7 @@ impl PathBuf { /// /// [`clear`]: ../ffi/struct.OsString.html#method.clear /// [`OsString`]: ../ffi/struct.OsString.html - #[unstable(feature = "path_buf_alias_os_string_methods", issue = "58234")] + #[unstable(feature = "path_buf_capacity", issue = "58234")] pub fn clear(&mut self) { self.inner.clear() } @@ -1422,7 +1422,7 @@ impl PathBuf { /// /// [`reserve`]: ../ffi/struct.OsString.html#method.reserve /// [`OsString`]: ../ffi/struct.OsString.html - #[unstable(feature = "path_buf_alias_os_string_methods", issue = "58234")] + #[unstable(feature = "path_buf_capacity", issue = "58234")] pub fn reserve(&mut self, additional: usize) { self.inner.reserve(additional) } @@ -1431,7 +1431,7 @@ impl PathBuf { /// /// [`reserve_exact`]: ../ffi/struct.OsString.html#method.reserve_exact /// [`OsString`]: ../ffi/struct.OsString.html - #[unstable(feature = "path_buf_alias_os_string_methods", issue = "58234")] + #[unstable(feature = "path_buf_capacity", issue = "58234")] pub fn reserve_exact(&mut self, additional: usize) { self.inner.reserve_exact(additional) } @@ -1440,7 +1440,7 @@ impl PathBuf { /// /// [`shrink_to_fit`]: ../ffi/struct.OsString.html#method.shrink_to_fit /// [`OsString`]: ../ffi/struct.OsString.html - #[unstable(feature = "path_buf_alias_os_string_methods", issue = "58234")] + #[unstable(feature = "path_buf_capacity", issue = "58234")] pub fn shrink_to_fit(&mut self) { self.inner.shrink_to_fit() } @@ -1449,7 +1449,7 @@ impl PathBuf { /// /// [`shrink_to`]: ../ffi/struct.OsString.html#method.shrink_to /// [`OsString`]: ../ffi/struct.OsString.html - #[unstable(feature = "path_buf_alias_os_string_methods", issue = "58234")] + #[unstable(feature = "path_buf_capacity", issue = "58234")] pub fn shrink_to(&mut self, min_capacity: usize) { self.inner.shrink_to(min_capacity) } -- cgit 1.4.1-3-g733a5 From 0b9ad6e6fd017837647eed8e5ae824d1f6e278b2 Mon Sep 17 00:00:00 2001 From: Stein Somers Date: Mon, 4 Feb 2019 23:47:28 +0100 Subject: Explain a panic in test case net::tcp::tests::double_bind --- src/libstd/net/tcp.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/net/tcp.rs b/src/libstd/net/tcp.rs index 86ecb10edf2..c2bc85ae576 100644 --- a/src/libstd/net/tcp.rs +++ b/src/libstd/net/tcp.rs @@ -1187,9 +1187,13 @@ mod tests { #[test] fn double_bind() { each_ip(&mut |addr| { - let _listener = t!(TcpListener::bind(&addr)); + let listener1 = t!(TcpListener::bind(&addr)); match TcpListener::bind(&addr) { - Ok(..) => panic!(), + Ok(listener2) => panic!( + "This system (perhaps due to options set by TcpListener::bind) \ + permits double binding: {:?} and {:?}", + listener1, listener2 + ), Err(e) => { assert!(e.kind() == ErrorKind::ConnectionRefused || e.kind() == ErrorKind::Other || -- cgit 1.4.1-3-g733a5 From 3bea2ca49d24606920b3a81811379debc0668992 Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Sun, 17 Feb 2019 19:42:36 -0800 Subject: Use more impl header lifetime elision There are two big categories of changes in here - Removing lifetimes from common traits that can essentially never user a lifetime from an input (particularly `Drop` & `Debug`) - Forwarding impls that are only possible because the lifetime doesn't matter (like `impl Read for &mut R`) I omitted things that seemed like they could be more controversial, like the handful of iterators that have a `Item: 'static` despite the iterator having a lifetime or the `PartialEq` implementations where the flipped one cannot elide the lifetime. --- src/liballoc/borrow.rs | 16 ++++---- src/liballoc/collections/binary_heap.rs | 4 +- src/liballoc/collections/btree/map.rs | 16 ++++---- src/liballoc/collections/btree/set.rs | 24 ++++++------ src/liballoc/collections/linked_list.rs | 8 ++-- src/liballoc/collections/vec_deque.rs | 6 +-- src/liballoc/vec.rs | 2 +- src/libcore/future/future.rs | 2 +- src/libcore/internal_macros.rs | 2 +- src/libcore/option.rs | 8 ++-- src/libcore/slice/mod.rs | 32 ++++++++-------- src/libcore/str/mod.rs | 2 +- src/libstd/collections/hash/map.rs | 66 ++++++++++++++++----------------- src/libstd/collections/hash/set.rs | 48 ++++++++++++------------ src/libstd/collections/hash/table.rs | 32 ++++++++-------- src/libstd/env.rs | 2 +- src/libstd/ffi/c_str.rs | 4 +- src/libstd/ffi/os_str.rs | 4 +- src/libstd/fs.rs | 6 +-- src/libstd/io/buffered.rs | 2 +- src/libstd/io/cursor.rs | 4 +- src/libstd/io/impls.rs | 14 +++---- src/libstd/io/mod.rs | 4 +- src/libstd/io/stdio.rs | 14 +++---- src/libstd/net/addr.rs | 4 +- src/libstd/net/tcp.rs | 4 +- src/libstd/panic.rs | 6 +-- src/libstd/path.rs | 44 +++++++++++----------- src/libstd/sync/mpsc/select.rs | 4 +- src/libstd/sync/mutex.rs | 14 +++---- src/libstd/sync/once.rs | 2 +- src/libstd/sync/rwlock.rs | 26 ++++++------- src/libstd/sys_common/bytestring.rs | 2 +- src/libstd/sys_common/mutex.rs | 2 +- src/libstd/sys_common/remutex.rs | 8 ++-- 35 files changed, 219 insertions(+), 219 deletions(-) (limited to 'src/libstd') diff --git a/src/liballoc/borrow.rs b/src/liballoc/borrow.rs index 270f48e8083..c66879cd655 100644 --- a/src/liballoc/borrow.rs +++ b/src/liballoc/borrow.rs @@ -182,8 +182,8 @@ pub enum Cow<'a, B: ?Sized + 'a> } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, B: ?Sized + ToOwned> Clone for Cow<'a, B> { - fn clone(&self) -> Cow<'a, B> { +impl Clone for Cow<'_, B> { + fn clone(&self) -> Self { match *self { Borrowed(b) => Borrowed(b), Owned(ref o) => { @@ -193,7 +193,7 @@ impl<'a, B: ?Sized + ToOwned> Clone for Cow<'a, B> { } } - fn clone_from(&mut self, source: &Cow<'a, B>) { + fn clone_from(&mut self, source: &Self) { if let Owned(ref mut dest) = *self { if let Owned(ref o) = *source { o.borrow().clone_into(dest); @@ -296,11 +296,11 @@ impl Deref for Cow<'_, B> { impl Eq for Cow<'_, B> where B: Eq + ToOwned {} #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, B: ?Sized> Ord for Cow<'a, B> +impl Ord for Cow<'_, B> where B: Ord + ToOwned { #[inline] - fn cmp(&self, other: &Cow<'a, B>) -> Ordering { + fn cmp(&self, other: &Self) -> Ordering { Ord::cmp(&**self, &**other) } } @@ -353,18 +353,18 @@ impl fmt::Display for Cow<'_, B> } #[stable(feature = "default", since = "1.11.0")] -impl<'a, B: ?Sized> Default for Cow<'a, B> +impl Default for Cow<'_, B> where B: ToOwned, ::Owned: Default { /// Creates an owned Cow<'a, B> with the default value for the contained owned value. - fn default() -> Cow<'a, B> { + fn default() -> Self { Owned(::Owned::default()) } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, B: ?Sized> Hash for Cow<'a, B> +impl Hash for Cow<'_, B> where B: Hash + ToOwned { #[inline] diff --git a/src/liballoc/collections/binary_heap.rs b/src/liballoc/collections/binary_heap.rs index 6214e1ce245..b0fd77b63bc 100644 --- a/src/liballoc/collections/binary_heap.rs +++ b/src/liballoc/collections/binary_heap.rs @@ -947,8 +947,8 @@ impl fmt::Debug for Iter<'_, T> { // FIXME(#26925) Remove in favor of `#[derive(Clone)]` #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T> Clone for Iter<'a, T> { - fn clone(&self) -> Iter<'a, T> { +impl Clone for Iter<'_, T> { + fn clone(&self) -> Self { Iter { iter: self.iter.clone() } } } diff --git a/src/liballoc/collections/btree/map.rs b/src/liballoc/collections/btree/map.rs index aaaa419dcb8..76c3945a182 100644 --- a/src/liballoc/collections/btree/map.rs +++ b/src/liballoc/collections/btree/map.rs @@ -1218,8 +1218,8 @@ impl ExactSizeIterator for Iter<'_, K, V> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, K, V> Clone for Iter<'a, K, V> { - fn clone(&self) -> Iter<'a, K, V> { +impl Clone for Iter<'_, K, V> { + fn clone(&self) -> Self { Iter { range: self.range.clone(), length: self.length, @@ -1441,8 +1441,8 @@ impl ExactSizeIterator for Keys<'_, K, V> { impl FusedIterator for Keys<'_, K, V> {} #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, K, V> Clone for Keys<'a, K, V> { - fn clone(&self) -> Keys<'a, K, V> { +impl Clone for Keys<'_, K, V> { + fn clone(&self) -> Self { Keys { inner: self.inner.clone() } } } @@ -1478,8 +1478,8 @@ impl ExactSizeIterator for Values<'_, K, V> { impl FusedIterator for Values<'_, K, V> {} #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, K, V> Clone for Values<'a, K, V> { - fn clone(&self) -> Values<'a, K, V> { +impl Clone for Values<'_, K, V> { + fn clone(&self) -> Self { Values { inner: self.inner.clone() } } } @@ -1606,8 +1606,8 @@ impl<'a, K, V> Range<'a, K, V> { impl FusedIterator for Range<'_, K, V> {} #[stable(feature = "btree_range", since = "1.17.0")] -impl<'a, K, V> Clone for Range<'a, K, V> { - fn clone(&self) -> Range<'a, K, V> { +impl Clone for Range<'_, K, V> { + fn clone(&self) -> Self { Range { front: self.front, back: self.back, diff --git a/src/liballoc/collections/btree/set.rs b/src/liballoc/collections/btree/set.rs index 78cd21dd411..84649466fad 100644 --- a/src/liballoc/collections/btree/set.rs +++ b/src/liballoc/collections/btree/set.rs @@ -907,8 +907,8 @@ impl Debug for BTreeSet { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T> Clone for Iter<'a, T> { - fn clone(&self) -> Iter<'a, T> { +impl Clone for Iter<'_, T> { + fn clone(&self) -> Self { Iter { iter: self.iter.clone() } } } @@ -963,8 +963,8 @@ impl ExactSizeIterator for IntoIter { impl FusedIterator for IntoIter {} #[stable(feature = "btree_range", since = "1.17.0")] -impl<'a, T> Clone for Range<'a, T> { - fn clone(&self) -> Range<'a, T> { +impl Clone for Range<'_, T> { + fn clone(&self) -> Self { Range { iter: self.iter.clone() } } } @@ -998,8 +998,8 @@ fn cmp_opt(x: Option<&T>, y: Option<&T>, short: Ordering, long: Ordering } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T> Clone for Difference<'a, T> { - fn clone(&self) -> Difference<'a, T> { +impl Clone for Difference<'_, T> { + fn clone(&self) -> Self { Difference { a: self.a.clone(), b: self.b.clone(), @@ -1036,8 +1036,8 @@ impl<'a, T: Ord> Iterator for Difference<'a, T> { impl FusedIterator for Difference<'_, T> {} #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T> Clone for SymmetricDifference<'a, T> { - fn clone(&self) -> SymmetricDifference<'a, T> { +impl Clone for SymmetricDifference<'_, T> { + fn clone(&self) -> Self { SymmetricDifference { a: self.a.clone(), b: self.b.clone(), @@ -1070,8 +1070,8 @@ impl<'a, T: Ord> Iterator for SymmetricDifference<'a, T> { impl FusedIterator for SymmetricDifference<'_, T> {} #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T> Clone for Intersection<'a, T> { - fn clone(&self) -> Intersection<'a, T> { +impl Clone for Intersection<'_, T> { + fn clone(&self) -> Self { Intersection { a: self.a.clone(), b: self.b.clone(), @@ -1108,8 +1108,8 @@ impl<'a, T: Ord> Iterator for Intersection<'a, T> { impl FusedIterator for Intersection<'_, T> {} #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T> Clone for Union<'a, T> { - fn clone(&self) -> Union<'a, T> { +impl Clone for Union<'_, T> { + fn clone(&self) -> Self { Union { a: self.a.clone(), b: self.b.clone(), diff --git a/src/liballoc/collections/linked_list.rs b/src/liballoc/collections/linked_list.rs index afd8078cdd7..c2ee2e63156 100644 --- a/src/liballoc/collections/linked_list.rs +++ b/src/liballoc/collections/linked_list.rs @@ -1200,16 +1200,16 @@ unsafe impl Send for LinkedList {} unsafe impl Sync for LinkedList {} #[stable(feature = "rust1", since = "1.0.0")] -unsafe impl<'a, T: Sync> Send for Iter<'a, T> {} +unsafe impl Send for Iter<'_, T> {} #[stable(feature = "rust1", since = "1.0.0")] -unsafe impl<'a, T: Sync> Sync for Iter<'a, T> {} +unsafe impl Sync for Iter<'_, T> {} #[stable(feature = "rust1", since = "1.0.0")] -unsafe impl<'a, T: Send> Send for IterMut<'a, T> {} +unsafe impl Send for IterMut<'_, T> {} #[stable(feature = "rust1", since = "1.0.0")] -unsafe impl<'a, T: Sync> Sync for IterMut<'a, T> {} +unsafe impl Sync for IterMut<'_, T> {} #[cfg(test)] mod tests { diff --git a/src/liballoc/collections/vec_deque.rs b/src/liballoc/collections/vec_deque.rs index 99fa54acb08..7a355fa7e2a 100644 --- a/src/liballoc/collections/vec_deque.rs +++ b/src/liballoc/collections/vec_deque.rs @@ -2132,8 +2132,8 @@ impl fmt::Debug for Iter<'_, T> { // FIXME(#26925) Remove in favor of `#[derive(Clone)]` #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T> Clone for Iter<'a, T> { - fn clone(&self) -> Iter<'a, T> { +impl Clone for Iter<'_, T> { + fn clone(&self) -> Self { Iter { ring: self.ring, tail: self.tail, @@ -2225,7 +2225,7 @@ pub struct IterMut<'a, T: 'a> { } #[stable(feature = "collection_debug", since = "1.17.0")] -impl<'a, T: fmt::Debug> fmt::Debug for IterMut<'_, T> { +impl fmt::Debug for IterMut<'_, T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let (front, back) = RingSlices::ring_slices(&*self.ring, self.head, self.tail); f.debug_tuple("IterMut") diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index 57e10498b92..95d5e02a2ed 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -2455,7 +2455,7 @@ pub struct Drain<'a, T: 'a> { } #[stable(feature = "collection_debug", since = "1.17.0")] -impl<'a, T: 'a + fmt::Debug> fmt::Debug for Drain<'a, T> { +impl fmt::Debug for Drain<'_, T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("Drain") .field(&self.iter.as_slice()) diff --git a/src/libcore/future/future.rs b/src/libcore/future/future.rs index 539b07fc21e..fa38a7c3c4c 100644 --- a/src/libcore/future/future.rs +++ b/src/libcore/future/future.rs @@ -100,7 +100,7 @@ pub trait Future { fn poll(self: Pin<&mut Self>, lw: &LocalWaker) -> Poll; } -impl<'a, F: ?Sized + Future + Unpin> Future for &'a mut F { +impl Future for &mut F { type Output = F::Output; fn poll(mut self: Pin<&mut Self>, lw: &LocalWaker) -> Poll { diff --git a/src/libcore/internal_macros.rs b/src/libcore/internal_macros.rs index d12800f7124..4d7255b6367 100644 --- a/src/libcore/internal_macros.rs +++ b/src/libcore/internal_macros.rs @@ -7,7 +7,7 @@ macro_rules! forward_ref_unop { }; (impl $imp:ident, $method:ident for $t:ty, #[$attr:meta]) => { #[$attr] - impl<'a> $imp for &'a $t { + impl $imp for &$t { type Output = <$t as $imp>::Output; #[inline] diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 0e54397db02..91bb6d66d34 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -874,7 +874,7 @@ impl Option { } } -impl<'a, T: Copy> Option<&'a T> { +impl Option<&T> { /// Maps an `Option<&T>` to an `Option` by copying the contents of the /// option. /// @@ -895,7 +895,7 @@ impl<'a, T: Copy> Option<&'a T> { } } -impl<'a, T: Copy> Option<&'a mut T> { +impl Option<&mut T> { /// Maps an `Option<&mut T>` to an `Option` by copying the contents of the /// option. /// @@ -916,7 +916,7 @@ impl<'a, T: Copy> Option<&'a mut T> { } } -impl<'a, T: Clone> Option<&'a T> { +impl Option<&T> { /// Maps an `Option<&T>` to an `Option` by cloning the contents of the /// option. /// @@ -935,7 +935,7 @@ impl<'a, T: Clone> Option<&'a T> { } } -impl<'a, T: Clone> Option<&'a mut T> { +impl Option<&mut T> { /// Maps an `Option<&mut T>` to an `Option` by cloning the contents of the /// option. /// diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index d062da0c247..6b5c94aac48 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -2899,7 +2899,7 @@ macro_rules! iterator { } #[stable(feature = "rust1", since = "1.0.0")] - impl<'a, T> ExactSizeIterator for $name<'a, T> { + impl ExactSizeIterator for $name<'_, T> { #[inline(always)] fn len(&self) -> usize { len!(self) @@ -3094,10 +3094,10 @@ macro_rules! iterator { } #[stable(feature = "fused", since = "1.26.0")] - impl<'a, T> FusedIterator for $name<'a, T> {} + impl FusedIterator for $name<'_, T> {} #[unstable(feature = "trusted_len", issue = "37572")] - unsafe impl<'a, T> TrustedLen for $name<'a, T> {} + unsafe impl TrustedLen for $name<'_, T> {} } } @@ -4361,8 +4361,8 @@ pub struct RChunks<'a, T:'a> { // FIXME(#26925) Remove in favor of `#[derive(Clone)]` #[stable(feature = "rchunks", since = "1.31.0")] -impl<'a, T> Clone for RChunks<'a, T> { - fn clone(&self) -> RChunks<'a, T> { +impl Clone for RChunks<'_, T> { + fn clone(&self) -> Self { RChunks { v: self.v, chunk_size: self.chunk_size, @@ -4451,13 +4451,13 @@ impl<'a, T> DoubleEndedIterator for RChunks<'a, T> { } #[stable(feature = "rchunks", since = "1.31.0")] -impl<'a, T> ExactSizeIterator for RChunks<'a, T> {} +impl ExactSizeIterator for RChunks<'_, T> {} #[unstable(feature = "trusted_len", issue = "37572")] -unsafe impl<'a, T> TrustedLen for RChunks<'a, T> {} +unsafe impl TrustedLen for RChunks<'_, T> {} #[stable(feature = "rchunks", since = "1.31.0")] -impl<'a, T> FusedIterator for RChunks<'a, T> {} +impl FusedIterator for RChunks<'_, T> {} #[doc(hidden)] #[stable(feature = "rchunks", since = "1.31.0")] @@ -4576,13 +4576,13 @@ impl<'a, T> DoubleEndedIterator for RChunksMut<'a, T> { } #[stable(feature = "rchunks", since = "1.31.0")] -impl<'a, T> ExactSizeIterator for RChunksMut<'a, T> {} +impl ExactSizeIterator for RChunksMut<'_, T> {} #[unstable(feature = "trusted_len", issue = "37572")] -unsafe impl<'a, T> TrustedLen for RChunksMut<'a, T> {} +unsafe impl TrustedLen for RChunksMut<'_, T> {} #[stable(feature = "rchunks", since = "1.31.0")] -impl<'a, T> FusedIterator for RChunksMut<'a, T> {} +impl FusedIterator for RChunksMut<'_, T> {} #[doc(hidden)] #[stable(feature = "rchunks", since = "1.31.0")] @@ -4707,10 +4707,10 @@ impl<'a, T> ExactSizeIterator for RChunksExact<'a, T> { } #[unstable(feature = "trusted_len", issue = "37572")] -unsafe impl<'a, T> TrustedLen for RChunksExact<'a, T> {} +unsafe impl TrustedLen for RChunksExact<'_, T> {} #[stable(feature = "rchunks", since = "1.31.0")] -impl<'a, T> FusedIterator for RChunksExact<'a, T> {} +impl FusedIterator for RChunksExact<'_, T> {} #[doc(hidden)] #[stable(feature = "rchunks", since = "1.31.0")] @@ -4818,17 +4818,17 @@ impl<'a, T> DoubleEndedIterator for RChunksExactMut<'a, T> { } #[stable(feature = "rchunks", since = "1.31.0")] -impl<'a, T> ExactSizeIterator for RChunksExactMut<'a, T> { +impl ExactSizeIterator for RChunksExactMut<'_, T> { fn is_empty(&self) -> bool { self.v.is_empty() } } #[unstable(feature = "trusted_len", issue = "37572")] -unsafe impl<'a, T> TrustedLen for RChunksExactMut<'a, T> {} +unsafe impl TrustedLen for RChunksExactMut<'_, T> {} #[stable(feature = "rchunks", since = "1.31.0")] -impl<'a, T> FusedIterator for RChunksExactMut<'a, T> {} +impl FusedIterator for RChunksExactMut<'_, T> {} #[doc(hidden)] #[stable(feature = "rchunks", since = "1.31.0")] diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index e9190cc3ddf..e3e73f50fbe 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -820,7 +820,7 @@ impl FusedIterator for Bytes<'_> {} unsafe impl TrustedLen for Bytes<'_> {} #[doc(hidden)] -unsafe impl<'a> TrustedRandomAccess for Bytes<'a> { +unsafe impl TrustedRandomAccess for Bytes<'_> { unsafe fn get_unchecked(&mut self, i: usize) -> u8 { self.0.get_unchecked(i) } diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 91c4e990e00..3dd299bf0ef 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -1641,7 +1641,7 @@ impl Default for HashMap } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, K, Q: ?Sized, V, S> Index<&'a Q> for HashMap +impl Index<&Q> for HashMap where K: Eq + Hash + Borrow, Q: Eq + Hash, S: BuildHasher @@ -1673,14 +1673,14 @@ pub struct Iter<'a, K: 'a, V: 'a> { // FIXME(#26925) Remove in favor of `#[derive(Clone)]` #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, K, V> Clone for Iter<'a, K, V> { - fn clone(&self) -> Iter<'a, K, V> { +impl Clone for Iter<'_, K, V> { + fn clone(&self) -> Self { Iter { inner: self.inner.clone() } } } #[stable(feature = "std_debug", since = "1.16.0")] -impl<'a, K: Debug, V: Debug> fmt::Debug for Iter<'a, K, V> { +impl fmt::Debug for Iter<'_, K, V> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_list() .entries(self.clone()) @@ -1726,14 +1726,14 @@ pub struct Keys<'a, K: 'a, V: 'a> { // FIXME(#26925) Remove in favor of `#[derive(Clone)]` #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, K, V> Clone for Keys<'a, K, V> { - fn clone(&self) -> Keys<'a, K, V> { +impl Clone for Keys<'_, K, V> { + fn clone(&self) -> Self { Keys { inner: self.inner.clone() } } } #[stable(feature = "std_debug", since = "1.16.0")] -impl<'a, K: Debug, V> fmt::Debug for Keys<'a, K, V> { +impl fmt::Debug for Keys<'_, K, V> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_list() .entries(self.clone()) @@ -1755,14 +1755,14 @@ pub struct Values<'a, K: 'a, V: 'a> { // FIXME(#26925) Remove in favor of `#[derive(Clone)]` #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, K, V> Clone for Values<'a, K, V> { - fn clone(&self) -> Values<'a, K, V> { +impl Clone for Values<'_, K, V> { + fn clone(&self) -> Self { Values { inner: self.inner.clone() } } } #[stable(feature = "std_debug", since = "1.16.0")] -impl<'a, K, V: Debug> fmt::Debug for Values<'a, K, V> { +impl fmt::Debug for Values<'_, K, V> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_list() .entries(self.clone()) @@ -2241,7 +2241,7 @@ impl<'a, K, V, S> RawVacantEntryMut<'a, K, V, S> { } #[unstable(feature = "hash_raw_entry", issue = "56167")] -impl<'a, K, V, S> Debug for RawEntryBuilderMut<'a, K, V, S> { +impl Debug for RawEntryBuilderMut<'_, K, V, S> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("RawEntryBuilder") .finish() @@ -2249,7 +2249,7 @@ impl<'a, K, V, S> Debug for RawEntryBuilderMut<'a, K, V, S> { } #[unstable(feature = "hash_raw_entry", issue = "56167")] -impl<'a, K: Debug, V: Debug, S> Debug for RawEntryMut<'a, K, V, S> { +impl Debug for RawEntryMut<'_, K, V, S> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { RawEntryMut::Vacant(ref v) => { @@ -2267,7 +2267,7 @@ impl<'a, K: Debug, V: Debug, S> Debug for RawEntryMut<'a, K, V, S> { } #[unstable(feature = "hash_raw_entry", issue = "56167")] -impl<'a, K: Debug, V: Debug> Debug for RawOccupiedEntryMut<'a, K, V> { +impl Debug for RawOccupiedEntryMut<'_, K, V> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("RawOccupiedEntryMut") .field("key", self.key()) @@ -2277,7 +2277,7 @@ impl<'a, K: Debug, V: Debug> Debug for RawOccupiedEntryMut<'a, K, V> { } #[unstable(feature = "hash_raw_entry", issue = "56167")] -impl<'a, K, V, S> Debug for RawVacantEntryMut<'a, K, V, S> { +impl Debug for RawVacantEntryMut<'_, K, V, S> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("RawVacantEntryMut") .finish() @@ -2285,7 +2285,7 @@ impl<'a, K, V, S> Debug for RawVacantEntryMut<'a, K, V, S> { } #[unstable(feature = "hash_raw_entry", issue = "56167")] -impl<'a, K, V, S> Debug for RawEntryBuilder<'a, K, V, S> { +impl Debug for RawEntryBuilder<'_, K, V, S> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("RawEntryBuilder") .finish() @@ -2312,7 +2312,7 @@ pub enum Entry<'a, K: 'a, V: 'a> { } #[stable(feature= "debug_hash_map", since = "1.12.0")] -impl<'a, K: 'a + Debug, V: 'a + Debug> Debug for Entry<'a, K, V> { +impl Debug for Entry<'_, K, V> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { Vacant(ref v) => { @@ -2340,7 +2340,7 @@ pub struct OccupiedEntry<'a, K: 'a, V: 'a> { } #[stable(feature= "debug_hash_map", since = "1.12.0")] -impl<'a, K: 'a + Debug, V: 'a + Debug> Debug for OccupiedEntry<'a, K, V> { +impl Debug for OccupiedEntry<'_, K, V> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("OccupiedEntry") .field("key", self.key()) @@ -2361,7 +2361,7 @@ pub struct VacantEntry<'a, K: 'a, V: 'a> { } #[stable(feature= "debug_hash_map", since = "1.12.0")] -impl<'a, K: 'a + Debug, V: 'a> Debug for VacantEntry<'a, K, V> { +impl Debug for VacantEntry<'_, K, V> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_tuple("VacantEntry") .field(self.key()) @@ -2448,7 +2448,7 @@ impl<'a, K, V> Iterator for Iter<'a, K, V> { } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, K, V> ExactSizeIterator for Iter<'a, K, V> { +impl ExactSizeIterator for Iter<'_, K, V> { #[inline] fn len(&self) -> usize { self.inner.len() @@ -2456,7 +2456,7 @@ impl<'a, K, V> ExactSizeIterator for Iter<'a, K, V> { } #[stable(feature = "fused", since = "1.26.0")] -impl<'a, K, V> FusedIterator for Iter<'a, K, V> {} +impl FusedIterator for Iter<'_, K, V> {} #[stable(feature = "rust1", since = "1.0.0")] impl<'a, K, V> Iterator for IterMut<'a, K, V> { @@ -2472,17 +2472,17 @@ impl<'a, K, V> Iterator for IterMut<'a, K, V> { } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, K, V> ExactSizeIterator for IterMut<'a, K, V> { +impl ExactSizeIterator for IterMut<'_, K, V> { #[inline] fn len(&self) -> usize { self.inner.len() } } #[stable(feature = "fused", since = "1.26.0")] -impl<'a, K, V> FusedIterator for IterMut<'a, K, V> {} +impl FusedIterator for IterMut<'_, K, V> {} #[stable(feature = "std_debug", since = "1.16.0")] -impl<'a, K, V> fmt::Debug for IterMut<'a, K, V> +impl fmt::Debug for IterMut<'_, K, V> where K: fmt::Debug, V: fmt::Debug, { @@ -2539,14 +2539,14 @@ impl<'a, K, V> Iterator for Keys<'a, K, V> { } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, K, V> ExactSizeIterator for Keys<'a, K, V> { +impl ExactSizeIterator for Keys<'_, K, V> { #[inline] fn len(&self) -> usize { self.inner.len() } } #[stable(feature = "fused", since = "1.26.0")] -impl<'a, K, V> FusedIterator for Keys<'a, K, V> {} +impl FusedIterator for Keys<'_, K, V> {} #[stable(feature = "rust1", since = "1.0.0")] impl<'a, K, V> Iterator for Values<'a, K, V> { @@ -2562,14 +2562,14 @@ impl<'a, K, V> Iterator for Values<'a, K, V> { } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, K, V> ExactSizeIterator for Values<'a, K, V> { +impl ExactSizeIterator for Values<'_, K, V> { #[inline] fn len(&self) -> usize { self.inner.len() } } #[stable(feature = "fused", since = "1.26.0")] -impl<'a, K, V> FusedIterator for Values<'a, K, V> {} +impl FusedIterator for Values<'_, K, V> {} #[stable(feature = "map_values_mut", since = "1.10.0")] impl<'a, K, V> Iterator for ValuesMut<'a, K, V> { @@ -2585,17 +2585,17 @@ impl<'a, K, V> Iterator for ValuesMut<'a, K, V> { } } #[stable(feature = "map_values_mut", since = "1.10.0")] -impl<'a, K, V> ExactSizeIterator for ValuesMut<'a, K, V> { +impl ExactSizeIterator for ValuesMut<'_, K, V> { #[inline] fn len(&self) -> usize { self.inner.len() } } #[stable(feature = "fused", since = "1.26.0")] -impl<'a, K, V> FusedIterator for ValuesMut<'a, K, V> {} +impl FusedIterator for ValuesMut<'_, K, V> {} #[stable(feature = "std_debug", since = "1.16.0")] -impl<'a, K, V> fmt::Debug for ValuesMut<'a, K, V> +impl fmt::Debug for ValuesMut<'_, K, V> where K: fmt::Debug, V: fmt::Debug, { @@ -2620,17 +2620,17 @@ impl<'a, K, V> Iterator for Drain<'a, K, V> { } } #[stable(feature = "drain", since = "1.6.0")] -impl<'a, K, V> ExactSizeIterator for Drain<'a, K, V> { +impl ExactSizeIterator for Drain<'_, K, V> { #[inline] fn len(&self) -> usize { self.inner.len() } } #[stable(feature = "fused", since = "1.26.0")] -impl<'a, K, V> FusedIterator for Drain<'a, K, V> {} +impl FusedIterator for Drain<'_, K, V> {} #[stable(feature = "std_debug", since = "1.16.0")] -impl<'a, K, V> fmt::Debug for Drain<'a, K, V> +impl fmt::Debug for Drain<'_, K, V> where K: fmt::Debug, V: fmt::Debug, { diff --git a/src/libstd/collections/hash/set.rs b/src/libstd/collections/hash/set.rs index c55dd049ec6..808f5f4a4f8 100644 --- a/src/libstd/collections/hash/set.rs +++ b/src/libstd/collections/hash/set.rs @@ -1112,8 +1112,8 @@ impl IntoIterator for HashSet } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, K> Clone for Iter<'a, K> { - fn clone(&self) -> Iter<'a, K> { +impl Clone for Iter<'_, K> { + fn clone(&self) -> Self { Iter { iter: self.iter.clone() } } } @@ -1129,16 +1129,16 @@ impl<'a, K> Iterator for Iter<'a, K> { } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, K> ExactSizeIterator for Iter<'a, K> { +impl ExactSizeIterator for Iter<'_, K> { fn len(&self) -> usize { self.iter.len() } } #[stable(feature = "fused", since = "1.26.0")] -impl<'a, K> FusedIterator for Iter<'a, K> {} +impl FusedIterator for Iter<'_, K> {} #[stable(feature = "std_debug", since = "1.16.0")] -impl<'a, K: fmt::Debug> fmt::Debug for Iter<'a, K> { +impl fmt::Debug for Iter<'_, K> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_list().entries(self.clone()).finish() } @@ -1187,16 +1187,16 @@ impl<'a, K> Iterator for Drain<'a, K> { } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, K> ExactSizeIterator for Drain<'a, K> { +impl ExactSizeIterator for Drain<'_, K> { fn len(&self) -> usize { self.iter.len() } } #[stable(feature = "fused", since = "1.26.0")] -impl<'a, K> FusedIterator for Drain<'a, K> {} +impl FusedIterator for Drain<'_, K> {} #[stable(feature = "std_debug", since = "1.16.0")] -impl<'a, K: fmt::Debug> fmt::Debug for Drain<'a, K> { +impl fmt::Debug for Drain<'_, K> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let entries_iter = self.iter .inner @@ -1207,8 +1207,8 @@ impl<'a, K: fmt::Debug> fmt::Debug for Drain<'a, K> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T, S> Clone for Intersection<'a, T, S> { - fn clone(&self) -> Intersection<'a, T, S> { +impl Clone for Intersection<'_, T, S> { + fn clone(&self) -> Self { Intersection { iter: self.iter.clone(), ..*self } } } @@ -1236,7 +1236,7 @@ impl<'a, T, S> Iterator for Intersection<'a, T, S> } #[stable(feature = "std_debug", since = "1.16.0")] -impl<'a, T, S> fmt::Debug for Intersection<'a, T, S> +impl fmt::Debug for Intersection<'_, T, S> where T: fmt::Debug + Eq + Hash, S: BuildHasher { @@ -1246,15 +1246,15 @@ impl<'a, T, S> fmt::Debug for Intersection<'a, T, S> } #[stable(feature = "fused", since = "1.26.0")] -impl<'a, T, S> FusedIterator for Intersection<'a, T, S> +impl FusedIterator for Intersection<'_, T, S> where T: Eq + Hash, S: BuildHasher { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T, S> Clone for Difference<'a, T, S> { - fn clone(&self) -> Difference<'a, T, S> { +impl Clone for Difference<'_, T, S> { + fn clone(&self) -> Self { Difference { iter: self.iter.clone(), ..*self } } } @@ -1282,14 +1282,14 @@ impl<'a, T, S> Iterator for Difference<'a, T, S> } #[stable(feature = "fused", since = "1.26.0")] -impl<'a, T, S> FusedIterator for Difference<'a, T, S> +impl FusedIterator for Difference<'_, T, S> where T: Eq + Hash, S: BuildHasher { } #[stable(feature = "std_debug", since = "1.16.0")] -impl<'a, T, S> fmt::Debug for Difference<'a, T, S> +impl fmt::Debug for Difference<'_, T, S> where T: fmt::Debug + Eq + Hash, S: BuildHasher { @@ -1299,8 +1299,8 @@ impl<'a, T, S> fmt::Debug for Difference<'a, T, S> } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T, S> Clone for SymmetricDifference<'a, T, S> { - fn clone(&self) -> SymmetricDifference<'a, T, S> { +impl Clone for SymmetricDifference<'_, T, S> { + fn clone(&self) -> Self { SymmetricDifference { iter: self.iter.clone() } } } @@ -1321,14 +1321,14 @@ impl<'a, T, S> Iterator for SymmetricDifference<'a, T, S> } #[stable(feature = "fused", since = "1.26.0")] -impl<'a, T, S> FusedIterator for SymmetricDifference<'a, T, S> +impl FusedIterator for SymmetricDifference<'_, T, S> where T: Eq + Hash, S: BuildHasher { } #[stable(feature = "std_debug", since = "1.16.0")] -impl<'a, T, S> fmt::Debug for SymmetricDifference<'a, T, S> +impl fmt::Debug for SymmetricDifference<'_, T, S> where T: fmt::Debug + Eq + Hash, S: BuildHasher { @@ -1338,21 +1338,21 @@ impl<'a, T, S> fmt::Debug for SymmetricDifference<'a, T, S> } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T, S> Clone for Union<'a, T, S> { - fn clone(&self) -> Union<'a, T, S> { +impl Clone for Union<'_, T, S> { + fn clone(&self) -> Self { Union { iter: self.iter.clone() } } } #[stable(feature = "fused", since = "1.26.0")] -impl<'a, T, S> FusedIterator for Union<'a, T, S> +impl FusedIterator for Union<'_, T, S> where T: Eq + Hash, S: BuildHasher { } #[stable(feature = "std_debug", since = "1.16.0")] -impl<'a, T, S> fmt::Debug for Union<'a, T, S> +impl fmt::Debug for Union<'_, T, S> where T: fmt::Debug + Eq + Hash, S: BuildHasher { diff --git a/src/libstd/collections/hash/table.rs b/src/libstd/collections/hash/table.rs index 28beb80612c..d5b75b22499 100644 --- a/src/libstd/collections/hash/table.rs +++ b/src/libstd/collections/hash/table.rs @@ -296,7 +296,7 @@ pub trait Put { } -impl<'t, K, V> Put for &'t mut RawTable { +impl Put for &mut RawTable { unsafe fn borrow_table_mut(&mut self) -> &mut RawTable { *self } @@ -865,8 +865,8 @@ struct RawBuckets<'a, K, V> { } // FIXME(#26925) Remove in favor of `#[derive(Clone)]` -impl<'a, K, V> Clone for RawBuckets<'a, K, V> { - fn clone(&self) -> RawBuckets<'a, K, V> { +impl Clone for RawBuckets<'_, K, V> { + fn clone(&self) -> Self { RawBuckets { raw: self.raw, elems_left: self.elems_left, @@ -901,7 +901,7 @@ impl<'a, K, V> Iterator for RawBuckets<'a, K, V> { } } -impl<'a, K, V> ExactSizeIterator for RawBuckets<'a, K, V> { +impl ExactSizeIterator for RawBuckets<'_, K, V> { fn len(&self) -> usize { self.elems_left } @@ -912,12 +912,12 @@ pub struct Iter<'a, K: 'a, V: 'a> { iter: RawBuckets<'a, K, V>, } -unsafe impl<'a, K: Sync, V: Sync> Sync for Iter<'a, K, V> {} -unsafe impl<'a, K: Sync, V: Sync> Send for Iter<'a, K, V> {} +unsafe impl Sync for Iter<'_, K, V> {} +unsafe impl Send for Iter<'_, K, V> {} // FIXME(#26925) Remove in favor of `#[derive(Clone)]` -impl<'a, K, V> Clone for Iter<'a, K, V> { - fn clone(&self) -> Iter<'a, K, V> { +impl Clone for Iter<'_, K, V> { + fn clone(&self) -> Self { Iter { iter: self.iter.clone(), } @@ -931,10 +931,10 @@ pub struct IterMut<'a, K: 'a, V: 'a> { _marker: marker::PhantomData<&'a mut V>, } -unsafe impl<'a, K: Sync, V: Sync> Sync for IterMut<'a, K, V> {} +unsafe impl Sync for IterMut<'_, K, V> {} // Both K: Sync and K: Send are correct for IterMut's Send impl, // but Send is the more useful bound -unsafe impl<'a, K: Send, V: Send> Send for IterMut<'a, K, V> {} +unsafe impl Send for IterMut<'_, K, V> {} impl<'a, K: 'a, V: 'a> IterMut<'a, K, V> { pub fn iter(&self) -> Iter { @@ -968,8 +968,8 @@ pub struct Drain<'a, K: 'a, V: 'a> { marker: marker::PhantomData<&'a RawTable>, } -unsafe impl<'a, K: Sync, V: Sync> Sync for Drain<'a, K, V> {} -unsafe impl<'a, K: Send, V: Send> Send for Drain<'a, K, V> {} +unsafe impl Sync for Drain<'_, K, V> {} +unsafe impl Send for Drain<'_, K, V> {} impl<'a, K, V> Drain<'a, K, V> { pub fn iter(&self) -> Iter { @@ -994,7 +994,7 @@ impl<'a, K, V> Iterator for Iter<'a, K, V> { } } -impl<'a, K, V> ExactSizeIterator for Iter<'a, K, V> { +impl ExactSizeIterator for Iter<'_, K, V> { fn len(&self) -> usize { self.iter.len() } @@ -1015,7 +1015,7 @@ impl<'a, K, V> Iterator for IterMut<'a, K, V> { } } -impl<'a, K, V> ExactSizeIterator for IterMut<'a, K, V> { +impl ExactSizeIterator for IterMut<'_, K, V> { fn len(&self) -> usize { self.iter.len() } @@ -1064,13 +1064,13 @@ impl<'a, K, V> Iterator for Drain<'a, K, V> { } } -impl<'a, K, V> ExactSizeIterator for Drain<'a, K, V> { +impl ExactSizeIterator for Drain<'_, K, V> { fn len(&self) -> usize { self.iter.len() } } -impl<'a, K: 'a, V: 'a> Drop for Drain<'a, K, V> { +impl Drop for Drain<'_, K, V> { fn drop(&mut self) { self.for_each(drop); } diff --git a/src/libstd/env.rs b/src/libstd/env.rs index 1f3b264c414..543973ab991 100644 --- a/src/libstd/env.rs +++ b/src/libstd/env.rs @@ -399,7 +399,7 @@ impl<'a> Iterator for SplitPaths<'a> { } #[stable(feature = "std_debug", since = "1.16.0")] -impl<'a> fmt::Debug for SplitPaths<'a> { +impl fmt::Debug for SplitPaths<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.pad("SplitPaths { .. }") } diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index 765452e0288..7e82f33ad8a 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -659,8 +659,8 @@ impl fmt::Debug for CStr { } #[stable(feature = "cstr_default", since = "1.10.0")] -impl<'a> Default for &'a CStr { - fn default() -> &'a CStr { +impl Default for &CStr { + fn default() -> Self { const SLICE: &[c_char] = &[0]; unsafe { CStr::from_ptr(SLICE.as_ptr()) } } diff --git a/src/libstd/ffi/os_str.rs b/src/libstd/ffi/os_str.rs index f8176892513..5429079f5b8 100644 --- a/src/libstd/ffi/os_str.rs +++ b/src/libstd/ffi/os_str.rs @@ -778,10 +778,10 @@ impl Default for Box { } #[stable(feature = "osstring_default", since = "1.9.0")] -impl<'a> Default for &'a OsStr { +impl Default for &OsStr { /// Creates an empty `OsStr`. #[inline] - fn default() -> &'a OsStr { + fn default() -> Self { OsStr::new("") } } diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 3538816c112..5d6a31fdd49 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -618,7 +618,7 @@ impl Seek for File { } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> Read for &'a File { +impl Read for &File { fn read(&mut self, buf: &mut [u8]) -> io::Result { self.inner.read(buf) } @@ -629,14 +629,14 @@ impl<'a> Read for &'a File { } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> Write for &'a File { +impl Write for &File { fn write(&mut self, buf: &[u8]) -> io::Result { self.inner.write(buf) } fn flush(&mut self) -> io::Result<()> { self.inner.flush() } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> Seek for &'a File { +impl Seek for &File { fn seek(&mut self, pos: SeekFrom) -> io::Result { self.inner.seek(pos) } diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index 056aa7c0c42..4380ab6de70 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -1174,7 +1174,7 @@ mod tests { // Issue #32085 struct FailFlushWriter<'a>(&'a mut Vec); - impl<'a> Write for FailFlushWriter<'a> { + impl Write for FailFlushWriter<'_> { fn write(&mut self, buf: &[u8]) -> io::Result { self.0.extend_from_slice(buf); Ok(buf.len()) diff --git a/src/libstd/io/cursor.rs b/src/libstd/io/cursor.rs index b205f788838..758d8568672 100644 --- a/src/libstd/io/cursor.rs +++ b/src/libstd/io/cursor.rs @@ -279,7 +279,7 @@ fn vec_write(pos_mut: &mut u64, vec: &mut Vec, buf: &[u8]) -> io::Result Write for Cursor<&'a mut [u8]> { +impl Write for Cursor<&mut [u8]> { #[inline] fn write(&mut self, buf: &[u8]) -> io::Result { slice_write(&mut self.pos, self.inner, buf) @@ -288,7 +288,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> { } #[stable(feature = "cursor_mut_vec", since = "1.25.0")] -impl<'a> Write for Cursor<&'a mut Vec> { +impl Write for Cursor<&mut Vec> { fn write(&mut self, buf: &[u8]) -> io::Result { vec_write(&mut self.pos, self.inner, buf) } diff --git a/src/libstd/io/impls.rs b/src/libstd/io/impls.rs index ec75a87aec3..2577b284714 100644 --- a/src/libstd/io/impls.rs +++ b/src/libstd/io/impls.rs @@ -7,7 +7,7 @@ use mem; // Forwarding implementations #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, R: Read + ?Sized> Read for &'a mut R { +impl Read for &mut R { #[inline] fn read(&mut self, buf: &mut [u8]) -> io::Result { (**self).read(buf) @@ -34,7 +34,7 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, W: Write + ?Sized> Write for &'a mut W { +impl Write for &mut W { #[inline] fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } @@ -52,12 +52,12 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W { } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, S: Seek + ?Sized> Seek for &'a mut S { +impl Seek for &mut S { #[inline] fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { +impl BufRead for &mut B { #[inline] fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } @@ -152,7 +152,7 @@ impl BufRead for Box { /// Note that reading updates the slice to point to the yet unread part. /// The slice will be empty when EOF is reached. #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> Read for &'a [u8] { +impl Read for &[u8] { #[inline] fn read(&mut self, buf: &mut [u8]) -> io::Result { let amt = cmp::min(buf.len(), self.len()); @@ -207,7 +207,7 @@ impl<'a> Read for &'a [u8] { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> BufRead for &'a [u8] { +impl BufRead for &[u8] { #[inline] fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) } @@ -221,7 +221,7 @@ impl<'a> BufRead for &'a [u8] { /// Note that writing updates the slice to point to the yet unwritten part. /// The slice will be empty when it has been completely overwritten. #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> Write for &'a mut [u8] { +impl Write for &mut [u8] { #[inline] fn write(&mut self, data: &[u8]) -> io::Result { let amt = cmp::min(data.len(), self.len()); diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 28a6fbd48cf..599a40737d6 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -299,7 +299,7 @@ const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; struct Guard<'a> { buf: &'a mut Vec, len: usize } -impl<'a> Drop for Guard<'a> { +impl Drop for Guard<'_> { fn drop(&mut self) { unsafe { self.buf.set_len(self.len); } } @@ -1114,7 +1114,7 @@ pub trait Write { error: Result<()>, } - impl<'a, T: Write + ?Sized> fmt::Write for Adaptor<'a, T> { + impl fmt::Write for Adaptor<'_, T> { fn write_str(&mut self, s: &str) -> fmt::Result { match self.inner.write_all(s.as_bytes()) { Ok(()) => Ok(()), diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs index 4068c0f9c7d..0324568e6fb 100644 --- a/src/libstd/io/stdio.rs +++ b/src/libstd/io/stdio.rs @@ -312,7 +312,7 @@ impl Read for Stdin { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> Read for StdinLock<'a> { +impl Read for StdinLock<'_> { fn read(&mut self, buf: &mut [u8]) -> io::Result { self.inner.read(buf) } @@ -323,13 +323,13 @@ impl<'a> Read for StdinLock<'a> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> BufRead for StdinLock<'a> { +impl BufRead for StdinLock<'_> { fn fill_buf(&mut self) -> io::Result<&[u8]> { self.inner.fill_buf() } fn consume(&mut self, n: usize) { self.inner.consume(n) } } #[stable(feature = "std_debug", since = "1.16.0")] -impl<'a> fmt::Debug for StdinLock<'a> { +impl fmt::Debug for StdinLock<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.pad("StdinLock { .. }") } @@ -485,7 +485,7 @@ impl Write for Stdout { } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> Write for StdoutLock<'a> { +impl Write for StdoutLock<'_> { fn write(&mut self, buf: &[u8]) -> io::Result { self.inner.borrow_mut().write(buf) } @@ -495,7 +495,7 @@ impl<'a> Write for StdoutLock<'a> { } #[stable(feature = "std_debug", since = "1.16.0")] -impl<'a> fmt::Debug for StdoutLock<'a> { +impl fmt::Debug for StdoutLock<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.pad("StdoutLock { .. }") } @@ -638,7 +638,7 @@ impl Write for Stderr { } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> Write for StderrLock<'a> { +impl Write for StderrLock<'_> { fn write(&mut self, buf: &[u8]) -> io::Result { self.inner.borrow_mut().write(buf) } @@ -648,7 +648,7 @@ impl<'a> Write for StderrLock<'a> { } #[stable(feature = "std_debug", since = "1.16.0")] -impl<'a> fmt::Debug for StderrLock<'a> { +impl fmt::Debug for StderrLock<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.pad("StderrLock { .. }") } diff --git a/src/libstd/net/addr.rs b/src/libstd/net/addr.rs index 8ace1127658..f9f89468a49 100644 --- a/src/libstd/net/addr.rs +++ b/src/libstd/net/addr.rs @@ -861,7 +861,7 @@ fn resolve_socket_addr(lh: LookupHost) -> io::Result> } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> ToSocketAddrs for (&'a str, u16) { +impl ToSocketAddrs for (&str, u16) { type Iter = vec::IntoIter; fn to_socket_addrs(&self) -> io::Result> { let (host, port) = *self; @@ -904,7 +904,7 @@ impl<'a> ToSocketAddrs for &'a [SocketAddr] { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T: ToSocketAddrs + ?Sized> ToSocketAddrs for &'a T { +impl ToSocketAddrs for &T { type Iter = T::Iter; fn to_socket_addrs(&self) -> io::Result { (**self).to_socket_addrs() diff --git a/src/libstd/net/tcp.rs b/src/libstd/net/tcp.rs index 86ecb10edf2..f0e6936e9da 100644 --- a/src/libstd/net/tcp.rs +++ b/src/libstd/net/tcp.rs @@ -580,7 +580,7 @@ impl Write for TcpStream { fn flush(&mut self) -> io::Result<()> { Ok(()) } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> Read for &'a TcpStream { +impl Read for &TcpStream { fn read(&mut self, buf: &mut [u8]) -> io::Result { self.0.read(buf) } #[inline] @@ -589,7 +589,7 @@ impl<'a> Read for &'a TcpStream { } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> Write for &'a TcpStream { +impl Write for &TcpStream { fn write(&mut self, buf: &[u8]) -> io::Result { self.0.write(buf) } fn flush(&mut self) -> io::Result<()> { Ok(()) } } diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs index d27f6ca88c2..8a15edcdef6 100644 --- a/src/libstd/panic.rs +++ b/src/libstd/panic.rs @@ -199,9 +199,9 @@ pub struct AssertUnwindSafe( // * Our custom AssertUnwindSafe wrapper is indeed unwind safe #[stable(feature = "catch_unwind", since = "1.9.0")] -impl<'a, T: ?Sized> !UnwindSafe for &'a mut T {} +impl !UnwindSafe for &mut T {} #[stable(feature = "catch_unwind", since = "1.9.0")] -impl<'a, T: RefUnwindSafe + ?Sized> UnwindSafe for &'a T {} +impl UnwindSafe for &T {} #[stable(feature = "catch_unwind", since = "1.9.0")] impl UnwindSafe for *const T {} #[stable(feature = "catch_unwind", since = "1.9.0")] @@ -320,7 +320,7 @@ impl fmt::Debug for AssertUnwindSafe { } #[unstable(feature = "futures_api", issue = "50547")] -impl<'a, F: Future> Future for AssertUnwindSafe { +impl Future for AssertUnwindSafe { type Output = F::Output; fn poll(self: Pin<&mut Self>, lw: &LocalWaker) -> Poll { diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 5c7bff70a0d..95036ff112a 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -457,14 +457,14 @@ impl<'a> cmp::PartialOrd for PrefixComponent<'a> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> cmp::Ord for PrefixComponent<'a> { - fn cmp(&self, other: &PrefixComponent<'a>) -> cmp::Ordering { +impl cmp::Ord for PrefixComponent<'_> { + fn cmp(&self, other: &Self) -> cmp::Ordering { cmp::Ord::cmp(&self.parsed, &other.parsed) } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> Hash for PrefixComponent<'a> { +impl Hash for PrefixComponent<'_> { fn hash(&self, h: &mut H) { self.parsed.hash(h); } @@ -561,14 +561,14 @@ impl<'a> Component<'a> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> AsRef for Component<'a> { +impl AsRef for Component<'_> { fn as_ref(&self) -> &OsStr { self.as_os_str() } } #[stable(feature = "path_component_asref", since = "1.25.0")] -impl<'a> AsRef for Component<'a> { +impl AsRef for Component<'_> { fn as_ref(&self) -> &Path { self.as_os_str().as_ref() } @@ -630,11 +630,11 @@ pub struct Iter<'a> { } #[stable(feature = "path_components_debug", since = "1.13.0")] -impl<'a> fmt::Debug for Components<'a> { +impl fmt::Debug for Components<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { struct DebugHelper<'a>(&'a Path); - impl<'a> fmt::Debug for DebugHelper<'a> { + impl fmt::Debug for DebugHelper<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_list() .entries(self.0.components()) @@ -814,25 +814,25 @@ impl<'a> Components<'a> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> AsRef for Components<'a> { +impl AsRef for Components<'_> { fn as_ref(&self) -> &Path { self.as_path() } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> AsRef for Components<'a> { +impl AsRef for Components<'_> { fn as_ref(&self) -> &OsStr { self.as_path().as_os_str() } } #[stable(feature = "path_iter_debug", since = "1.13.0")] -impl<'a> fmt::Debug for Iter<'a> { +impl fmt::Debug for Iter<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { struct DebugHelper<'a>(&'a Path); - impl<'a> fmt::Debug for DebugHelper<'a> { + impl fmt::Debug for DebugHelper<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_list() .entries(self.0.iter()) @@ -867,14 +867,14 @@ impl<'a> Iter<'a> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> AsRef for Iter<'a> { +impl AsRef for Iter<'_> { fn as_ref(&self) -> &Path { self.as_path() } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> AsRef for Iter<'a> { +impl AsRef for Iter<'_> { fn as_ref(&self) -> &OsStr { self.as_path().as_os_str() } @@ -897,7 +897,7 @@ impl<'a> DoubleEndedIterator for Iter<'a> { } #[stable(feature = "fused", since = "1.26.0")] -impl<'a> FusedIterator for Iter<'a> {} +impl FusedIterator for Iter<'_> {} #[stable(feature = "rust1", since = "1.0.0")] impl<'a> Iterator for Components<'a> { @@ -1000,7 +1000,7 @@ impl<'a> DoubleEndedIterator for Components<'a> { } #[stable(feature = "fused", since = "1.26.0")] -impl<'a> FusedIterator for Components<'a> {} +impl FusedIterator for Components<'_> {} #[stable(feature = "rust1", since = "1.0.0")] impl<'a> cmp::PartialEq for Components<'a> { @@ -1010,7 +1010,7 @@ impl<'a> cmp::PartialEq for Components<'a> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> cmp::Eq for Components<'a> {} +impl cmp::Eq for Components<'_> {} #[stable(feature = "rust1", since = "1.0.0")] impl<'a> cmp::PartialOrd for Components<'a> { @@ -1020,8 +1020,8 @@ impl<'a> cmp::PartialOrd for Components<'a> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> cmp::Ord for Components<'a> { - fn cmp(&self, other: &Components<'a>) -> cmp::Ordering { +impl cmp::Ord for Components<'_> { + fn cmp(&self, other: &Self) -> cmp::Ordering { Iterator::cmp(self.clone(), other.clone()) } } @@ -1063,7 +1063,7 @@ impl<'a> Iterator for Ancestors<'a> { } #[stable(feature = "path_ancestors", since = "1.28.0")] -impl<'a> FusedIterator for Ancestors<'a> {} +impl FusedIterator for Ancestors<'_> {} //////////////////////////////////////////////////////////////////////////////// // Basic types and traits @@ -2530,14 +2530,14 @@ pub struct Display<'a> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> fmt::Debug for Display<'a> { +impl fmt::Debug for Display<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Debug::fmt(&self.path, f) } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> fmt::Display for Display<'a> { +impl fmt::Display for Display<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.path.inner.display(f) } @@ -2591,7 +2591,7 @@ impl AsRef for OsStr { } #[stable(feature = "cow_os_str_as_ref_path", since = "1.8.0")] -impl<'a> AsRef for Cow<'a, OsStr> { +impl AsRef for Cow<'_, OsStr> { fn as_ref(&self) -> &Path { Path::new(self) } diff --git a/src/libstd/sync/mpsc/select.rs b/src/libstd/sync/mpsc/select.rs index 8f41680a818..4c629fa2e4c 100644 --- a/src/libstd/sync/mpsc/select.rs +++ b/src/libstd/sync/mpsc/select.rs @@ -321,7 +321,7 @@ impl Drop for Select { } } -impl<'rx, T: Send> Drop for Handle<'rx, T> { +impl Drop for Handle<'_, T> { fn drop(&mut self) { unsafe { self.remove() } } @@ -347,7 +347,7 @@ impl fmt::Debug for Select { } } -impl<'rx, T:Send+'rx> fmt::Debug for Handle<'rx, T> { +impl fmt::Debug for Handle<'_, T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("Handle").finish() } diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs index 59829db23cb..76e63c22859 100644 --- a/src/libstd/sync/mutex.rs +++ b/src/libstd/sync/mutex.rs @@ -150,9 +150,9 @@ pub struct MutexGuard<'a, T: ?Sized + 'a> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T: ?Sized> !Send for MutexGuard<'a, T> { } +impl !Send for MutexGuard<'_, T> { } #[stable(feature = "mutexguard", since = "1.19.0")] -unsafe impl<'a, T: ?Sized + Sync> Sync for MutexGuard<'a, T> { } +unsafe impl Sync for MutexGuard<'_, T> { } impl Mutex { /// Creates a new mutex in an unlocked state ready for use. @@ -421,7 +421,7 @@ impl<'mutex, T: ?Sized> MutexGuard<'mutex, T> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'mutex, T: ?Sized> Deref for MutexGuard<'mutex, T> { +impl Deref for MutexGuard<'_, T> { type Target = T; fn deref(&self) -> &T { @@ -430,14 +430,14 @@ impl<'mutex, T: ?Sized> Deref for MutexGuard<'mutex, T> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'mutex, T: ?Sized> DerefMut for MutexGuard<'mutex, T> { +impl DerefMut for MutexGuard<'_, T> { fn deref_mut(&mut self) -> &mut T { unsafe { &mut *self.__lock.data.get() } } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T: ?Sized> Drop for MutexGuard<'a, T> { +impl Drop for MutexGuard<'_, T> { #[inline] fn drop(&mut self) { unsafe { @@ -448,14 +448,14 @@ impl<'a, T: ?Sized> Drop for MutexGuard<'a, T> { } #[stable(feature = "std_debug", since = "1.16.0")] -impl<'a, T: ?Sized + fmt::Debug> fmt::Debug for MutexGuard<'a, T> { +impl fmt::Debug for MutexGuard<'_, T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Debug::fmt(&**self, f) } } #[stable(feature = "std_guard_impls", since = "1.20.0")] -impl<'a, T: ?Sized + fmt::Display> fmt::Display for MutexGuard<'a, T> { +impl fmt::Display for MutexGuard<'_, T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { (**self).fmt(f) } diff --git a/src/libstd/sync/once.rs b/src/libstd/sync/once.rs index fcab2ffe144..9d0b6774863 100644 --- a/src/libstd/sync/once.rs +++ b/src/libstd/sync/once.rs @@ -436,7 +436,7 @@ impl fmt::Debug for Once { } } -impl<'a> Drop for Finish<'a> { +impl Drop for Finish<'_> { fn drop(&mut self) { // Swap out our state with however we finished. We should only ever see // an old state which was RUNNING. diff --git a/src/libstd/sync/rwlock.rs b/src/libstd/sync/rwlock.rs index 7fbe0b8c199..ec49492cec3 100644 --- a/src/libstd/sync/rwlock.rs +++ b/src/libstd/sync/rwlock.rs @@ -91,10 +91,10 @@ pub struct RwLockReadGuard<'a, T: ?Sized + 'a> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T: ?Sized> !Send for RwLockReadGuard<'a, T> {} +impl !Send for RwLockReadGuard<'_, T> {} #[stable(feature = "rwlock_guard_sync", since = "1.23.0")] -unsafe impl<'a, T: ?Sized + Sync> Sync for RwLockReadGuard<'a, T> {} +unsafe impl Sync for RwLockReadGuard<'_, T> {} /// RAII structure used to release the exclusive write access of a lock when /// dropped. @@ -113,10 +113,10 @@ pub struct RwLockWriteGuard<'a, T: ?Sized + 'a> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T: ?Sized> !Send for RwLockWriteGuard<'a, T> {} +impl !Send for RwLockWriteGuard<'_, T> {} #[stable(feature = "rwlock_guard_sync", since = "1.23.0")] -unsafe impl<'a, T: ?Sized + Sync> Sync for RwLockWriteGuard<'a, T> {} +unsafe impl Sync for RwLockWriteGuard<'_, T> {} impl RwLock { /// Creates a new instance of an `RwLock` which is unlocked. @@ -480,7 +480,7 @@ impl<'rwlock, T: ?Sized> RwLockWriteGuard<'rwlock, T> { } #[stable(feature = "std_debug", since = "1.16.0")] -impl<'a, T: fmt::Debug> fmt::Debug for RwLockReadGuard<'a, T> { +impl fmt::Debug for RwLockReadGuard<'_, T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("RwLockReadGuard") .field("lock", &self.__lock) @@ -489,14 +489,14 @@ impl<'a, T: fmt::Debug> fmt::Debug for RwLockReadGuard<'a, T> { } #[stable(feature = "std_guard_impls", since = "1.20.0")] -impl<'a, T: ?Sized + fmt::Display> fmt::Display for RwLockReadGuard<'a, T> { +impl fmt::Display for RwLockReadGuard<'_, T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { (**self).fmt(f) } } #[stable(feature = "std_debug", since = "1.16.0")] -impl<'a, T: fmt::Debug> fmt::Debug for RwLockWriteGuard<'a, T> { +impl fmt::Debug for RwLockWriteGuard<'_, T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("RwLockWriteGuard") .field("lock", &self.__lock) @@ -505,14 +505,14 @@ impl<'a, T: fmt::Debug> fmt::Debug for RwLockWriteGuard<'a, T> { } #[stable(feature = "std_guard_impls", since = "1.20.0")] -impl<'a, T: ?Sized + fmt::Display> fmt::Display for RwLockWriteGuard<'a, T> { +impl fmt::Display for RwLockWriteGuard<'_, T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { (**self).fmt(f) } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'rwlock, T: ?Sized> Deref for RwLockReadGuard<'rwlock, T> { +impl Deref for RwLockReadGuard<'_, T> { type Target = T; fn deref(&self) -> &T { @@ -521,7 +521,7 @@ impl<'rwlock, T: ?Sized> Deref for RwLockReadGuard<'rwlock, T> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'rwlock, T: ?Sized> Deref for RwLockWriteGuard<'rwlock, T> { +impl Deref for RwLockWriteGuard<'_, T> { type Target = T; fn deref(&self) -> &T { @@ -530,21 +530,21 @@ impl<'rwlock, T: ?Sized> Deref for RwLockWriteGuard<'rwlock, T> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'rwlock, T: ?Sized> DerefMut for RwLockWriteGuard<'rwlock, T> { +impl DerefMut for RwLockWriteGuard<'_, T> { fn deref_mut(&mut self) -> &mut T { unsafe { &mut *self.__lock.data.get() } } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T: ?Sized> Drop for RwLockReadGuard<'a, T> { +impl Drop for RwLockReadGuard<'_, T> { fn drop(&mut self) { unsafe { self.__lock.inner.read_unlock(); } } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T: ?Sized> Drop for RwLockWriteGuard<'a, T> { +impl Drop for RwLockWriteGuard<'_, T> { fn drop(&mut self) { self.__lock.poison.done(&self.__poison); unsafe { self.__lock.inner.write_unlock(); } diff --git a/src/libstd/sys_common/bytestring.rs b/src/libstd/sys_common/bytestring.rs index df57fae4281..915c17374ca 100644 --- a/src/libstd/sys_common/bytestring.rs +++ b/src/libstd/sys_common/bytestring.rs @@ -31,7 +31,7 @@ mod tests { fn smoke() { struct Helper<'a>(&'a [u8]); - impl<'a> Debug for Helper<'a> { + impl Debug for Helper<'_> { fn fmt(&self, f: &mut Formatter) -> Result { debug_fmt_bytestring(self.0, f) } diff --git a/src/libstd/sys_common/mutex.rs b/src/libstd/sys_common/mutex.rs index 536f1c70db2..b47d8698c60 100644 --- a/src/libstd/sys_common/mutex.rs +++ b/src/libstd/sys_common/mutex.rs @@ -76,7 +76,7 @@ pub fn raw(mutex: &Mutex) -> &imp::Mutex { &mutex.0 } /// A simple RAII utility for the above Mutex without the poisoning semantics. pub struct MutexGuard<'a>(&'a imp::Mutex); -impl<'a> Drop for MutexGuard<'a> { +impl Drop for MutexGuard<'_> { #[inline] fn drop(&mut self) { unsafe { self.0.unlock(); } diff --git a/src/libstd/sys_common/remutex.rs b/src/libstd/sys_common/remutex.rs index 9ef24433f13..596e5d534c2 100644 --- a/src/libstd/sys_common/remutex.rs +++ b/src/libstd/sys_common/remutex.rs @@ -43,7 +43,7 @@ pub struct ReentrantMutexGuard<'a, T: 'a> { __poison: poison::Guard, } -impl<'a, T> !marker::Send for ReentrantMutexGuard<'a, T> {} +impl !marker::Send for ReentrantMutexGuard<'_, T> {} impl ReentrantMutex { @@ -138,7 +138,7 @@ impl<'mutex, T> ReentrantMutexGuard<'mutex, T> { } } -impl<'mutex, T> Deref for ReentrantMutexGuard<'mutex, T> { +impl Deref for ReentrantMutexGuard<'_, T> { type Target = T; fn deref(&self) -> &T { @@ -146,7 +146,7 @@ impl<'mutex, T> Deref for ReentrantMutexGuard<'mutex, T> { } } -impl<'a, T> Drop for ReentrantMutexGuard<'a, T> { +impl Drop for ReentrantMutexGuard<'_, T> { #[inline] fn drop(&mut self) { unsafe { @@ -212,7 +212,7 @@ mod tests { } pub struct Answer<'a>(pub ReentrantMutexGuard<'a, RefCell>); - impl<'a> Drop for Answer<'a> { + impl Drop for Answer<'_> { fn drop(&mut self) { *self.0.borrow_mut() = 42; } -- cgit 1.4.1-3-g733a5 From c9fbcc1f39f2c37a6d0a40ca8c2462d934a9fc60 Mon Sep 17 00:00:00 2001 From: Aaron Stillwell Date: Mon, 18 Feb 2019 17:42:07 +0000 Subject: Fixed doc example for Path::with_capacity --- src/libstd/path.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/libstd') diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 735714aca10..dcaa65a8fa7 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -1151,9 +1151,10 @@ impl PathBuf { /// # Examples /// /// ``` + /// #![feature(path_buf_capacity)] /// use std::path::PathBuf; /// - /// let path = PathBuf::with_capacity(10); + /// let mut path = PathBuf::with_capacity(10); /// let capacity = path.capacity(); /// /// // This push is done without reallocating -- cgit 1.4.1-3-g733a5