From f65b630d33ef2e57f0966c9b7b1f179e78502a9d Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Tue, 23 Oct 2018 02:04:42 +0200 Subject: constify parts of libstd. --- src/libstd/collections/hash/map.rs | 6 +++--- src/libstd/collections/hash/table.rs | 12 ++++++------ src/libstd/ffi/c_str.rs | 10 +++++----- src/libstd/io/buffered.rs | 2 +- src/libstd/io/cursor.rs | 6 +++--- src/libstd/io/mod.rs | 10 +++++----- src/libstd/io/util.rs | 4 ++-- src/libstd/net/addr.rs | 4 ++-- src/libstd/net/ip.rs | 7 +++---- src/libstd/path.rs | 8 ++++---- src/libstd/process.rs | 6 +++--- src/libstd/sync/condvar.rs | 2 +- src/libstd/sync/mpsc/mod.rs | 6 +++--- src/libstd/sync/mpsc/oneshot.rs | 2 +- src/libstd/sync/once.rs | 2 +- src/libstd/sys_common/mutex.rs | 2 +- src/libstd/sys_common/net.rs | 6 +++--- src/libstd/sys_common/wtf8.rs | 4 ++-- src/libstd/thread/mod.rs | 4 ++-- src/libstd/time.rs | 2 +- 20 files changed, 52 insertions(+), 53 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 8de415e8aed..b95449d11ea 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -36,7 +36,7 @@ struct DefaultResizePolicy; impl DefaultResizePolicy { #[inline] - fn new() -> DefaultResizePolicy { + const fn new() -> DefaultResizePolicy { DefaultResizePolicy } @@ -69,7 +69,7 @@ impl DefaultResizePolicy { /// The capacity of the given raw capacity. #[inline] - fn capacity(&self, raw_cap: usize) -> usize { + const fn capacity(&self, raw_cap: usize) -> usize { // This doesn't have to be checked for overflow since allocation size // in bytes will overflow earlier than multiplication by 10. // @@ -3013,7 +3013,7 @@ impl<'a, K: 'a, V: 'a> VacantEntry<'a, K, V> { /// assert_eq!(map.entry("poneyland").key(), &"poneyland"); /// ``` #[stable(feature = "map_entry_keys", since = "1.10.0")] - pub fn key(&self) -> &K { + pub const fn key(&self) -> &K { &self.key } diff --git a/src/libstd/collections/hash/table.rs b/src/libstd/collections/hash/table.rs index 547f97cc8ac..0df20395b01 100644 --- a/src/libstd/collections/hash/table.rs +++ b/src/libstd/collections/hash/table.rs @@ -247,7 +247,7 @@ impl RawBucket { // Buckets hold references to the table. impl FullBucket { /// Borrow a reference to the table. - pub fn table(&self) -> &M { + pub const fn table(&self) -> &M { &self.table } /// Borrow a mutable reference to the table. @@ -259,18 +259,18 @@ impl FullBucket { self.table } /// Get the raw index. - pub fn index(&self) -> usize { + pub const fn index(&self) -> usize { self.raw.idx } /// Get the raw bucket. - pub fn raw(&self) -> RawBucket { + pub const fn raw(&self) -> RawBucket { self.raw } } impl EmptyBucket { /// Borrow a reference to the table. - pub fn table(&self) -> &M { + pub const fn table(&self) -> &M { &self.table } /// Borrow a mutable reference to the table. @@ -281,7 +281,7 @@ impl EmptyBucket { impl Bucket { /// Get the raw index. - pub fn index(&self) -> usize { + pub const fn index(&self) -> usize { self.raw.idx } /// get the table. @@ -772,7 +772,7 @@ impl RawTable { /// The number of elements ever `put` in the hashtable, minus the number /// of elements ever `take`n. - pub fn size(&self) -> usize { + pub const fn size(&self) -> usize { self.size } diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index dfec13cd2ec..feff65bff3f 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -265,12 +265,12 @@ enum FromBytesWithNulErrorKind { } impl FromBytesWithNulError { - fn interior_nul(pos: usize) -> FromBytesWithNulError { + const fn interior_nul(pos: usize) -> FromBytesWithNulError { FromBytesWithNulError { kind: FromBytesWithNulErrorKind::InteriorNul(pos), } } - fn not_nul_terminated() -> FromBytesWithNulError { + const fn not_nul_terminated() -> FromBytesWithNulError { FromBytesWithNulError { kind: FromBytesWithNulErrorKind::NotNulTerminated, } @@ -833,7 +833,7 @@ impl NulError { /// assert_eq!(nul_error.nul_position(), 7); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn nul_position(&self) -> usize { self.0 } + pub const fn nul_position(&self) -> usize { self.0 } /// Consumes this error, returning the underlying vector of bytes which /// generated the error in the first place. @@ -909,7 +909,7 @@ impl IntoStringError { /// Access the underlying UTF-8 error that was the cause of this error. #[stable(feature = "cstring_into", since = "1.7.0")] - pub fn utf8_error(&self) -> Utf8Error { + pub const fn utf8_error(&self) -> Utf8Error { self.error } } @@ -1091,7 +1091,7 @@ impl CStr { /// [`CString`]: struct.CString.html #[inline] #[stable(feature = "rust1", since = "1.0.0")] - pub fn as_ptr(&self) -> *const c_char { + pub const fn as_ptr(&self) -> *const c_char { self.inner.as_ptr() } diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index e26e6d391f8..bde9c57c57c 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -633,7 +633,7 @@ impl IntoInnerError { /// }; /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn error(&self) -> &Error { &self.1 } + pub const fn error(&self) -> &Error { &self.1 } /// Returns the buffered writer instance which generated the error. /// diff --git a/src/libstd/io/cursor.rs b/src/libstd/io/cursor.rs index 14f20151dca..05bee19c93f 100644 --- a/src/libstd/io/cursor.rs +++ b/src/libstd/io/cursor.rs @@ -104,7 +104,7 @@ impl Cursor { /// # force_inference(&buff); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn new(inner: T) -> Cursor { + pub const fn new(inner: T) -> Cursor { Cursor { pos: 0, inner: inner } } @@ -138,7 +138,7 @@ impl Cursor { /// let reference = buff.get_ref(); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn get_ref(&self) -> &T { &self.inner } + pub const fn get_ref(&self) -> &T { &self.inner } /// Gets a mutable reference to the underlying value in this cursor. /// @@ -179,7 +179,7 @@ impl Cursor { /// assert_eq!(buff.position(), 1); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn position(&self) -> u64 { self.pos } + pub const fn position(&self) -> u64 { self.pos } /// Sets the position of this cursor. /// diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index e263db24fc2..4c3117260fe 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -885,7 +885,7 @@ impl Initializer { /// Returns a new `Initializer` which will zero out buffers. #[unstable(feature = "read_initializer", issue = "42788")] #[inline] - pub fn zeroing() -> Initializer { + pub const fn zeroing() -> Initializer { Initializer(true) } @@ -906,7 +906,7 @@ impl Initializer { /// Indicates if a buffer should be initialized. #[unstable(feature = "read_initializer", issue = "42788")] #[inline] - pub fn should_initialize(&self) -> bool { + pub const fn should_initialize(&self) -> bool { self.0 } @@ -1653,7 +1653,7 @@ impl Chain { /// } /// ``` #[stable(feature = "more_io_inner_methods", since = "1.20.0")] - pub fn get_ref(&self) -> (&T, &U) { + pub const fn get_ref(&self) -> (&T, &U) { (&self.first, &self.second) } @@ -1780,7 +1780,7 @@ impl Take { /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn limit(&self) -> u64 { self.limit } + pub const fn limit(&self) -> u64 { self.limit } /// Sets the number of bytes that can be read before this instance will /// return EOF. This is the same as constructing a new `Take` instance, so @@ -1856,7 +1856,7 @@ impl Take { /// } /// ``` #[stable(feature = "more_io_inner_methods", since = "1.20.0")] - pub fn get_ref(&self) -> &T { + pub const fn get_ref(&self) -> &T { &self.inner } diff --git a/src/libstd/io/util.rs b/src/libstd/io/util.rs index 12995d08683..d0db4cfc704 100644 --- a/src/libstd/io/util.rs +++ b/src/libstd/io/util.rs @@ -99,7 +99,7 @@ pub struct Empty { _priv: () } /// assert!(buffer.is_empty()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] -pub fn empty() -> Empty { Empty { _priv: () } } +pub const fn empty() -> Empty { Empty { _priv: () } } #[stable(feature = "rust1", since = "1.0.0")] impl Read for Empty { @@ -199,7 +199,7 @@ pub struct Sink { _priv: () } /// assert_eq!(num_bytes, 5); /// ``` #[stable(feature = "rust1", since = "1.0.0")] -pub fn sink() -> Sink { Sink { _priv: () } } +pub const fn sink() -> Sink { Sink { _priv: () } } #[stable(feature = "rust1", since = "1.0.0")] impl Write for Sink { diff --git a/src/libstd/net/addr.rs b/src/libstd/net/addr.rs index ff35325ab4f..fc2e8104782 100644 --- a/src/libstd/net/addr.rs +++ b/src/libstd/net/addr.rs @@ -475,7 +475,7 @@ impl SocketAddrV6 { /// assert_eq!(socket.flowinfo(), 10); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn flowinfo(&self) -> u32 { + pub const fn flowinfo(&self) -> u32 { self.inner.sin6_flowinfo } @@ -515,7 +515,7 @@ impl SocketAddrV6 { /// assert_eq!(socket.scope_id(), 78); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn scope_id(&self) -> u32 { + pub const fn scope_id(&self) -> u32 { self.inner.sin6_scope_id } diff --git a/src/libstd/net/ip.rs b/src/libstd/net/ip.rs index d45a66ef665..c5106c9abb9 100644 --- a/src/libstd/net/ip.rs +++ b/src/libstd/net/ip.rs @@ -402,7 +402,7 @@ impl Ipv4Addr { /// assert_eq!(addr.octets(), [127, 0, 0, 1]); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn octets(&self) -> [u8; 4] { + pub fn octets(&self) -> [u8; 4] { let bits = u32::from_be(self.inner.s_addr); [(bits >> 24) as u8, (bits >> 16) as u8, (bits >> 8) as u8, bits as u8] } @@ -424,7 +424,7 @@ impl Ipv4Addr { /// assert_eq!(Ipv4Addr::new(45, 22, 13, 197).is_unspecified(), false); /// ``` #[stable(feature = "ip_shared", since = "1.12.0")] - pub fn is_unspecified(&self) -> bool { + pub const fn is_unspecified(&self) -> bool { self.inner.s_addr == 0 } @@ -862,7 +862,6 @@ impl Ipv6Addr { /// let addr = Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_unstable(feature = "const_ip")] pub const fn new(a: u16, b: u16, c: u16, d: u16, e: u16, f: u16, g: u16, h: u16) -> Ipv6Addr { Ipv6Addr { @@ -1224,7 +1223,7 @@ impl Ipv6Addr { /// [255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); /// ``` #[stable(feature = "ipv6_to_octets", since = "1.12.0")] - pub fn octets(&self) -> [u8; 16] { + pub const fn octets(&self) -> [u8; 16] { self.inner.s6_addr } } diff --git a/src/libstd/path.rs b/src/libstd/path.rs index a153456370c..71f39ff85e7 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -439,7 +439,7 @@ impl<'a> PrefixComponent<'a> { /// /// [`Prefix`]: enum.Prefix.html #[stable(feature = "rust1", since = "1.0.0")] - pub fn kind(&self) -> Prefix<'a> { + pub const fn kind(&self) -> Prefix<'a> { self.parsed } @@ -447,7 +447,7 @@ impl<'a> PrefixComponent<'a> { /// /// [`OsStr`]: ../../std/ffi/struct.OsStr.html #[stable(feature = "rust1", since = "1.0.0")] - pub fn as_os_str(&self) -> &'a OsStr { + pub const fn as_os_str(&self) -> &'a OsStr { self.raw } } @@ -1918,7 +1918,7 @@ impl Path { /// [`None`]: ../../std/option/enum.Option.html#variant.None /// [`parent`]: struct.Path.html#method.parent #[stable(feature = "path_ancestors", since = "1.28.0")] - pub fn ancestors(&self) -> Ancestors { + pub const fn ancestors(&self) -> Ancestors { Ancestors { next: Some(&self), } @@ -2267,7 +2267,7 @@ impl Path { /// println!("{}", path.display()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn display(&self) -> Display { + pub const fn display(&self) -> Display { Display { path: self } } diff --git a/src/libstd/process.rs b/src/libstd/process.rs index a9219f75362..d5047ef6ad7 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -926,7 +926,7 @@ impl Stdio { /// assert_eq!(String::from_utf8_lossy(&output.stdout), "!dlrow ,olleH\n"); /// ``` #[stable(feature = "process", since = "1.0.0")] - pub fn piped() -> Stdio { Stdio(imp::Stdio::MakePipe) } + pub const fn piped() -> Stdio { Stdio(imp::Stdio::MakePipe) } /// The child inherits from the corresponding parent descriptor. /// @@ -961,7 +961,7 @@ impl Stdio { /// println!("You piped in the reverse of: {}", String::from_utf8_lossy(&output.stdout)); /// ``` #[stable(feature = "process", since = "1.0.0")] - pub fn inherit() -> Stdio { Stdio(imp::Stdio::Inherit) } + pub const fn inherit() -> Stdio { Stdio(imp::Stdio::Inherit) } /// This stream will be ignored. This is the equivalent of attaching the /// stream to `/dev/null` @@ -998,7 +998,7 @@ impl Stdio { /// // Ignores any piped-in input /// ``` #[stable(feature = "process", since = "1.0.0")] - pub fn null() -> Stdio { Stdio(imp::Stdio::Null) } + pub const fn null() -> Stdio { Stdio(imp::Stdio::Null) } } impl FromInner for Stdio { diff --git a/src/libstd/sync/condvar.rs b/src/libstd/sync/condvar.rs index 3014283da5b..1c6cc9cb361 100644 --- a/src/libstd/sync/condvar.rs +++ b/src/libstd/sync/condvar.rs @@ -72,7 +72,7 @@ impl WaitTimeoutResult { /// } /// ``` #[stable(feature = "wait_timeout", since = "1.5.0")] - pub fn timed_out(&self) -> bool { + pub const fn timed_out(&self) -> bool { self.0 } } diff --git a/src/libstd/sync/mpsc/mod.rs b/src/libstd/sync/mpsc/mod.rs index 059ced4f56e..2a2e5c030b3 100644 --- a/src/libstd/sync/mpsc/mod.rs +++ b/src/libstd/sync/mpsc/mod.rs @@ -785,7 +785,7 @@ pub fn sync_channel(bound: usize) -> (SyncSender, Receiver) { //////////////////////////////////////////////////////////////////////////////// impl Sender { - fn new(inner: Flavor) -> Sender { + const fn new(inner: Flavor) -> Sender { Sender { inner: UnsafeCell::new(inner), } @@ -1469,7 +1469,7 @@ impl Receiver { /// assert_eq!(iter.next(), None); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn iter(&self) -> Iter { + pub const fn iter(&self) -> Iter { Iter { rx: self } } @@ -1512,7 +1512,7 @@ impl Receiver { /// assert_eq!(iter.next(), None); /// ``` #[stable(feature = "receiver_try_iter", since = "1.15.0")] - pub fn try_iter(&self) -> TryIter { + pub const fn try_iter(&self) -> TryIter { TryIter { rx: self } } diff --git a/src/libstd/sync/mpsc/oneshot.rs b/src/libstd/sync/mpsc/oneshot.rs index b8e50c9297b..273644cb902 100644 --- a/src/libstd/sync/mpsc/oneshot.rs +++ b/src/libstd/sync/mpsc/oneshot.rs @@ -89,7 +89,7 @@ enum MyUpgrade { } impl Packet { - pub fn new() -> Packet { + pub const fn new() -> Packet { Packet { data: UnsafeCell::new(None), upgrade: UnsafeCell::new(NothingSent), diff --git a/src/libstd/sync/once.rs b/src/libstd/sync/once.rs index cf9698cb2a9..4dd37ec3878 100644 --- a/src/libstd/sync/once.rs +++ b/src/libstd/sync/once.rs @@ -517,7 +517,7 @@ impl OnceState { /// assert!(!state.poisoned()); /// }); #[unstable(feature = "once_poison", issue = "33577")] - pub fn poisoned(&self) -> bool { + pub const fn poisoned(&self) -> bool { self.poisoned } } diff --git a/src/libstd/sys_common/mutex.rs b/src/libstd/sys_common/mutex.rs index c6d531c7a1a..dc9edb306de 100644 --- a/src/libstd/sys_common/mutex.rs +++ b/src/libstd/sys_common/mutex.rs @@ -80,7 +80,7 @@ impl Mutex { } // not meant to be exported to the outside world, just the containing module -pub fn raw(mutex: &Mutex) -> &imp::Mutex { &mutex.0 } +pub const fn raw(mutex: &Mutex) -> &imp::Mutex { &mutex.0 } #[must_use] /// A simple RAII utility for the above Mutex without the poisoning semantics. diff --git a/src/libstd/sys_common/net.rs b/src/libstd/sys_common/net.rs index d09a233ed89..f58c26ef428 100644 --- a/src/libstd/sys_common/net.rs +++ b/src/libstd/sys_common/net.rs @@ -199,7 +199,7 @@ impl TcpStream { Ok(TcpStream { inner: sock }) } - pub fn socket(&self) -> &Socket { &self.inner } + pub const fn socket(&self) -> &Socket { &self.inner } pub fn into_socket(self) -> Socket { self.inner } @@ -339,7 +339,7 @@ impl TcpListener { Ok(TcpListener { inner: sock }) } - pub fn socket(&self) -> &Socket { &self.inner } + pub const fn socket(&self) -> &Socket { &self.inner } pub fn into_socket(self) -> Socket { self.inner } @@ -427,7 +427,7 @@ impl UdpSocket { Ok(UdpSocket { inner: sock }) } - pub fn socket(&self) -> &Socket { &self.inner } + pub const fn socket(&self) -> &Socket { &self.inner } pub fn into_socket(self) -> Socket { self.inner } diff --git a/src/libstd/sys_common/wtf8.rs b/src/libstd/sys_common/wtf8.rs index 19ce932aa12..5f6747a1224 100644 --- a/src/libstd/sys_common/wtf8.rs +++ b/src/libstd/sys_common/wtf8.rs @@ -85,13 +85,13 @@ impl CodePoint { /// /// Since all Unicode scalar values are code points, this always succeeds. #[inline] - pub fn from_char(value: char) -> CodePoint { + pub const fn from_char(value: char) -> CodePoint { CodePoint { value: value as u32 } } /// Returns the numeric value of the code point. #[inline] - pub fn to_u32(&self) -> u32 { + pub const fn to_u32(&self) -> u32 { self.value } diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index a57b8dc7237..3a3d2450014 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -286,7 +286,7 @@ impl Builder { /// handler.join().unwrap(); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn new() -> Builder { + pub const fn new() -> Builder { Builder { name: None, stack_size: None, @@ -1391,7 +1391,7 @@ impl JoinHandle { /// println!("thread id: {:?}", thread.id()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn thread(&self) -> &Thread { + pub const fn thread(&self) -> &Thread { &self.0.thread } diff --git a/src/libstd/time.rs b/src/libstd/time.rs index 90ab3491599..a9344941f42 100644 --- a/src/libstd/time.rs +++ b/src/libstd/time.rs @@ -449,7 +449,7 @@ impl SystemTimeError { /// } /// ``` #[stable(feature = "time2", since = "1.8.0")] - pub fn duration(&self) -> Duration { + pub const fn duration(&self) -> Duration { self.0 } } -- cgit 1.4.1-3-g733a5 From d1d2aa22c0d15465af1daccdb3821450c98d0ed0 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Tue, 23 Oct 2018 18:06:11 +0200 Subject: reduce list to functions callable in const ctx. --- src/liballoc/collections/btree/map.rs | 4 ++-- src/liballoc/collections/btree/set.rs | 4 ++-- src/liballoc/collections/vec_deque.rs | 2 +- src/liballoc/string.rs | 6 +++--- src/liballoc/vec.rs | 4 ++-- src/libcore/alloc.rs | 2 +- src/libcore/char/decode.rs | 2 +- src/libcore/fmt/mod.rs | 18 +++++++++--------- src/libcore/panic.rs | 14 +++++++------- src/libcore/pin.rs | 4 ++-- src/libcore/slice/mod.rs | 4 ++-- src/libcore/str/lossy.rs | 2 +- src/libcore/str/mod.rs | 2 +- src/libcore/task/wake.rs | 2 +- src/libstd/collections/hash/map.rs | 2 +- src/libstd/ffi/c_str.rs | 4 ++-- src/libstd/io/buffered.rs | 2 +- src/libstd/io/mod.rs | 6 +++--- src/libstd/net/addr.rs | 4 ++-- src/libstd/net/ip.rs | 2 +- src/libstd/path.rs | 8 ++++---- src/libstd/sync/condvar.rs | 2 +- src/libstd/sync/mpsc/mod.rs | 4 ++-- src/libstd/sync/once.rs | 2 +- src/libstd/thread/mod.rs | 2 +- src/libstd/time.rs | 2 +- 26 files changed, 55 insertions(+), 55 deletions(-) (limited to 'src/libstd') diff --git a/src/liballoc/collections/btree/map.rs b/src/liballoc/collections/btree/map.rs index 8a721a50b46..24c8fd3a969 100644 --- a/src/liballoc/collections/btree/map.rs +++ b/src/liballoc/collections/btree/map.rs @@ -2074,7 +2074,7 @@ impl BTreeMap { /// assert_eq!(a.len(), 1); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub const fn len(&self) -> usize { + pub fn len(&self) -> usize { self.length } @@ -2093,7 +2093,7 @@ impl BTreeMap { /// assert!(!a.is_empty()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub const fn is_empty(&self) -> bool { + pub fn is_empty(&self) -> bool { self.len() == 0 } } diff --git a/src/liballoc/collections/btree/set.rs b/src/liballoc/collections/btree/set.rs index 6a0ecfd3f58..af9a7074e4a 100644 --- a/src/liballoc/collections/btree/set.rs +++ b/src/liballoc/collections/btree/set.rs @@ -730,7 +730,7 @@ impl BTreeSet { /// assert_eq!(v.len(), 1); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub const fn len(&self) -> usize { + pub fn len(&self) -> usize { self.map.len() } @@ -747,7 +747,7 @@ impl BTreeSet { /// assert!(!v.is_empty()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub const fn is_empty(&self) -> bool { + pub fn is_empty(&self) -> bool { self.len() == 0 } } diff --git a/src/liballoc/collections/vec_deque.rs b/src/liballoc/collections/vec_deque.rs index b139b440fe1..e0ae7561d45 100644 --- a/src/liballoc/collections/vec_deque.rs +++ b/src/liballoc/collections/vec_deque.rs @@ -933,7 +933,7 @@ impl VecDeque { /// assert!(!v.is_empty()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub const fn is_empty(&self) -> bool { + pub fn is_empty(&self) -> bool { self.tail == self.head } diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index 8f379c4cfb4..5c776292f53 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -1374,7 +1374,7 @@ impl String { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - pub const fn len(&self) -> usize { + pub fn len(&self) -> usize { self.vec.len() } @@ -1395,7 +1395,7 @@ impl String { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - pub const fn is_empty(&self) -> bool { + pub fn is_empty(&self) -> bool { self.len() == 0 } @@ -1662,7 +1662,7 @@ impl FromUtf8Error { /// assert_eq!(1, error.valid_up_to()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub const fn utf8_error(&self) -> Utf8Error { + pub fn utf8_error(&self) -> Utf8Error { self.error } } diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index 78e9da2084d..f7a0bbdceaf 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -1165,7 +1165,7 @@ impl Vec { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - pub const fn len(&self) -> usize { + pub fn len(&self) -> usize { self.len } @@ -1181,7 +1181,7 @@ impl Vec { /// assert!(!v.is_empty()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub const fn is_empty(&self) -> bool { + pub fn is_empty(&self) -> bool { self.len() == 0 } diff --git a/src/libcore/alloc.rs b/src/libcore/alloc.rs index 8b9f7f2c816..045fabca268 100644 --- a/src/libcore/alloc.rs +++ b/src/libcore/alloc.rs @@ -116,7 +116,7 @@ impl Layout { /// The minimum size in bytes for a memory block of this layout. #[stable(feature = "alloc_layout", since = "1.28.0")] #[inline] - pub const fn size(&self) -> usize { self.size_ } + pub fn size(&self) -> usize { self.size_ } /// The minimum byte alignment for a memory block of this layout. #[stable(feature = "alloc_layout", since = "1.28.0")] diff --git a/src/libcore/char/decode.rs b/src/libcore/char/decode.rs index bcd1e92c6d8..cc52f048b89 100644 --- a/src/libcore/char/decode.rs +++ b/src/libcore/char/decode.rs @@ -130,7 +130,7 @@ impl> Iterator for DecodeUtf16 { impl DecodeUtf16Error { /// Returns the unpaired surrogate which caused this error. #[stable(feature = "decode_utf16", since = "1.9.0")] - pub const fn unpaired_surrogate(&self) -> u16 { + pub fn unpaired_surrogate(&self) -> u16 { self.code } } diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index 56576f8334b..4fde4e79ee2 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -341,7 +341,7 @@ impl<'a> Arguments<'a> { #[doc(hidden)] #[inline] #[unstable(feature = "fmt_internals", reason = "internal to format_args!", issue = "0")] - pub const fn new_v1(pieces: &'a [&'a str], + pub fn new_v1(pieces: &'a [&'a str], args: &'a [ArgumentV1<'a>]) -> Arguments<'a> { Arguments { pieces, @@ -359,7 +359,7 @@ impl<'a> Arguments<'a> { #[doc(hidden)] #[inline] #[unstable(feature = "fmt_internals", reason = "internal to format_args!", issue = "0")] - pub const fn new_v1_formatted(pieces: &'a [&'a str], + pub fn new_v1_formatted(pieces: &'a [&'a str], args: &'a [ArgumentV1<'a>], fmt: &'a [rt::v1::Argument]) -> Arguments<'a> { Arguments { @@ -1492,7 +1492,7 @@ impl<'a> Formatter<'a> { /// assert_eq!(&format!("{:t>6}", Foo), "tttttt"); /// ``` #[stable(feature = "fmt_flags", since = "1.5.0")] - pub const fn fill(&self) -> char { self.fill } + pub fn fill(&self) -> char { self.fill } /// Flag indicating what form of alignment was requested. /// @@ -1562,7 +1562,7 @@ impl<'a> Formatter<'a> { /// assert_eq!(&format!("{}", Foo(23)), "Foo(23)"); /// ``` #[stable(feature = "fmt_flags", since = "1.5.0")] - pub const fn width(&self) -> Option { self.width } + pub fn width(&self) -> Option { self.width } /// Optionally specified precision for numeric types. /// @@ -1589,7 +1589,7 @@ impl<'a> Formatter<'a> { /// assert_eq!(&format!("{}", Foo(23.2)), "Foo(23.20)"); /// ``` #[stable(feature = "fmt_flags", since = "1.5.0")] - pub const fn precision(&self) -> Option { self.precision } + pub fn precision(&self) -> Option { self.precision } /// Determines if the `+` flag was specified. /// @@ -1617,7 +1617,7 @@ impl<'a> Formatter<'a> { /// assert_eq!(&format!("{}", Foo(23)), "Foo(23)"); /// ``` #[stable(feature = "fmt_flags", since = "1.5.0")] - pub const fn sign_plus(&self) -> bool { + pub fn sign_plus(&self) -> bool { self.flags & (1 << FlagV1::SignPlus as u32) != 0 } @@ -1645,7 +1645,7 @@ impl<'a> Formatter<'a> { /// assert_eq!(&format!("{}", Foo(23)), "Foo(23)"); /// ``` #[stable(feature = "fmt_flags", since = "1.5.0")] - pub const fn sign_minus(&self) -> bool { + pub fn sign_minus(&self) -> bool { self.flags & (1 << FlagV1::SignMinus as u32) != 0 } @@ -1672,7 +1672,7 @@ impl<'a> Formatter<'a> { /// assert_eq!(&format!("{}", Foo(23)), "23"); /// ``` #[stable(feature = "fmt_flags", since = "1.5.0")] - pub const fn alternate(&self) -> bool { + pub fn alternate(&self) -> bool { self.flags & (1 << FlagV1::Alternate as u32) != 0 } @@ -1697,7 +1697,7 @@ impl<'a> Formatter<'a> { /// assert_eq!(&format!("{:04}", Foo(23)), "23"); /// ``` #[stable(feature = "fmt_flags", since = "1.5.0")] - pub const fn sign_aware_zero_pad(&self) -> bool { + pub fn sign_aware_zero_pad(&self) -> bool { self.flags & (1 << FlagV1::SignAwareZeroPad as u32) != 0 } diff --git a/src/libcore/panic.rs b/src/libcore/panic.rs index af9d1596938..f0efeb59e8d 100644 --- a/src/libcore/panic.rs +++ b/src/libcore/panic.rs @@ -55,7 +55,7 @@ impl<'a> PanicInfo<'a> { issue = "0")] #[doc(hidden)] #[inline] - pub const fn internal_constructor(message: Option<&'a fmt::Arguments<'a>>, + pub fn internal_constructor(message: Option<&'a fmt::Arguments<'a>>, location: Location<'a>) -> Self { struct NoPayload; @@ -96,7 +96,7 @@ impl<'a> PanicInfo<'a> { /// /// [`fmt::write`]: ../fmt/fn.write.html #[unstable(feature = "panic_info_message", issue = "44489")] - pub const fn message(&self) -> Option<&fmt::Arguments> { + pub fn message(&self) -> Option<&fmt::Arguments> { self.message } @@ -125,7 +125,7 @@ impl<'a> PanicInfo<'a> { /// panic!("Normal panic"); /// ``` #[stable(feature = "panic_hooks", since = "1.10.0")] - pub const fn location(&self) -> Option<&Location> { + pub fn location(&self) -> Option<&Location> { // NOTE: If this is changed to sometimes return None, // deal with that case in std::panicking::default_hook and std::panicking::begin_panic_fmt. Some(&self.location) @@ -186,7 +186,7 @@ impl<'a> Location<'a> { and related macros", issue = "0")] #[doc(hidden)] - pub const fn internal_constructor(file: &'a str, line: u32, col: u32) -> Self { + pub fn internal_constructor(file: &'a str, line: u32, col: u32) -> Self { Location { file, line, col } } @@ -208,7 +208,7 @@ impl<'a> Location<'a> { /// panic!("Normal panic"); /// ``` #[stable(feature = "panic_hooks", since = "1.10.0")] - pub const fn file(&self) -> &str { + pub fn file(&self) -> &str { self.file } @@ -230,7 +230,7 @@ impl<'a> Location<'a> { /// panic!("Normal panic"); /// ``` #[stable(feature = "panic_hooks", since = "1.10.0")] - pub const fn line(&self) -> u32 { + pub fn line(&self) -> u32 { self.line } @@ -252,7 +252,7 @@ impl<'a> Location<'a> { /// panic!("Normal panic"); /// ``` #[stable(feature = "panic_col", since = "1.25.0")] - pub const fn column(&self) -> u32 { + pub fn column(&self) -> u32 { self.col } } diff --git a/src/libcore/pin.rs b/src/libcore/pin.rs index 63a433a8b23..68de82d2945 100644 --- a/src/libcore/pin.rs +++ b/src/libcore/pin.rs @@ -207,7 +207,7 @@ impl<'a, T: ?Sized> Pin<&'a T> { /// with the same lifetime as the original `Pin`. #[unstable(feature = "pin", issue = "49150")] #[inline(always)] - pub const fn get_ref(this: Pin<&'a T>) -> &'a T { + pub fn get_ref(this: Pin<&'a T>) -> &'a T { this.pointer } } @@ -216,7 +216,7 @@ impl<'a, T: ?Sized> Pin<&'a mut T> { /// Convert this `Pin<&mut T>` into a `Pin<&T>` with the same lifetime. #[unstable(feature = "pin", issue = "49150")] #[inline(always)] - pub const fn into_ref(this: Pin<&'a mut T>) -> Pin<&'a T> { + pub fn into_ref(this: Pin<&'a mut T>) -> Pin<&'a T> { Pin { pointer: this.pointer } } diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index f8dee537062..dae425da789 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -4021,7 +4021,7 @@ impl<'a, T> ChunksExact<'a, T> { /// returned by the iterator. The returned slice has at most `chunk_size-1` /// elements. #[stable(feature = "chunks_exact", since = "1.31.0")] - pub const fn remainder(&self) -> &'a [T] { + pub fn remainder(&self) -> &'a [T] { self.rem } } @@ -4517,7 +4517,7 @@ impl<'a, T> RChunksExact<'a, T> { /// returned by the iterator. The returned slice has at most `chunk_size-1` /// elements. #[stable(feature = "rchunks", since = "1.31.0")] - pub const fn remainder(&self) -> &'a [T] { + pub fn remainder(&self) -> &'a [T] { self.rem } } diff --git a/src/libcore/str/lossy.rs b/src/libcore/str/lossy.rs index 950552fc6b1..186d6adbc91 100644 --- a/src/libcore/str/lossy.rs +++ b/src/libcore/str/lossy.rs @@ -29,7 +29,7 @@ impl Utf8Lossy { unsafe { mem::transmute(bytes) } } - pub const fn chunks(&self) -> Utf8LossyChunksIter { + pub fn chunks(&self) -> Utf8LossyChunksIter { Utf8LossyChunksIter { source: &self.bytes } } } diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index d73e5db727c..f5bfe804899 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -231,7 +231,7 @@ impl Utf8Error { /// assert_eq!(1, error.valid_up_to()); /// ``` #[stable(feature = "utf8_error", since = "1.5.0")] - pub const fn valid_up_to(&self) -> usize { self.valid_up_to } + pub fn valid_up_to(&self) -> usize { self.valid_up_to } /// Provide more information about the failure: /// diff --git a/src/libcore/task/wake.rs b/src/libcore/task/wake.rs index 1db3a290e04..c9fb22e0080 100644 --- a/src/libcore/task/wake.rs +++ b/src/libcore/task/wake.rs @@ -141,7 +141,7 @@ impl LocalWaker { /// `Waker` is nearly identical to `LocalWaker`, but is threadsafe /// (implements `Send` and `Sync`). #[inline] - pub const fn as_waker(&self) -> &Waker { + pub fn as_waker(&self) -> &Waker { &self.0 } diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index b95449d11ea..c18f200872d 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -3013,7 +3013,7 @@ impl<'a, K: 'a, V: 'a> VacantEntry<'a, K, V> { /// assert_eq!(map.entry("poneyland").key(), &"poneyland"); /// ``` #[stable(feature = "map_entry_keys", since = "1.10.0")] - pub const fn key(&self) -> &K { + pub fn key(&self) -> &K { &self.key } diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index feff65bff3f..e2dc02e40bf 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -833,7 +833,7 @@ impl NulError { /// assert_eq!(nul_error.nul_position(), 7); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub const fn nul_position(&self) -> usize { self.0 } + pub fn nul_position(&self) -> usize { self.0 } /// Consumes this error, returning the underlying vector of bytes which /// generated the error in the first place. @@ -909,7 +909,7 @@ impl IntoStringError { /// Access the underlying UTF-8 error that was the cause of this error. #[stable(feature = "cstring_into", since = "1.7.0")] - pub const fn utf8_error(&self) -> Utf8Error { + pub fn utf8_error(&self) -> Utf8Error { self.error } } diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index bde9c57c57c..e26e6d391f8 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -633,7 +633,7 @@ impl IntoInnerError { /// }; /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub const fn error(&self) -> &Error { &self.1 } + pub fn error(&self) -> &Error { &self.1 } /// Returns the buffered writer instance which generated the error. /// diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 4c3117260fe..c07d4a2e755 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -1653,7 +1653,7 @@ impl Chain { /// } /// ``` #[stable(feature = "more_io_inner_methods", since = "1.20.0")] - pub const fn get_ref(&self) -> (&T, &U) { + pub fn get_ref(&self) -> (&T, &U) { (&self.first, &self.second) } @@ -1780,7 +1780,7 @@ impl Take { /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub const fn limit(&self) -> u64 { self.limit } + pub fn limit(&self) -> u64 { self.limit } /// Sets the number of bytes that can be read before this instance will /// return EOF. This is the same as constructing a new `Take` instance, so @@ -1856,7 +1856,7 @@ impl Take { /// } /// ``` #[stable(feature = "more_io_inner_methods", since = "1.20.0")] - pub const fn get_ref(&self) -> &T { + pub fn get_ref(&self) -> &T { &self.inner } diff --git a/src/libstd/net/addr.rs b/src/libstd/net/addr.rs index fc2e8104782..ff35325ab4f 100644 --- a/src/libstd/net/addr.rs +++ b/src/libstd/net/addr.rs @@ -475,7 +475,7 @@ impl SocketAddrV6 { /// assert_eq!(socket.flowinfo(), 10); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub const fn flowinfo(&self) -> u32 { + pub fn flowinfo(&self) -> u32 { self.inner.sin6_flowinfo } @@ -515,7 +515,7 @@ impl SocketAddrV6 { /// assert_eq!(socket.scope_id(), 78); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub const fn scope_id(&self) -> u32 { + pub fn scope_id(&self) -> u32 { self.inner.sin6_scope_id } diff --git a/src/libstd/net/ip.rs b/src/libstd/net/ip.rs index c5106c9abb9..2517c45696a 100644 --- a/src/libstd/net/ip.rs +++ b/src/libstd/net/ip.rs @@ -402,7 +402,7 @@ impl Ipv4Addr { /// assert_eq!(addr.octets(), [127, 0, 0, 1]); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn octets(&self) -> [u8; 4] { + pub fn octets(&self) -> [u8; 4] { let bits = u32::from_be(self.inner.s_addr); [(bits >> 24) as u8, (bits >> 16) as u8, (bits >> 8) as u8, bits as u8] } diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 71f39ff85e7..a153456370c 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -439,7 +439,7 @@ impl<'a> PrefixComponent<'a> { /// /// [`Prefix`]: enum.Prefix.html #[stable(feature = "rust1", since = "1.0.0")] - pub const fn kind(&self) -> Prefix<'a> { + pub fn kind(&self) -> Prefix<'a> { self.parsed } @@ -447,7 +447,7 @@ impl<'a> PrefixComponent<'a> { /// /// [`OsStr`]: ../../std/ffi/struct.OsStr.html #[stable(feature = "rust1", since = "1.0.0")] - pub const fn as_os_str(&self) -> &'a OsStr { + pub fn as_os_str(&self) -> &'a OsStr { self.raw } } @@ -1918,7 +1918,7 @@ impl Path { /// [`None`]: ../../std/option/enum.Option.html#variant.None /// [`parent`]: struct.Path.html#method.parent #[stable(feature = "path_ancestors", since = "1.28.0")] - pub const fn ancestors(&self) -> Ancestors { + pub fn ancestors(&self) -> Ancestors { Ancestors { next: Some(&self), } @@ -2267,7 +2267,7 @@ impl Path { /// println!("{}", path.display()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub const fn display(&self) -> Display { + pub fn display(&self) -> Display { Display { path: self } } diff --git a/src/libstd/sync/condvar.rs b/src/libstd/sync/condvar.rs index 1c6cc9cb361..3014283da5b 100644 --- a/src/libstd/sync/condvar.rs +++ b/src/libstd/sync/condvar.rs @@ -72,7 +72,7 @@ impl WaitTimeoutResult { /// } /// ``` #[stable(feature = "wait_timeout", since = "1.5.0")] - pub const fn timed_out(&self) -> bool { + pub fn timed_out(&self) -> bool { self.0 } } diff --git a/src/libstd/sync/mpsc/mod.rs b/src/libstd/sync/mpsc/mod.rs index 2a2e5c030b3..b726168c7c6 100644 --- a/src/libstd/sync/mpsc/mod.rs +++ b/src/libstd/sync/mpsc/mod.rs @@ -1469,7 +1469,7 @@ impl Receiver { /// assert_eq!(iter.next(), None); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub const fn iter(&self) -> Iter { + pub fn iter(&self) -> Iter { Iter { rx: self } } @@ -1512,7 +1512,7 @@ impl Receiver { /// assert_eq!(iter.next(), None); /// ``` #[stable(feature = "receiver_try_iter", since = "1.15.0")] - pub const fn try_iter(&self) -> TryIter { + pub fn try_iter(&self) -> TryIter { TryIter { rx: self } } diff --git a/src/libstd/sync/once.rs b/src/libstd/sync/once.rs index 4dd37ec3878..cf9698cb2a9 100644 --- a/src/libstd/sync/once.rs +++ b/src/libstd/sync/once.rs @@ -517,7 +517,7 @@ impl OnceState { /// assert!(!state.poisoned()); /// }); #[unstable(feature = "once_poison", issue = "33577")] - pub const fn poisoned(&self) -> bool { + pub fn poisoned(&self) -> bool { self.poisoned } } diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index 3a3d2450014..e9a97f7c747 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -1391,7 +1391,7 @@ impl JoinHandle { /// println!("thread id: {:?}", thread.id()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub const fn thread(&self) -> &Thread { + pub fn thread(&self) -> &Thread { &self.0.thread } diff --git a/src/libstd/time.rs b/src/libstd/time.rs index a9344941f42..90ab3491599 100644 --- a/src/libstd/time.rs +++ b/src/libstd/time.rs @@ -449,7 +449,7 @@ impl SystemTimeError { /// } /// ``` #[stable(feature = "time2", since = "1.8.0")] - pub const fn duration(&self) -> Duration { + pub fn duration(&self) -> Duration { self.0 } } -- cgit 1.4.1-3-g733a5 From e15c62d61fa02fac93992db9297aa4a8a56cef93 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Tue, 23 Oct 2018 23:09:44 +0200 Subject: revert making internal APIs const fn. --- src/liballoc/collections/binary_heap.rs | 2 +- src/liballoc/collections/btree/node.rs | 2 +- src/liballoc/collections/linked_list.rs | 2 +- src/liballoc/collections/vec_deque.rs | 2 +- src/liballoc/raw_vec.rs | 4 ++-- src/libcore/alloc.rs | 2 +- src/libcore/array.rs | 2 +- src/libcore/benches/iter.rs | 2 +- src/libcore/cell.rs | 4 ++-- src/libcore/fmt/mod.rs | 4 ++-- src/libcore/iter/mod.rs | 2 +- src/libcore/num/dec2flt/mod.rs | 4 ++-- src/libcore/num/dec2flt/parse.rs | 2 +- src/libcore/num/dec2flt/rawfp.rs | 2 +- src/libcore/num/flt2dec/estimator.rs | 2 +- src/libcore/ptr.rs | 2 +- src/libcore/slice/memchr.rs | 6 +++--- src/libcore/slice/mod.rs | 2 +- src/libcore/str/mod.rs | 8 ++++---- src/libcore/unicode/bool_trie.rs | 2 +- src/libstd/collections/hash/map.rs | 4 ++-- src/libstd/collections/hash/table.rs | 12 ++++++------ src/libstd/ffi/c_str.rs | 4 ++-- src/libstd/sync/mpsc/mod.rs | 2 +- src/libstd/sync/mpsc/oneshot.rs | 2 +- src/libstd/sys_common/mutex.rs | 2 +- src/libstd/sys_common/net.rs | 6 +++--- src/libstd/sys_common/wtf8.rs | 4 ++-- 28 files changed, 47 insertions(+), 47 deletions(-) (limited to 'src/libstd') diff --git a/src/liballoc/collections/binary_heap.rs b/src/liballoc/collections/binary_heap.rs index e7e741dea4c..fcadcb544c4 100644 --- a/src/liballoc/collections/binary_heap.rs +++ b/src/liballoc/collections/binary_heap.rs @@ -884,7 +884,7 @@ impl<'a, T> Hole<'a, T> { } #[inline] - const fn pos(&self) -> usize { + fn pos(&self) -> usize { self.pos } diff --git a/src/liballoc/collections/btree/node.rs b/src/liballoc/collections/btree/node.rs index 10665b8e463..deca9591fbd 100644 --- a/src/liballoc/collections/btree/node.rs +++ b/src/liballoc/collections/btree/node.rs @@ -357,7 +357,7 @@ impl NodeRef { /// Returns the height of this node in the whole tree. Zero height denotes the /// leaf level. - pub const fn height(&self) -> usize { + pub fn height(&self) -> usize { self.height } diff --git a/src/liballoc/collections/linked_list.rs b/src/liballoc/collections/linked_list.rs index 9b2975b81a3..3d66b9f54da 100644 --- a/src/liballoc/collections/linked_list.rs +++ b/src/liballoc/collections/linked_list.rs @@ -135,7 +135,7 @@ impl fmt::Debug for IntoIter { } impl Node { - const fn new(element: T) -> Self { + fn new(element: T) -> Self { Node { next: None, prev: None, diff --git a/src/liballoc/collections/vec_deque.rs b/src/liballoc/collections/vec_deque.rs index e0ae7561d45..88e76033f27 100644 --- a/src/liballoc/collections/vec_deque.rs +++ b/src/liballoc/collections/vec_deque.rs @@ -1275,7 +1275,7 @@ impl VecDeque { } #[inline] - const fn is_contiguous(&self) -> bool { + fn is_contiguous(&self) -> bool { self.tail <= self.head } diff --git a/src/liballoc/raw_vec.rs b/src/liballoc/raw_vec.rs index 0b6f400a403..837770feece 100644 --- a/src/liballoc/raw_vec.rs +++ b/src/liballoc/raw_vec.rs @@ -204,7 +204,7 @@ impl RawVec { /// Gets a raw pointer to the start of the allocation. Note that this is /// Unique::empty() if `cap = 0` or T is zero-sized. In the former case, you must /// be careful. - pub const fn ptr(&self) -> *mut T { + pub fn ptr(&self) -> *mut T { self.ptr.as_ptr() } @@ -221,7 +221,7 @@ impl RawVec { } /// Returns a shared reference to the allocator backing this RawVec. - pub const fn alloc(&self) -> &A { + pub fn alloc(&self) -> &A { &self.a } diff --git a/src/libcore/alloc.rs b/src/libcore/alloc.rs index 045fabca268..113a85abecb 100644 --- a/src/libcore/alloc.rs +++ b/src/libcore/alloc.rs @@ -25,7 +25,7 @@ use num::NonZeroUsize; #[derive(Debug)] pub struct Excess(pub NonNull, pub usize); -const fn size_align() -> (usize, usize) { +fn size_align() -> (usize, usize) { (mem::size_of::(), mem::align_of::()) } diff --git a/src/libcore/array.rs b/src/libcore/array.rs index 0bea541e163..3d24f8902bd 100644 --- a/src/libcore/array.rs +++ b/src/libcore/array.rs @@ -77,7 +77,7 @@ impl TryFromSliceError { issue = "0")] #[inline] #[doc(hidden)] - pub const fn __description(&self) -> &str { + pub fn __description(&self) -> &str { "could not convert slice to array" } } diff --git a/src/libcore/benches/iter.rs b/src/libcore/benches/iter.rs index c8b8c2eff97..6c597301ac2 100644 --- a/src/libcore/benches/iter.rs +++ b/src/libcore/benches/iter.rs @@ -39,7 +39,7 @@ fn bench_multiple_take(b: &mut Bencher) { }); } -const fn scatter(x: i32) -> i32 { (x * 31) % 127 } +fn scatter(x: i32) -> i32 { (x * 31) % 127 } #[bench] fn bench_max_by_key(b: &mut Bencher) { diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index 3fe77fe688f..9cf42eff219 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -636,12 +636,12 @@ type BorrowFlag = isize; const UNUSED: BorrowFlag = 0; #[inline(always)] -const fn is_writing(x: BorrowFlag) -> bool { +fn is_writing(x: BorrowFlag) -> bool { x < UNUSED } #[inline(always)] -const fn is_reading(x: BorrowFlag) -> bool { +fn is_reading(x: BorrowFlag) -> bool { x > UNUSED } diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index 4fde4e79ee2..284617a4167 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -1703,11 +1703,11 @@ impl<'a> Formatter<'a> { // FIXME: Decide what public API we want for these two flags. // https://github.com/rust-lang/rust/issues/48584 - const fn debug_lower_hex(&self) -> bool { + fn debug_lower_hex(&self) -> bool { self.flags & (1 << FlagV1::DebugLowerHex as u32) != 0 } - const fn debug_upper_hex(&self) -> bool { + fn debug_upper_hex(&self) -> bool { self.flags & (1 << FlagV1::DebugUpperHex as u32) != 0 } diff --git a/src/libcore/iter/mod.rs b/src/libcore/iter/mod.rs index 72a032b57d0..c42fb7019c7 100644 --- a/src/libcore/iter/mod.rs +++ b/src/libcore/iter/mod.rs @@ -2658,7 +2658,7 @@ impl FusedIterator for Flatten I::Item: IntoIterator {} /// Adapts an iterator by flattening it, for use in `flatten()` and `flat_map()`. -const fn flatten_compat(iter: I) -> FlattenCompat { +fn flatten_compat(iter: I) -> FlattenCompat { FlattenCompat { iter, frontiter: None, backiter: None } } diff --git a/src/libcore/num/dec2flt/mod.rs b/src/libcore/num/dec2flt/mod.rs index 0e1f6664d96..f93564c2849 100644 --- a/src/libcore/num/dec2flt/mod.rs +++ b/src/libcore/num/dec2flt/mod.rs @@ -187,11 +187,11 @@ impl fmt::Display for ParseFloatError { } } -const fn pfe_empty() -> ParseFloatError { +fn pfe_empty() -> ParseFloatError { ParseFloatError { kind: FloatErrorKind::Empty } } -const fn pfe_invalid() -> ParseFloatError { +fn pfe_invalid() -> ParseFloatError { ParseFloatError { kind: FloatErrorKind::Invalid } } diff --git a/src/libcore/num/dec2flt/parse.rs b/src/libcore/num/dec2flt/parse.rs index 8d8f357425e..e7ed94d4d91 100644 --- a/src/libcore/num/dec2flt/parse.rs +++ b/src/libcore/num/dec2flt/parse.rs @@ -39,7 +39,7 @@ pub struct Decimal<'a> { } impl<'a> Decimal<'a> { - pub const fn new(integral: &'a [u8], fractional: &'a [u8], exp: i64) -> Decimal<'a> { + pub fn new(integral: &'a [u8], fractional: &'a [u8], exp: i64) -> Decimal<'a> { Decimal { integral, fractional, exp } } } diff --git a/src/libcore/num/dec2flt/rawfp.rs b/src/libcore/num/dec2flt/rawfp.rs index c5d4aa68958..38f4e4687a9 100644 --- a/src/libcore/num/dec2flt/rawfp.rs +++ b/src/libcore/num/dec2flt/rawfp.rs @@ -44,7 +44,7 @@ pub struct Unpacked { } impl Unpacked { - pub const fn new(sig: u64, k: i16) -> Self { + pub fn new(sig: u64, k: i16) -> Self { Unpacked { sig, k } } } diff --git a/src/libcore/num/flt2dec/estimator.rs b/src/libcore/num/flt2dec/estimator.rs index 2a87bf43664..4e33fcfd76e 100644 --- a/src/libcore/num/flt2dec/estimator.rs +++ b/src/libcore/num/flt2dec/estimator.rs @@ -15,7 +15,7 @@ /// This is used to approximate `k = ceil(log_10 (mant * 2^exp))`; /// the true `k` is either `k_0` or `k_0+1`. #[doc(hidden)] -pub const fn estimate_scaling_factor(mant: u64, exp: i16) -> i16 { +pub fn estimate_scaling_factor(mant: u64, exp: i16) -> i16 { // 2^(nbits-1) < mant <= 2^nbits if mant > 0 let nbits = 64 - (mant - 1).leading_zeros() as i64; // 1292913986 = floor(2^32 * log_10 2) diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index c06e580e30e..b795cd72150 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -2759,7 +2759,7 @@ impl Unique { } /// Acquires the underlying `*mut` pointer. - pub const fn as_ptr(self) -> *mut T { + pub fn as_ptr(self) -> *mut T { self.pointer.0 as *mut T } diff --git a/src/libcore/slice/memchr.rs b/src/libcore/slice/memchr.rs index deaeb53e84a..cf95333af9c 100644 --- a/src/libcore/slice/memchr.rs +++ b/src/libcore/slice/memchr.rs @@ -29,19 +29,19 @@ const HI_USIZE: usize = HI_U64 as usize; /// bytes where the borrow propagated all the way to the most significant /// bit." #[inline] -const fn contains_zero_byte(x: usize) -> bool { +fn contains_zero_byte(x: usize) -> bool { x.wrapping_sub(LO_USIZE) & !x & HI_USIZE != 0 } #[cfg(target_pointer_width = "16")] #[inline] -const fn repeat_byte(b: u8) -> usize { +fn repeat_byte(b: u8) -> usize { (b as usize) << 8 | b as usize } #[cfg(not(target_pointer_width = "16"))] #[inline] -const fn repeat_byte(b: u8) -> usize { +fn repeat_byte(b: u8) -> usize { (b as usize) * (::usize::MAX / 255) } diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index dae425da789..fece328f51f 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -2737,7 +2737,7 @@ impl<'a, T> IntoIterator for &'a mut [T] { // Macro helper functions #[inline(always)] -const fn size_from_ptr(_: *const T) -> usize { +fn size_from_ptr(_: *const T) -> usize { mem::size_of::() } diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index f5bfe804899..e710cbffe4d 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -476,16 +476,16 @@ pub struct Chars<'a> { /// The first byte is special, only want bottom 5 bits for width 2, 4 bits /// for width 3, and 3 bits for width 4. #[inline] -const fn utf8_first_byte(byte: u8, width: u32) -> u32 { (byte & (0x7F >> width)) as u32 } +fn utf8_first_byte(byte: u8, width: u32) -> u32 { (byte & (0x7F >> width)) as u32 } /// Returns the value of `ch` updated with continuation byte `byte`. #[inline] -const fn utf8_acc_cont_byte(ch: u32, byte: u8) -> u32 { (ch << 6) | (byte & CONT_MASK) as u32 } +fn utf8_acc_cont_byte(ch: u32, byte: u8) -> u32 { (ch << 6) | (byte & CONT_MASK) as u32 } /// Checks whether the byte is a UTF-8 continuation byte (i.e. starts with the /// bits `10`). #[inline] -const fn utf8_is_cont_byte(byte: u8) -> bool { (byte & !CONT_MASK) == TAG_CONT_U8 } +fn utf8_is_cont_byte(byte: u8) -> bool { (byte & !CONT_MASK) == TAG_CONT_U8 } #[inline] fn unwrap_or_0(opt: Option<&u8>) -> u8 { @@ -1420,7 +1420,7 @@ const NONASCII_MASK: usize = 0x80808080_80808080u64 as usize; /// Returns `true` if any byte in the word `x` is nonascii (>= 128). #[inline] -const fn contains_nonascii(x: usize) -> bool { +fn contains_nonascii(x: usize) -> bool { (x & NONASCII_MASK) != 0 } diff --git a/src/libcore/unicode/bool_trie.rs b/src/libcore/unicode/bool_trie.rs index 995795839b7..0e6437fded5 100644 --- a/src/libcore/unicode/bool_trie.rs +++ b/src/libcore/unicode/bool_trie.rs @@ -71,6 +71,6 @@ impl SmallBoolTrie { } } -const fn trie_range_leaf(c: u32, bitmap_chunk: u64) -> bool { +fn trie_range_leaf(c: u32, bitmap_chunk: u64) -> bool { ((bitmap_chunk >> (c & 63)) & 1) != 0 } diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index c18f200872d..8de415e8aed 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -36,7 +36,7 @@ struct DefaultResizePolicy; impl DefaultResizePolicy { #[inline] - const fn new() -> DefaultResizePolicy { + fn new() -> DefaultResizePolicy { DefaultResizePolicy } @@ -69,7 +69,7 @@ impl DefaultResizePolicy { /// The capacity of the given raw capacity. #[inline] - const fn capacity(&self, raw_cap: usize) -> usize { + fn capacity(&self, raw_cap: usize) -> usize { // This doesn't have to be checked for overflow since allocation size // in bytes will overflow earlier than multiplication by 10. // diff --git a/src/libstd/collections/hash/table.rs b/src/libstd/collections/hash/table.rs index 0df20395b01..547f97cc8ac 100644 --- a/src/libstd/collections/hash/table.rs +++ b/src/libstd/collections/hash/table.rs @@ -247,7 +247,7 @@ impl RawBucket { // Buckets hold references to the table. impl FullBucket { /// Borrow a reference to the table. - pub const fn table(&self) -> &M { + pub fn table(&self) -> &M { &self.table } /// Borrow a mutable reference to the table. @@ -259,18 +259,18 @@ impl FullBucket { self.table } /// Get the raw index. - pub const fn index(&self) -> usize { + pub fn index(&self) -> usize { self.raw.idx } /// Get the raw bucket. - pub const fn raw(&self) -> RawBucket { + pub fn raw(&self) -> RawBucket { self.raw } } impl EmptyBucket { /// Borrow a reference to the table. - pub const fn table(&self) -> &M { + pub fn table(&self) -> &M { &self.table } /// Borrow a mutable reference to the table. @@ -281,7 +281,7 @@ impl EmptyBucket { impl Bucket { /// Get the raw index. - pub const fn index(&self) -> usize { + pub fn index(&self) -> usize { self.raw.idx } /// get the table. @@ -772,7 +772,7 @@ impl RawTable { /// The number of elements ever `put` in the hashtable, minus the number /// of elements ever `take`n. - pub const fn size(&self) -> usize { + pub fn size(&self) -> usize { self.size } diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index e2dc02e40bf..cb914539985 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -265,12 +265,12 @@ enum FromBytesWithNulErrorKind { } impl FromBytesWithNulError { - const fn interior_nul(pos: usize) -> FromBytesWithNulError { + fn interior_nul(pos: usize) -> FromBytesWithNulError { FromBytesWithNulError { kind: FromBytesWithNulErrorKind::InteriorNul(pos), } } - const fn not_nul_terminated() -> FromBytesWithNulError { + fn not_nul_terminated() -> FromBytesWithNulError { FromBytesWithNulError { kind: FromBytesWithNulErrorKind::NotNulTerminated, } diff --git a/src/libstd/sync/mpsc/mod.rs b/src/libstd/sync/mpsc/mod.rs index b726168c7c6..059ced4f56e 100644 --- a/src/libstd/sync/mpsc/mod.rs +++ b/src/libstd/sync/mpsc/mod.rs @@ -785,7 +785,7 @@ pub fn sync_channel(bound: usize) -> (SyncSender, Receiver) { //////////////////////////////////////////////////////////////////////////////// impl Sender { - const fn new(inner: Flavor) -> Sender { + fn new(inner: Flavor) -> Sender { Sender { inner: UnsafeCell::new(inner), } diff --git a/src/libstd/sync/mpsc/oneshot.rs b/src/libstd/sync/mpsc/oneshot.rs index 273644cb902..b8e50c9297b 100644 --- a/src/libstd/sync/mpsc/oneshot.rs +++ b/src/libstd/sync/mpsc/oneshot.rs @@ -89,7 +89,7 @@ enum MyUpgrade { } impl Packet { - pub const fn new() -> Packet { + pub fn new() -> Packet { Packet { data: UnsafeCell::new(None), upgrade: UnsafeCell::new(NothingSent), diff --git a/src/libstd/sys_common/mutex.rs b/src/libstd/sys_common/mutex.rs index dc9edb306de..c6d531c7a1a 100644 --- a/src/libstd/sys_common/mutex.rs +++ b/src/libstd/sys_common/mutex.rs @@ -80,7 +80,7 @@ impl Mutex { } // not meant to be exported to the outside world, just the containing module -pub const fn raw(mutex: &Mutex) -> &imp::Mutex { &mutex.0 } +pub fn raw(mutex: &Mutex) -> &imp::Mutex { &mutex.0 } #[must_use] /// A simple RAII utility for the above Mutex without the poisoning semantics. diff --git a/src/libstd/sys_common/net.rs b/src/libstd/sys_common/net.rs index f58c26ef428..d09a233ed89 100644 --- a/src/libstd/sys_common/net.rs +++ b/src/libstd/sys_common/net.rs @@ -199,7 +199,7 @@ impl TcpStream { Ok(TcpStream { inner: sock }) } - pub const fn socket(&self) -> &Socket { &self.inner } + pub fn socket(&self) -> &Socket { &self.inner } pub fn into_socket(self) -> Socket { self.inner } @@ -339,7 +339,7 @@ impl TcpListener { Ok(TcpListener { inner: sock }) } - pub const fn socket(&self) -> &Socket { &self.inner } + pub fn socket(&self) -> &Socket { &self.inner } pub fn into_socket(self) -> Socket { self.inner } @@ -427,7 +427,7 @@ impl UdpSocket { Ok(UdpSocket { inner: sock }) } - pub const fn socket(&self) -> &Socket { &self.inner } + pub fn socket(&self) -> &Socket { &self.inner } pub fn into_socket(self) -> Socket { self.inner } diff --git a/src/libstd/sys_common/wtf8.rs b/src/libstd/sys_common/wtf8.rs index 5f6747a1224..19ce932aa12 100644 --- a/src/libstd/sys_common/wtf8.rs +++ b/src/libstd/sys_common/wtf8.rs @@ -85,13 +85,13 @@ impl CodePoint { /// /// Since all Unicode scalar values are code points, this always succeeds. #[inline] - pub const fn from_char(value: char) -> CodePoint { + pub fn from_char(value: char) -> CodePoint { CodePoint { value: value as u32 } } /// Returns the numeric value of the code point. #[inline] - pub const fn to_u32(&self) -> u32 { + pub fn to_u32(&self) -> u32 { self.value } -- cgit 1.4.1-3-g733a5 From 38a90406d3b0a8aec72cb62f794ceddb026c86b6 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Thu, 25 Oct 2018 19:37:52 +0200 Subject: revert some more constification. --- src/liballoc/collections/linked_list.rs | 8 ++++---- src/libcore/mem.rs | 2 +- src/libstd/io/cursor.rs | 6 +++--- src/libstd/io/mod.rs | 4 ++-- src/libstd/io/util.rs | 4 ++-- src/libstd/process.rs | 6 +++--- src/libstd/thread/mod.rs | 2 +- 7 files changed, 16 insertions(+), 16 deletions(-) (limited to 'src/libstd') diff --git a/src/liballoc/collections/linked_list.rs b/src/liballoc/collections/linked_list.rs index 3d66b9f54da..4b1cbb0d908 100644 --- a/src/liballoc/collections/linked_list.rs +++ b/src/liballoc/collections/linked_list.rs @@ -264,7 +264,7 @@ impl LinkedList { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - pub const fn new() -> Self { + pub fn new() -> Self { LinkedList { head: None, tail: None, @@ -341,7 +341,7 @@ impl LinkedList { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - pub const fn iter(&self) -> Iter { + pub fn iter(&self) -> Iter { Iter { head: self.head, tail: self.tail, @@ -401,7 +401,7 @@ impl LinkedList { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - pub const fn is_empty(&self) -> bool { + pub fn is_empty(&self) -> bool { self.len() == 0 } @@ -427,7 +427,7 @@ impl LinkedList { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - pub const fn len(&self) -> usize { + pub fn len(&self) -> usize { self.len } diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index 0aa374c7a64..b89f37fa5ce 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -139,7 +139,7 @@ pub use intrinsics::transmute; /// [ub]: ../../reference/behavior-considered-undefined.html #[inline] #[stable(feature = "rust1", since = "1.0.0")] -pub const fn forget(t: T) { +pub fn forget(t: T) { ManuallyDrop::new(t); } diff --git a/src/libstd/io/cursor.rs b/src/libstd/io/cursor.rs index 05bee19c93f..14f20151dca 100644 --- a/src/libstd/io/cursor.rs +++ b/src/libstd/io/cursor.rs @@ -104,7 +104,7 @@ impl Cursor { /// # force_inference(&buff); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub const fn new(inner: T) -> Cursor { + pub fn new(inner: T) -> Cursor { Cursor { pos: 0, inner: inner } } @@ -138,7 +138,7 @@ impl Cursor { /// let reference = buff.get_ref(); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub const fn get_ref(&self) -> &T { &self.inner } + pub fn get_ref(&self) -> &T { &self.inner } /// Gets a mutable reference to the underlying value in this cursor. /// @@ -179,7 +179,7 @@ impl Cursor { /// assert_eq!(buff.position(), 1); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub const fn position(&self) -> u64 { self.pos } + pub fn position(&self) -> u64 { self.pos } /// Sets the position of this cursor. /// diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index c07d4a2e755..e263db24fc2 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -885,7 +885,7 @@ impl Initializer { /// Returns a new `Initializer` which will zero out buffers. #[unstable(feature = "read_initializer", issue = "42788")] #[inline] - pub const fn zeroing() -> Initializer { + pub fn zeroing() -> Initializer { Initializer(true) } @@ -906,7 +906,7 @@ impl Initializer { /// Indicates if a buffer should be initialized. #[unstable(feature = "read_initializer", issue = "42788")] #[inline] - pub const fn should_initialize(&self) -> bool { + pub fn should_initialize(&self) -> bool { self.0 } diff --git a/src/libstd/io/util.rs b/src/libstd/io/util.rs index d0db4cfc704..12995d08683 100644 --- a/src/libstd/io/util.rs +++ b/src/libstd/io/util.rs @@ -99,7 +99,7 @@ pub struct Empty { _priv: () } /// assert!(buffer.is_empty()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] -pub const fn empty() -> Empty { Empty { _priv: () } } +pub fn empty() -> Empty { Empty { _priv: () } } #[stable(feature = "rust1", since = "1.0.0")] impl Read for Empty { @@ -199,7 +199,7 @@ pub struct Sink { _priv: () } /// assert_eq!(num_bytes, 5); /// ``` #[stable(feature = "rust1", since = "1.0.0")] -pub const fn sink() -> Sink { Sink { _priv: () } } +pub fn sink() -> Sink { Sink { _priv: () } } #[stable(feature = "rust1", since = "1.0.0")] impl Write for Sink { diff --git a/src/libstd/process.rs b/src/libstd/process.rs index d5047ef6ad7..a9219f75362 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -926,7 +926,7 @@ impl Stdio { /// assert_eq!(String::from_utf8_lossy(&output.stdout), "!dlrow ,olleH\n"); /// ``` #[stable(feature = "process", since = "1.0.0")] - pub const fn piped() -> Stdio { Stdio(imp::Stdio::MakePipe) } + pub fn piped() -> Stdio { Stdio(imp::Stdio::MakePipe) } /// The child inherits from the corresponding parent descriptor. /// @@ -961,7 +961,7 @@ impl Stdio { /// println!("You piped in the reverse of: {}", String::from_utf8_lossy(&output.stdout)); /// ``` #[stable(feature = "process", since = "1.0.0")] - pub const fn inherit() -> Stdio { Stdio(imp::Stdio::Inherit) } + pub fn inherit() -> Stdio { Stdio(imp::Stdio::Inherit) } /// This stream will be ignored. This is the equivalent of attaching the /// stream to `/dev/null` @@ -998,7 +998,7 @@ impl Stdio { /// // Ignores any piped-in input /// ``` #[stable(feature = "process", since = "1.0.0")] - pub const fn null() -> Stdio { Stdio(imp::Stdio::Null) } + pub fn null() -> Stdio { Stdio(imp::Stdio::Null) } } impl FromInner for Stdio { diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index e9a97f7c747..a57b8dc7237 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -286,7 +286,7 @@ impl Builder { /// handler.join().unwrap(); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub const fn new() -> Builder { + pub fn new() -> Builder { Builder { name: None, stack_size: None, -- cgit 1.4.1-3-g733a5