提交 e15c62d6 编写于 作者: M Mazdak Farrokhzad

revert making internal APIs const fn.

上级 d1d2aa22
......@@ -884,7 +884,7 @@ unsafe fn new(data: &'a mut [T], pos: usize) -> Self {
}
#[inline]
const fn pos(&self) -> usize {
fn pos(&self) -> usize {
self.pos
}
......
......@@ -357,7 +357,7 @@ pub fn len(&self) -> usize {
/// 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
}
......
......@@ -135,7 +135,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
}
impl<T> Node<T> {
const fn new(element: T) -> Self {
fn new(element: T) -> Self {
Node {
next: None,
prev: None,
......
......@@ -1275,7 +1275,7 @@ pub fn pop_back(&mut self) -> Option<T> {
}
#[inline]
const fn is_contiguous(&self) -> bool {
fn is_contiguous(&self) -> bool {
self.tail <= self.head
}
......
......@@ -204,7 +204,7 @@ impl<T, A: Alloc> RawVec<T, A> {
/// 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 @@ pub fn cap(&self) -> usize {
}
/// Returns a shared reference to the allocator backing this RawVec.
pub const fn alloc(&self) -> &A {
pub fn alloc(&self) -> &A {
&self.a
}
......
......@@ -25,7 +25,7 @@
#[derive(Debug)]
pub struct Excess(pub NonNull<u8>, pub usize);
const fn size_align<T>() -> (usize, usize) {
fn size_align<T>() -> (usize, usize) {
(mem::size_of::<T>(), mem::align_of::<T>())
}
......
......@@ -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"
}
}
......
......@@ -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) {
......
......@@ -636,12 +636,12 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
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
}
......
......@@ -1703,11 +1703,11 @@ pub fn sign_aware_zero_pad(&self) -> bool {
// 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
}
......
......@@ -2658,7 +2658,7 @@ impl<I, U> FusedIterator for Flatten<I>
I::Item: IntoIterator<IntoIter = U, Item = U::Item> {}
/// Adapts an iterator by flattening it, for use in `flatten()` and `flat_map()`.
const fn flatten_compat<I, U>(iter: I) -> FlattenCompat<I, U> {
fn flatten_compat<I, U>(iter: I) -> FlattenCompat<I, U> {
FlattenCompat { iter, frontiter: None, backiter: None }
}
......
......@@ -187,11 +187,11 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
}
}
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 }
}
......
......@@ -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 }
}
}
......
......@@ -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 }
}
}
......
......@@ -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)
......
......@@ -2759,7 +2759,7 @@ pub fn new(ptr: *mut T) -> Option<Self> {
}
/// 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
}
......
......@@ -29,19 +29,19 @@
/// 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)
}
......
......@@ -2737,7 +2737,7 @@ fn into_iter(self) -> IterMut<'a, T> {
// Macro helper functions
#[inline(always)]
const fn size_from_ptr<T>(_: *const T) -> usize {
fn size_from_ptr<T>(_: *const T) -> usize {
mem::size_of::<T>()
}
......
......@@ -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 @@ impl FusedIterator for LinesAny<'_> {}
/// 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
}
......
......@@ -71,6 +71,6 @@ pub fn lookup(&self, c: char) -> bool {
}
}
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
}
......@@ -36,7 +36,7 @@
impl DefaultResizePolicy {
#[inline]
const fn new() -> DefaultResizePolicy {
fn new() -> DefaultResizePolicy {
DefaultResizePolicy
}
......@@ -69,7 +69,7 @@ fn raw_capacity(&self, len: usize) -> usize {
/// 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.
//
......
......@@ -247,7 +247,7 @@ unsafe fn hash_pair(&self) -> (*mut HashUint, *mut (K, V)) {
// Buckets hold references to the table.
impl<K, V, M> FullBucket<K, V, M> {
/// 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 @@ pub fn into_table(self) -> M {
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<K, V> {
pub fn raw(&self) -> RawBucket<K, V> {
self.raw
}
}
impl<K, V, M> EmptyBucket<K, V, M> {
/// 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 @@ pub fn table_mut(&mut self) -> &mut M {
impl<K, V, M> Bucket<K, V, M> {
/// 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 @@ pub fn capacity(&self) -> usize {
/// 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
}
......
......@@ -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,
}
......
......@@ -785,7 +785,7 @@ pub fn sync_channel<T>(bound: usize) -> (SyncSender<T>, Receiver<T>) {
////////////////////////////////////////////////////////////////////////////////
impl<T> Sender<T> {
const fn new(inner: Flavor<T>) -> Sender<T> {
fn new(inner: Flavor<T>) -> Sender<T> {
Sender {
inner: UnsafeCell::new(inner),
}
......
......@@ -89,7 +89,7 @@ enum MyUpgrade<T> {
}
impl<T> Packet<T> {
pub const fn new() -> Packet<T> {
pub fn new() -> Packet<T> {
Packet {
data: UnsafeCell::new(None),
upgrade: UnsafeCell::new(NothingSent),
......
......@@ -80,7 +80,7 @@ pub unsafe fn destroy(&self) { self.0.destroy() }
}
// 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.
......
......@@ -199,7 +199,7 @@ pub fn connect_timeout(addr: &SocketAddr, timeout: Duration) -> io::Result<TcpSt
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 @@ pub fn bind(addr: &SocketAddr) -> io::Result<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 @@ pub fn bind(addr: &SocketAddr) -> io::Result<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 }
......
......@@ -85,13 +85,13 @@ pub fn from_u32(value: u32) -> Option<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
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册