Auto merge of #105741 - pietroalbini:pa-1.68-nightly, r=Mark-Simulacrum
Bump master bootstrap compiler This PR bumps the bootstrap compiler to the beta created earlier this week, cherry-picks the stabilization version number updates, and updates the `cfg(bootstrap)`s. r? `@Mark-Simulacrum`
This commit is contained in:
commit
b15ca6635f
39 changed files with 451 additions and 1073 deletions
|
@ -140,7 +140,7 @@ impl char {
|
|||
/// assert_eq!(None, c);
|
||||
/// ```
|
||||
#[stable(feature = "assoc_char_funcs", since = "1.52.0")]
|
||||
#[rustc_const_stable(feature = "const_char_convert", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "const_char_convert", since = "1.67.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn from_u32(i: u32) -> Option<char> {
|
||||
|
@ -241,7 +241,7 @@ impl char {
|
|||
/// let _c = char::from_digit(1, 37);
|
||||
/// ```
|
||||
#[stable(feature = "assoc_char_funcs", since = "1.52.0")]
|
||||
#[rustc_const_stable(feature = "const_char_convert", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "const_char_convert", since = "1.67.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn from_digit(num: u32, radix: u32) -> Option<char> {
|
||||
|
@ -338,7 +338,7 @@ impl char {
|
|||
/// let _ = '1'.to_digit(37);
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "const_char_convert", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "const_char_convert", since = "1.67.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
|
|
|
@ -110,7 +110,7 @@ pub fn decode_utf16<I: IntoIterator<Item = u16>>(iter: I) -> DecodeUtf16<I::Into
|
|||
|
||||
/// Converts a `u32` to a `char`. Use [`char::from_u32`] instead.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "const_char_convert", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "const_char_convert", since = "1.67.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn from_u32(i: u32) -> Option<char> {
|
||||
|
@ -130,7 +130,7 @@ pub const unsafe fn from_u32_unchecked(i: u32) -> char {
|
|||
|
||||
/// Converts a digit in the given radix to a `char`. Use [`char::from_digit`] instead.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "const_char_convert", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "const_char_convert", since = "1.67.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn from_digit(num: u32, radix: u32) -> Option<char> {
|
||||
|
|
|
@ -24,8 +24,6 @@
|
|||
|
||||
use crate::const_closure::ConstFnMutClosure;
|
||||
use crate::marker::Destruct;
|
||||
#[cfg(bootstrap)]
|
||||
use crate::marker::StructuralPartialEq;
|
||||
|
||||
use self::Ordering::*;
|
||||
|
||||
|
@ -333,7 +331,7 @@ pub struct AssertParamIsEq<T: Eq + ?Sized> {
|
|||
/// assert_eq!(Ordering::Greater, result);
|
||||
/// ```
|
||||
#[derive(Clone, Copy, Eq, Debug, Hash)]
|
||||
#[cfg_attr(not(bootstrap), derive_const(PartialOrd, Ord, PartialEq))]
|
||||
#[derive_const(PartialOrd, Ord, PartialEq)]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[repr(i8)]
|
||||
pub enum Ordering {
|
||||
|
@ -879,40 +877,6 @@ pub macro Ord($item:item) {
|
|||
/* compiler built-in */
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[cfg(bootstrap)]
|
||||
impl StructuralPartialEq for Ordering {}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_cmp", issue = "92391")]
|
||||
#[cfg(bootstrap)]
|
||||
impl const PartialEq for Ordering {
|
||||
#[inline]
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
(*self as i32).eq(&(*other as i32))
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_cmp", issue = "92391")]
|
||||
#[cfg(bootstrap)]
|
||||
impl const Ord for Ordering {
|
||||
#[inline]
|
||||
fn cmp(&self, other: &Ordering) -> Ordering {
|
||||
(*self as i32).cmp(&(*other as i32))
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_cmp", issue = "92391")]
|
||||
#[cfg(bootstrap)]
|
||||
impl const PartialOrd for Ordering {
|
||||
#[inline]
|
||||
fn partial_cmp(&self, other: &Ordering) -> Option<Ordering> {
|
||||
(*self as i32).partial_cmp(&(*other as i32))
|
||||
}
|
||||
}
|
||||
|
||||
/// Trait for types that form a [partial order](https://en.wikipedia.org/wiki/Partial_order).
|
||||
///
|
||||
/// The `lt`, `le`, `gt`, and `ge` methods of this trait can be called using
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
use crate::marker::Destruct;
|
||||
#[cfg(not(bootstrap))]
|
||||
use crate::marker::Tuple;
|
||||
|
||||
/// Struct representing a closure with mutably borrowed data.
|
||||
|
@ -46,33 +45,6 @@ impl<'a, CapturedData: ?Sized, Function> ConstFnMutClosure<&'a mut CapturedData,
|
|||
|
||||
macro_rules! impl_fn_mut_tuple {
|
||||
($($var:ident)*) => {
|
||||
#[cfg(bootstrap)]
|
||||
#[allow(unused_parens)]
|
||||
impl<'a, $($var,)* ClosureArguments, Function, ClosureReturnValue> const
|
||||
FnOnce<ClosureArguments> for ConstFnMutClosure<($(&'a mut $var),*), Function>
|
||||
where
|
||||
Function: ~const Fn(($(&mut $var),*), ClosureArguments) -> ClosureReturnValue + ~const Destruct,
|
||||
{
|
||||
type Output = ClosureReturnValue;
|
||||
|
||||
extern "rust-call" fn call_once(mut self, args: ClosureArguments) -> Self::Output {
|
||||
self.call_mut(args)
|
||||
}
|
||||
}
|
||||
#[cfg(bootstrap)]
|
||||
#[allow(unused_parens)]
|
||||
impl<'a, $($var,)* ClosureArguments, Function, ClosureReturnValue> const
|
||||
FnMut<ClosureArguments> for ConstFnMutClosure<($(&'a mut $var),*), Function>
|
||||
where
|
||||
Function: ~const Fn(($(&mut $var),*), ClosureArguments)-> ClosureReturnValue + ~const Destruct,
|
||||
{
|
||||
extern "rust-call" fn call_mut(&mut self, args: ClosureArguments) -> Self::Output {
|
||||
#[allow(non_snake_case)]
|
||||
let ($($var),*) = &mut self.data;
|
||||
(self.func)(($($var),*), args)
|
||||
}
|
||||
}
|
||||
#[cfg(not(bootstrap))]
|
||||
#[allow(unused_parens)]
|
||||
impl<'a, $($var,)* ClosureArguments: Tuple, Function, ClosureReturnValue> const
|
||||
FnOnce<ClosureArguments> for ConstFnMutClosure<($(&'a mut $var),*), Function>
|
||||
|
@ -85,7 +57,6 @@ macro_rules! impl_fn_mut_tuple {
|
|||
self.call_mut(args)
|
||||
}
|
||||
}
|
||||
#[cfg(not(bootstrap))]
|
||||
#[allow(unused_parens)]
|
||||
impl<'a, $($var,)* ClosureArguments: Tuple, Function, ClosureReturnValue> const
|
||||
FnMut<ClosureArguments> for ConstFnMutClosure<($(&'a mut $var),*), Function>
|
||||
|
|
|
@ -44,7 +44,7 @@ pub use poll_fn::{poll_fn, PollFn};
|
|||
/// non-Send/Sync as well, and we don't want that.
|
||||
///
|
||||
/// It also simplifies the HIR lowering of `.await`.
|
||||
#[cfg_attr(not(bootstrap), lang = "ResumeTy")]
|
||||
#[lang = "ResumeTy"]
|
||||
#[doc(hidden)]
|
||||
#[unstable(feature = "gen_future", issue = "50547")]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
|
@ -61,7 +61,6 @@ unsafe impl Sync for ResumeTy {}
|
|||
/// This function returns a `GenFuture` underneath, but hides it in `impl Trait` to give
|
||||
/// better error messages (`impl Future` rather than `GenFuture<[closure.....]>`).
|
||||
// This is `const` to avoid extra errors after we recover from `const async fn`
|
||||
#[cfg_attr(bootstrap, lang = "from_generator")]
|
||||
#[doc(hidden)]
|
||||
#[unstable(feature = "gen_future", issue = "50547")]
|
||||
#[rustc_const_unstable(feature = "gen_future", issue = "50547")]
|
||||
|
@ -113,10 +112,10 @@ pub unsafe fn get_context<'a, 'b>(cx: ResumeTy) -> &'a mut Context<'b> {
|
|||
unsafe { &mut *cx.0.as_ptr().cast() }
|
||||
}
|
||||
|
||||
#[cfg_attr(not(bootstrap), lang = "identity_future")]
|
||||
#[doc(hidden)]
|
||||
#[unstable(feature = "gen_future", issue = "50547")]
|
||||
#[inline]
|
||||
#[lang = "identity_future"]
|
||||
pub const fn identity_future<O, Fut: Future<Output = O>>(f: Fut) -> Fut {
|
||||
f
|
||||
}
|
||||
|
|
|
@ -55,7 +55,6 @@
|
|||
#![allow(missing_docs)]
|
||||
|
||||
use crate::marker::DiscriminantKind;
|
||||
#[cfg(not(bootstrap))]
|
||||
use crate::marker::Tuple;
|
||||
use crate::mem;
|
||||
|
||||
|
@ -2175,66 +2174,6 @@ extern "rust-intrinsic" {
|
|||
/// `unreachable_unchecked` is actually being reached. The bug is in *crate A*,
|
||||
/// which violates the principle that a `const fn` must behave the same at
|
||||
/// compile-time and at run-time. The unsafe code in crate B is fine.
|
||||
#[cfg(bootstrap)]
|
||||
#[rustc_const_unstable(feature = "const_eval_select", issue = "none")]
|
||||
pub fn const_eval_select<ARG, F, G, RET>(arg: ARG, called_in_const: F, called_at_rt: G) -> RET
|
||||
where
|
||||
G: FnOnce<ARG, Output = RET>,
|
||||
F: FnOnce<ARG, Output = RET>;
|
||||
|
||||
/// Selects which function to call depending on the context.
|
||||
///
|
||||
/// If this function is evaluated at compile-time, then a call to this
|
||||
/// intrinsic will be replaced with a call to `called_in_const`. It gets
|
||||
/// replaced with a call to `called_at_rt` otherwise.
|
||||
///
|
||||
/// # Type Requirements
|
||||
///
|
||||
/// The two functions must be both function items. They cannot be function
|
||||
/// pointers or closures. The first function must be a `const fn`.
|
||||
///
|
||||
/// `arg` will be the tupled arguments that will be passed to either one of
|
||||
/// the two functions, therefore, both functions must accept the same type of
|
||||
/// arguments. Both functions must return RET.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// The two functions must behave observably equivalent. Safe code in other
|
||||
/// crates may assume that calling a `const fn` at compile-time and at run-time
|
||||
/// produces the same result. A function that produces a different result when
|
||||
/// evaluated at run-time, or has any other observable side-effects, is
|
||||
/// *unsound*.
|
||||
///
|
||||
/// Here is an example of how this could cause a problem:
|
||||
/// ```no_run
|
||||
/// #![feature(const_eval_select)]
|
||||
/// #![feature(core_intrinsics)]
|
||||
/// use std::hint::unreachable_unchecked;
|
||||
/// use std::intrinsics::const_eval_select;
|
||||
///
|
||||
/// // Crate A
|
||||
/// pub const fn inconsistent() -> i32 {
|
||||
/// fn runtime() -> i32 { 1 }
|
||||
/// const fn compiletime() -> i32 { 2 }
|
||||
///
|
||||
/// unsafe {
|
||||
// // ⚠ This code violates the required equivalence of `compiletime`
|
||||
/// // and `runtime`.
|
||||
/// const_eval_select((), compiletime, runtime)
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// // Crate B
|
||||
/// const X: i32 = inconsistent();
|
||||
/// let x = inconsistent();
|
||||
/// if x != X { unsafe { unreachable_unchecked(); }}
|
||||
/// ```
|
||||
///
|
||||
/// This code causes Undefined Behavior when being run, since the
|
||||
/// `unreachable_unchecked` is actually being reached. The bug is in *crate A*,
|
||||
/// which violates the principle that a `const fn` must behave the same at
|
||||
/// compile-time and at run-time. The unsafe code in crate B is fine.
|
||||
#[cfg(not(bootstrap))]
|
||||
#[rustc_const_unstable(feature = "const_eval_select", issue = "none")]
|
||||
pub fn const_eval_select<ARG: Tuple, F, G, RET>(
|
||||
arg: ARG,
|
||||
|
|
|
@ -60,7 +60,8 @@
|
|||
//!
|
||||
//! # Examples
|
||||
//!
|
||||
//! ```rust
|
||||
#![cfg_attr(bootstrap, doc = "```rust,compile_fail")]
|
||||
#![cfg_attr(not(bootstrap), doc = "```rust")]
|
||||
//! #![feature(core_intrinsics, custom_mir)]
|
||||
//!
|
||||
//! extern crate core;
|
||||
|
@ -291,7 +292,8 @@ define!(
|
|||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
#[cfg_attr(bootstrap, doc = "```rust,compile_fail")]
|
||||
#[cfg_attr(not(bootstrap), doc = "```rust")]
|
||||
/// #![feature(custom_mir, core_intrinsics)]
|
||||
///
|
||||
/// extern crate core;
|
||||
|
|
|
@ -195,7 +195,7 @@
|
|||
#![feature(const_refs_to_cell)]
|
||||
#![feature(decl_macro)]
|
||||
#![feature(deprecated_suggestion)]
|
||||
#![cfg_attr(not(bootstrap), feature(derive_const))]
|
||||
#![feature(derive_const)]
|
||||
#![feature(doc_cfg)]
|
||||
#![feature(doc_notable_trait)]
|
||||
#![feature(rustdoc_internals)]
|
||||
|
|
|
@ -1461,7 +1461,6 @@ pub(crate) mod builtin {
|
|||
/// [the reference]: ../../../reference/attributes/derive.html
|
||||
#[unstable(feature = "derive_const", issue = "none")]
|
||||
#[rustc_builtin_macro]
|
||||
#[cfg(not(bootstrap))]
|
||||
pub macro derive_const($item:item) {
|
||||
/* compiler built-in */
|
||||
}
|
||||
|
@ -1516,7 +1515,6 @@ pub(crate) mod builtin {
|
|||
/// Attribute macro applied to a function to register it as a handler for allocation failure.
|
||||
///
|
||||
/// See also [`std::alloc::handle_alloc_error`](../../../std/alloc/fn.handle_alloc_error.html).
|
||||
#[cfg(not(bootstrap))]
|
||||
#[unstable(feature = "alloc_error_handler", issue = "51540")]
|
||||
#[allow_internal_unstable(rustc_attrs)]
|
||||
#[rustc_builtin_macro]
|
||||
|
@ -1553,7 +1551,6 @@ pub(crate) mod builtin {
|
|||
issue = "23416",
|
||||
reason = "placeholder syntax for type ascription"
|
||||
)]
|
||||
#[cfg(not(bootstrap))]
|
||||
pub macro type_ascribe($expr:expr, $ty:ty) {
|
||||
/* compiler built-in */
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ unsafe impl<T: Sync + ?Sized> Send for &T {}
|
|||
)]
|
||||
#[fundamental] // for Default, for example, which requires that `[T]: !Default` be evaluatable
|
||||
#[rustc_specialization_trait]
|
||||
#[cfg_attr(not(bootstrap), rustc_deny_explicit_impl)]
|
||||
#[rustc_deny_explicit_impl]
|
||||
pub trait Sized {
|
||||
// Empty.
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ pub trait Sized {
|
|||
/// [nomicon-coerce]: ../../nomicon/coercions.html
|
||||
#[unstable(feature = "unsize", issue = "18598")]
|
||||
#[lang = "unsize"]
|
||||
#[cfg_attr(not(bootstrap), rustc_deny_explicit_impl)]
|
||||
#[rustc_deny_explicit_impl]
|
||||
pub trait Unsize<T: ?Sized> {
|
||||
// Empty.
|
||||
}
|
||||
|
@ -695,7 +695,7 @@ impl<T: ?Sized> StructuralEq for PhantomData<T> {}
|
|||
reason = "this trait is unlikely to ever be stabilized, use `mem::discriminant` instead"
|
||||
)]
|
||||
#[lang = "discriminant_kind"]
|
||||
#[cfg_attr(not(bootstrap), rustc_deny_explicit_impl)]
|
||||
#[rustc_deny_explicit_impl]
|
||||
pub trait DiscriminantKind {
|
||||
/// The type of the discriminant, which must satisfy the trait
|
||||
/// bounds required by `mem::Discriminant`.
|
||||
|
@ -796,7 +796,7 @@ impl<T: ?Sized> Unpin for *mut T {}
|
|||
#[lang = "destruct"]
|
||||
#[rustc_on_unimplemented(message = "can't drop `{Self}`", append_const_msg)]
|
||||
#[const_trait]
|
||||
#[cfg_attr(not(bootstrap), rustc_deny_explicit_impl)]
|
||||
#[rustc_deny_explicit_impl]
|
||||
pub trait Destruct {}
|
||||
|
||||
/// A marker for tuple types.
|
||||
|
@ -806,12 +806,12 @@ pub trait Destruct {}
|
|||
#[unstable(feature = "tuple_trait", issue = "none")]
|
||||
#[lang = "tuple_trait"]
|
||||
#[rustc_on_unimplemented(message = "`{Self}` is not a tuple")]
|
||||
#[cfg_attr(not(bootstrap), rustc_deny_explicit_impl)]
|
||||
#[rustc_deny_explicit_impl]
|
||||
pub trait Tuple {}
|
||||
|
||||
/// A marker for things
|
||||
#[unstable(feature = "pointer_sized_trait", issue = "none")]
|
||||
#[cfg_attr(not(bootstrap), lang = "pointer_sized")]
|
||||
#[lang = "pointer_sized"]
|
||||
#[rustc_on_unimplemented(
|
||||
message = "`{Self}` needs to be a pointer-sized type",
|
||||
label = "`{Self}` needs to be a pointer-sized type"
|
||||
|
|
|
@ -2290,8 +2290,8 @@ macro_rules! int_impl {
|
|||
/// ```
|
||||
#[doc = concat!("assert_eq!(5", stringify!($SelfT), ".ilog(5), 1);")]
|
||||
/// ```
|
||||
#[stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[stable(feature = "int_log", since = "1.67.0")]
|
||||
#[rustc_const_stable(feature = "int_log", since = "1.67.0")]
|
||||
#[rustc_allow_const_fn_unstable(const_option)]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
|
@ -2313,8 +2313,8 @@ macro_rules! int_impl {
|
|||
/// ```
|
||||
#[doc = concat!("assert_eq!(2", stringify!($SelfT), ".ilog2(), 1);")]
|
||||
/// ```
|
||||
#[stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[stable(feature = "int_log", since = "1.67.0")]
|
||||
#[rustc_const_stable(feature = "int_log", since = "1.67.0")]
|
||||
#[rustc_allow_const_fn_unstable(const_option)]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
|
@ -2335,8 +2335,8 @@ macro_rules! int_impl {
|
|||
/// ```
|
||||
#[doc = concat!("assert_eq!(10", stringify!($SelfT), ".ilog10(), 1);")]
|
||||
/// ```
|
||||
#[stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[stable(feature = "int_log", since = "1.67.0")]
|
||||
#[rustc_const_stable(feature = "int_log", since = "1.67.0")]
|
||||
#[rustc_allow_const_fn_unstable(const_option)]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
|
@ -2360,8 +2360,8 @@ macro_rules! int_impl {
|
|||
/// ```
|
||||
#[doc = concat!("assert_eq!(5", stringify!($SelfT), ".checked_ilog(5), Some(1));")]
|
||||
/// ```
|
||||
#[stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[stable(feature = "int_log", since = "1.67.0")]
|
||||
#[rustc_const_stable(feature = "int_log", since = "1.67.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
|
@ -2396,8 +2396,8 @@ macro_rules! int_impl {
|
|||
/// ```
|
||||
#[doc = concat!("assert_eq!(2", stringify!($SelfT), ".checked_ilog2(), Some(1));")]
|
||||
/// ```
|
||||
#[stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[stable(feature = "int_log", since = "1.67.0")]
|
||||
#[rustc_const_stable(feature = "int_log", since = "1.67.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
|
@ -2420,8 +2420,8 @@ macro_rules! int_impl {
|
|||
/// ```
|
||||
#[doc = concat!("assert_eq!(10", stringify!($SelfT), ".checked_ilog10(), Some(1));")]
|
||||
/// ```
|
||||
#[stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[stable(feature = "int_log", since = "1.67.0")]
|
||||
#[rustc_const_stable(feature = "int_log", since = "1.67.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
|
|
|
@ -462,8 +462,8 @@ macro_rules! nonzero_unsigned_operations {
|
|||
#[doc = concat!("assert_eq!(", stringify!($Ty), "::new(8).unwrap().ilog2(), 3);")]
|
||||
#[doc = concat!("assert_eq!(", stringify!($Ty), "::new(9).unwrap().ilog2(), 3);")]
|
||||
/// ```
|
||||
#[stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[stable(feature = "int_log", since = "1.67.0")]
|
||||
#[rustc_const_stable(feature = "int_log", since = "1.67.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
|
@ -486,8 +486,8 @@ macro_rules! nonzero_unsigned_operations {
|
|||
#[doc = concat!("assert_eq!(", stringify!($Ty), "::new(100).unwrap().ilog10(), 2);")]
|
||||
#[doc = concat!("assert_eq!(", stringify!($Ty), "::new(101).unwrap().ilog10(), 2);")]
|
||||
/// ```
|
||||
#[stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[stable(feature = "int_log", since = "1.67.0")]
|
||||
#[rustc_const_stable(feature = "int_log", since = "1.67.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
|
@ -1253,7 +1253,7 @@ macro_rules! nonzero_bits {
|
|||
///
|
||||
#[doc = concat!("assert_eq!(", stringify!($Ty), "::BITS, ", stringify!($Int), "::BITS);")]
|
||||
/// ```
|
||||
#[stable(feature = "nonzero_bits", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[stable(feature = "nonzero_bits", since = "1.67.0")]
|
||||
pub const BITS: u32 = <$Int>::BITS;
|
||||
}
|
||||
)+
|
||||
|
|
|
@ -703,8 +703,8 @@ macro_rules! uint_impl {
|
|||
/// ```
|
||||
#[doc = concat!("assert_eq!(5", stringify!($SelfT), ".ilog(5), 1);")]
|
||||
/// ```
|
||||
#[stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[stable(feature = "int_log", since = "1.67.0")]
|
||||
#[rustc_const_stable(feature = "int_log", since = "1.67.0")]
|
||||
#[rustc_allow_const_fn_unstable(const_option)]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
|
@ -726,8 +726,8 @@ macro_rules! uint_impl {
|
|||
/// ```
|
||||
#[doc = concat!("assert_eq!(2", stringify!($SelfT), ".ilog2(), 1);")]
|
||||
/// ```
|
||||
#[stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[stable(feature = "int_log", since = "1.67.0")]
|
||||
#[rustc_const_stable(feature = "int_log", since = "1.67.0")]
|
||||
#[rustc_allow_const_fn_unstable(const_option)]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
|
@ -748,8 +748,8 @@ macro_rules! uint_impl {
|
|||
/// ```
|
||||
#[doc = concat!("assert_eq!(10", stringify!($SelfT), ".ilog10(), 1);")]
|
||||
/// ```
|
||||
#[stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[stable(feature = "int_log", since = "1.67.0")]
|
||||
#[rustc_const_stable(feature = "int_log", since = "1.67.0")]
|
||||
#[rustc_allow_const_fn_unstable(const_option)]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
|
@ -773,8 +773,8 @@ macro_rules! uint_impl {
|
|||
/// ```
|
||||
#[doc = concat!("assert_eq!(5", stringify!($SelfT), ".checked_ilog(5), Some(1));")]
|
||||
/// ```
|
||||
#[stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[stable(feature = "int_log", since = "1.67.0")]
|
||||
#[rustc_const_stable(feature = "int_log", since = "1.67.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
|
@ -809,8 +809,8 @@ macro_rules! uint_impl {
|
|||
/// ```
|
||||
#[doc = concat!("assert_eq!(2", stringify!($SelfT), ".checked_ilog2(), Some(1));")]
|
||||
/// ```
|
||||
#[stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[stable(feature = "int_log", since = "1.67.0")]
|
||||
#[rustc_const_stable(feature = "int_log", since = "1.67.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
|
@ -831,8 +831,8 @@ macro_rules! uint_impl {
|
|||
/// ```
|
||||
#[doc = concat!("assert_eq!(10", stringify!($SelfT), ".checked_ilog10(), Some(1));")]
|
||||
/// ```
|
||||
#[stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[stable(feature = "int_log", since = "1.67.0")]
|
||||
#[rustc_const_stable(feature = "int_log", since = "1.67.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#[cfg(not(bootstrap))]
|
||||
use crate::marker::Tuple;
|
||||
|
||||
/// The version of the call operator that takes an immutable receiver.
|
||||
|
@ -54,87 +53,6 @@ use crate::marker::Tuple;
|
|||
/// let double = |x| x * 2;
|
||||
/// assert_eq!(call_with_one(double), 2);
|
||||
/// ```
|
||||
#[cfg(bootstrap)]
|
||||
#[lang = "fn"]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_paren_sugar]
|
||||
#[rustc_on_unimplemented(
|
||||
on(
|
||||
Args = "()",
|
||||
note = "wrap the `{Self}` in a closure with no arguments: `|| {{ /* code */ }}`"
|
||||
),
|
||||
on(
|
||||
_Self = "unsafe fn",
|
||||
note = "unsafe function cannot be called generically without an unsafe block",
|
||||
// SAFETY: tidy is not smart enough to tell that the below unsafe block is a string
|
||||
label = "call the function in a closure: `|| unsafe {{ /* code */ }}`"
|
||||
),
|
||||
message = "expected a `{Fn}<{Args}>` closure, found `{Self}`",
|
||||
label = "expected an `Fn<{Args}>` closure, found `{Self}`"
|
||||
)]
|
||||
#[fundamental] // so that regex can rely that `&str: !FnMut`
|
||||
#[must_use = "closures are lazy and do nothing unless called"]
|
||||
#[const_trait]
|
||||
pub trait Fn<Args>: FnMut<Args> {
|
||||
/// Performs the call operation.
|
||||
#[unstable(feature = "fn_traits", issue = "29625")]
|
||||
extern "rust-call" fn call(&self, args: Args) -> Self::Output;
|
||||
}
|
||||
|
||||
/// The version of the call operator that takes an immutable receiver.
|
||||
///
|
||||
/// Instances of `Fn` can be called repeatedly without mutating state.
|
||||
///
|
||||
/// *This trait (`Fn`) is not to be confused with [function pointers]
|
||||
/// (`fn`).*
|
||||
///
|
||||
/// `Fn` is implemented automatically by closures which only take immutable
|
||||
/// references to captured variables or don't capture anything at all, as well
|
||||
/// as (safe) [function pointers] (with some caveats, see their documentation
|
||||
/// for more details). Additionally, for any type `F` that implements `Fn`, `&F`
|
||||
/// implements `Fn`, too.
|
||||
///
|
||||
/// Since both [`FnMut`] and [`FnOnce`] are supertraits of `Fn`, any
|
||||
/// instance of `Fn` can be used as a parameter where a [`FnMut`] or [`FnOnce`]
|
||||
/// is expected.
|
||||
///
|
||||
/// Use `Fn` as a bound when you want to accept a parameter of function-like
|
||||
/// type and need to call it repeatedly and without mutating state (e.g., when
|
||||
/// calling it concurrently). If you do not need such strict requirements, use
|
||||
/// [`FnMut`] or [`FnOnce`] as bounds.
|
||||
///
|
||||
/// See the [chapter on closures in *The Rust Programming Language*][book] for
|
||||
/// some more information on this topic.
|
||||
///
|
||||
/// Also of note is the special syntax for `Fn` traits (e.g.
|
||||
/// `Fn(usize, bool) -> usize`). Those interested in the technical details of
|
||||
/// this can refer to [the relevant section in the *Rustonomicon*][nomicon].
|
||||
///
|
||||
/// [book]: ../../book/ch13-01-closures.html
|
||||
/// [function pointers]: fn
|
||||
/// [nomicon]: ../../nomicon/hrtb.html
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ## Calling a closure
|
||||
///
|
||||
/// ```
|
||||
/// let square = |x| x * x;
|
||||
/// assert_eq!(square(5), 25);
|
||||
/// ```
|
||||
///
|
||||
/// ## Using a `Fn` parameter
|
||||
///
|
||||
/// ```
|
||||
/// fn call_with_one<F>(func: F) -> usize
|
||||
/// where F: Fn(usize) -> usize {
|
||||
/// func(1)
|
||||
/// }
|
||||
///
|
||||
/// let double = |x| x * 2;
|
||||
/// assert_eq!(call_with_one(double), 2);
|
||||
/// ```
|
||||
#[cfg(not(bootstrap))]
|
||||
#[lang = "fn"]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_paren_sugar]
|
||||
|
@ -222,95 +140,6 @@ pub trait Fn<Args: Tuple>: FnMut<Args> {
|
|||
///
|
||||
/// assert_eq!(x, 5);
|
||||
/// ```
|
||||
#[cfg(bootstrap)]
|
||||
#[lang = "fn_mut"]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_paren_sugar]
|
||||
#[rustc_on_unimplemented(
|
||||
on(
|
||||
Args = "()",
|
||||
note = "wrap the `{Self}` in a closure with no arguments: `|| {{ /* code */ }}`"
|
||||
),
|
||||
on(
|
||||
_Self = "unsafe fn",
|
||||
note = "unsafe function cannot be called generically without an unsafe block",
|
||||
// SAFETY: tidy is not smart enough to tell that the below unsafe block is a string
|
||||
label = "call the function in a closure: `|| unsafe {{ /* code */ }}`"
|
||||
),
|
||||
message = "expected a `{FnMut}<{Args}>` closure, found `{Self}`",
|
||||
label = "expected an `FnMut<{Args}>` closure, found `{Self}`"
|
||||
)]
|
||||
#[fundamental] // so that regex can rely that `&str: !FnMut`
|
||||
#[must_use = "closures are lazy and do nothing unless called"]
|
||||
#[const_trait]
|
||||
pub trait FnMut<Args>: FnOnce<Args> {
|
||||
/// Performs the call operation.
|
||||
#[unstable(feature = "fn_traits", issue = "29625")]
|
||||
extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output;
|
||||
}
|
||||
|
||||
/// The version of the call operator that takes a mutable receiver.
|
||||
///
|
||||
/// Instances of `FnMut` can be called repeatedly and may mutate state.
|
||||
///
|
||||
/// `FnMut` is implemented automatically by closures which take mutable
|
||||
/// references to captured variables, as well as all types that implement
|
||||
/// [`Fn`], e.g., (safe) [function pointers] (since `FnMut` is a supertrait of
|
||||
/// [`Fn`]). Additionally, for any type `F` that implements `FnMut`, `&mut F`
|
||||
/// implements `FnMut`, too.
|
||||
///
|
||||
/// Since [`FnOnce`] is a supertrait of `FnMut`, any instance of `FnMut` can be
|
||||
/// used where a [`FnOnce`] is expected, and since [`Fn`] is a subtrait of
|
||||
/// `FnMut`, any instance of [`Fn`] can be used where `FnMut` is expected.
|
||||
///
|
||||
/// Use `FnMut` as a bound when you want to accept a parameter of function-like
|
||||
/// type and need to call it repeatedly, while allowing it to mutate state.
|
||||
/// If you don't want the parameter to mutate state, use [`Fn`] as a
|
||||
/// bound; if you don't need to call it repeatedly, use [`FnOnce`].
|
||||
///
|
||||
/// See the [chapter on closures in *The Rust Programming Language*][book] for
|
||||
/// some more information on this topic.
|
||||
///
|
||||
/// Also of note is the special syntax for `Fn` traits (e.g.
|
||||
/// `Fn(usize, bool) -> usize`). Those interested in the technical details of
|
||||
/// this can refer to [the relevant section in the *Rustonomicon*][nomicon].
|
||||
///
|
||||
/// [book]: ../../book/ch13-01-closures.html
|
||||
/// [function pointers]: fn
|
||||
/// [nomicon]: ../../nomicon/hrtb.html
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ## Calling a mutably capturing closure
|
||||
///
|
||||
/// ```
|
||||
/// let mut x = 5;
|
||||
/// {
|
||||
/// let mut square_x = || x *= x;
|
||||
/// square_x();
|
||||
/// }
|
||||
/// assert_eq!(x, 25);
|
||||
/// ```
|
||||
///
|
||||
/// ## Using a `FnMut` parameter
|
||||
///
|
||||
/// ```
|
||||
/// fn do_twice<F>(mut func: F)
|
||||
/// where F: FnMut()
|
||||
/// {
|
||||
/// func();
|
||||
/// func();
|
||||
/// }
|
||||
///
|
||||
/// let mut x: usize = 1;
|
||||
/// {
|
||||
/// let add_two_to_x = || x += 2;
|
||||
/// do_twice(add_two_to_x);
|
||||
/// }
|
||||
///
|
||||
/// assert_eq!(x, 5);
|
||||
/// ```
|
||||
#[cfg(not(bootstrap))]
|
||||
#[lang = "fn_mut"]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_paren_sugar]
|
||||
|
@ -390,92 +219,6 @@ pub trait FnMut<Args: Tuple>: FnOnce<Args> {
|
|||
///
|
||||
/// // `consume_and_return_x` can no longer be invoked at this point
|
||||
/// ```
|
||||
#[cfg(bootstrap)]
|
||||
#[lang = "fn_once"]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_paren_sugar]
|
||||
#[rustc_on_unimplemented(
|
||||
on(
|
||||
Args = "()",
|
||||
note = "wrap the `{Self}` in a closure with no arguments: `|| {{ /* code */ }}`"
|
||||
),
|
||||
on(
|
||||
_Self = "unsafe fn",
|
||||
note = "unsafe function cannot be called generically without an unsafe block",
|
||||
// SAFETY: tidy is not smart enough to tell that the below unsafe block is a string
|
||||
label = "call the function in a closure: `|| unsafe {{ /* code */ }}`"
|
||||
),
|
||||
message = "expected a `{FnOnce}<{Args}>` closure, found `{Self}`",
|
||||
label = "expected an `FnOnce<{Args}>` closure, found `{Self}`"
|
||||
)]
|
||||
#[fundamental] // so that regex can rely that `&str: !FnMut`
|
||||
#[must_use = "closures are lazy and do nothing unless called"]
|
||||
#[const_trait]
|
||||
pub trait FnOnce<Args> {
|
||||
/// The returned type after the call operator is used.
|
||||
#[lang = "fn_once_output"]
|
||||
#[stable(feature = "fn_once_output", since = "1.12.0")]
|
||||
type Output;
|
||||
|
||||
/// Performs the call operation.
|
||||
#[unstable(feature = "fn_traits", issue = "29625")]
|
||||
extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
|
||||
}
|
||||
|
||||
/// The version of the call operator that takes a by-value receiver.
|
||||
///
|
||||
/// Instances of `FnOnce` can be called, but might not be callable multiple
|
||||
/// times. Because of this, if the only thing known about a type is that it
|
||||
/// implements `FnOnce`, it can only be called once.
|
||||
///
|
||||
/// `FnOnce` is implemented automatically by closures that might consume captured
|
||||
/// variables, as well as all types that implement [`FnMut`], e.g., (safe)
|
||||
/// [function pointers] (since `FnOnce` is a supertrait of [`FnMut`]).
|
||||
///
|
||||
/// Since both [`Fn`] and [`FnMut`] are subtraits of `FnOnce`, any instance of
|
||||
/// [`Fn`] or [`FnMut`] can be used where a `FnOnce` is expected.
|
||||
///
|
||||
/// Use `FnOnce` as a bound when you want to accept a parameter of function-like
|
||||
/// type and only need to call it once. If you need to call the parameter
|
||||
/// repeatedly, use [`FnMut`] as a bound; if you also need it to not mutate
|
||||
/// state, use [`Fn`].
|
||||
///
|
||||
/// See the [chapter on closures in *The Rust Programming Language*][book] for
|
||||
/// some more information on this topic.
|
||||
///
|
||||
/// Also of note is the special syntax for `Fn` traits (e.g.
|
||||
/// `Fn(usize, bool) -> usize`). Those interested in the technical details of
|
||||
/// this can refer to [the relevant section in the *Rustonomicon*][nomicon].
|
||||
///
|
||||
/// [book]: ../../book/ch13-01-closures.html
|
||||
/// [function pointers]: fn
|
||||
/// [nomicon]: ../../nomicon/hrtb.html
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ## Using a `FnOnce` parameter
|
||||
///
|
||||
/// ```
|
||||
/// fn consume_with_relish<F>(func: F)
|
||||
/// where F: FnOnce() -> String
|
||||
/// {
|
||||
/// // `func` consumes its captured variables, so it cannot be run more
|
||||
/// // than once.
|
||||
/// println!("Consumed: {}", func());
|
||||
///
|
||||
/// println!("Delicious!");
|
||||
///
|
||||
/// // Attempting to invoke `func()` again will throw a `use of moved
|
||||
/// // value` error for `func`.
|
||||
/// }
|
||||
///
|
||||
/// let x = String::from("x");
|
||||
/// let consume_and_return_x = move || x;
|
||||
/// consume_with_relish(consume_and_return_x);
|
||||
///
|
||||
/// // `consume_and_return_x` can no longer be invoked at this point
|
||||
/// ```
|
||||
#[cfg(not(bootstrap))]
|
||||
#[lang = "fn_once"]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_paren_sugar]
|
||||
|
@ -507,68 +250,6 @@ pub trait FnOnce<Args: Tuple> {
|
|||
extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
|
||||
}
|
||||
|
||||
#[cfg(bootstrap)]
|
||||
mod impls {
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_fn_trait_ref_impls", issue = "101803")]
|
||||
impl<A, F: ?Sized> const Fn<A> for &F
|
||||
where
|
||||
F: ~const Fn<A>,
|
||||
{
|
||||
extern "rust-call" fn call(&self, args: A) -> F::Output {
|
||||
(**self).call(args)
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_fn_trait_ref_impls", issue = "101803")]
|
||||
impl<A, F: ?Sized> const FnMut<A> for &F
|
||||
where
|
||||
F: ~const Fn<A>,
|
||||
{
|
||||
extern "rust-call" fn call_mut(&mut self, args: A) -> F::Output {
|
||||
(**self).call(args)
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_fn_trait_ref_impls", issue = "101803")]
|
||||
impl<A, F: ?Sized> const FnOnce<A> for &F
|
||||
where
|
||||
F: ~const Fn<A>,
|
||||
{
|
||||
type Output = F::Output;
|
||||
|
||||
extern "rust-call" fn call_once(self, args: A) -> F::Output {
|
||||
(*self).call(args)
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_fn_trait_ref_impls", issue = "101803")]
|
||||
impl<A, F: ?Sized> const FnMut<A> for &mut F
|
||||
where
|
||||
F: ~const FnMut<A>,
|
||||
{
|
||||
extern "rust-call" fn call_mut(&mut self, args: A) -> F::Output {
|
||||
(*self).call_mut(args)
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_fn_trait_ref_impls", issue = "101803")]
|
||||
impl<A, F: ?Sized> const FnOnce<A> for &mut F
|
||||
where
|
||||
F: ~const FnMut<A>,
|
||||
{
|
||||
type Output = F::Output;
|
||||
extern "rust-call" fn call_once(self, args: A) -> F::Output {
|
||||
(*self).call_mut(args)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(bootstrap))]
|
||||
mod impls {
|
||||
use crate::marker::Tuple;
|
||||
|
||||
|
|
|
@ -75,14 +75,12 @@ pub use crate::macros::builtin::{RustcDecodable, RustcEncodable};
|
|||
|
||||
// Do not `doc(no_inline)` so that they become doc items on their own
|
||||
// (no public module for them to be re-exported from).
|
||||
#[cfg(not(bootstrap))]
|
||||
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
|
||||
pub use crate::macros::builtin::alloc_error_handler;
|
||||
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
|
||||
pub use crate::macros::builtin::{bench, derive, global_allocator, test, test_case};
|
||||
pub use crate::macros::builtin::{
|
||||
alloc_error_handler, bench, derive, global_allocator, test, test_case,
|
||||
};
|
||||
|
||||
#[unstable(feature = "derive_const", issue = "none")]
|
||||
#[cfg(not(bootstrap))]
|
||||
pub use crate::macros::builtin::derive_const;
|
||||
|
||||
#[unstable(
|
||||
|
@ -104,5 +102,4 @@ pub use crate::macros::builtin::cfg_eval;
|
|||
issue = "23416",
|
||||
reason = "placeholder syntax for type ascription"
|
||||
)]
|
||||
#[cfg(not(bootstrap))]
|
||||
pub use crate::macros::builtin::type_ascribe;
|
||||
|
|
|
@ -10,8 +10,7 @@ use crate::{cmp, fmt, hash, mem, num};
|
|||
/// are likely not to be supported by actual allocators and linkers.
|
||||
#[unstable(feature = "ptr_alignment_type", issue = "102070")]
|
||||
#[derive(Copy, Clone, Eq)]
|
||||
#[cfg_attr(bootstrap, derive(PartialEq))]
|
||||
#[cfg_attr(not(bootstrap), derive_const(PartialEq))]
|
||||
#[derive_const(PartialEq)]
|
||||
#[repr(transparent)]
|
||||
pub struct Alignment(AlignmentEnum);
|
||||
|
||||
|
@ -203,8 +202,7 @@ type AlignmentEnum = AlignmentEnum32;
|
|||
type AlignmentEnum = AlignmentEnum64;
|
||||
|
||||
#[derive(Copy, Clone, Eq)]
|
||||
#[cfg_attr(bootstrap, derive(PartialEq))]
|
||||
#[cfg_attr(not(bootstrap), derive_const(PartialEq))]
|
||||
#[derive_const(PartialEq)]
|
||||
#[repr(u16)]
|
||||
enum AlignmentEnum16 {
|
||||
_Align1Shl0 = 1 << 0,
|
||||
|
@ -226,8 +224,7 @@ enum AlignmentEnum16 {
|
|||
}
|
||||
|
||||
#[derive(Copy, Clone, Eq)]
|
||||
#[cfg_attr(bootstrap, derive(PartialEq))]
|
||||
#[cfg_attr(not(bootstrap), derive_const(PartialEq))]
|
||||
#[derive_const(PartialEq)]
|
||||
#[repr(u32)]
|
||||
enum AlignmentEnum32 {
|
||||
_Align1Shl0 = 1 << 0,
|
||||
|
@ -265,8 +262,7 @@ enum AlignmentEnum32 {
|
|||
}
|
||||
|
||||
#[derive(Copy, Clone, Eq)]
|
||||
#[cfg_attr(bootstrap, derive(PartialEq))]
|
||||
#[cfg_attr(not(bootstrap), derive_const(PartialEq))]
|
||||
#[derive_const(PartialEq)]
|
||||
#[repr(u64)]
|
||||
enum AlignmentEnum64 {
|
||||
_Align1Shl0 = 1 << 0,
|
||||
|
|
|
@ -1350,26 +1350,6 @@ impl<T: ?Sized> *const T {
|
|||
panic!("align_offset: align is not a power-of-two");
|
||||
}
|
||||
|
||||
#[cfg(bootstrap)]
|
||||
{
|
||||
fn rt_impl<T>(p: *const T, align: usize) -> usize {
|
||||
// SAFETY: `align` has been checked to be a power of 2 above
|
||||
unsafe { align_offset(p, align) }
|
||||
}
|
||||
|
||||
const fn ctfe_impl<T>(_: *const T, _: usize) -> usize {
|
||||
usize::MAX
|
||||
}
|
||||
|
||||
// SAFETY:
|
||||
// It is permissible for `align_offset` to always return `usize::MAX`,
|
||||
// algorithm correctness can not depend on `align_offset` returning non-max values.
|
||||
//
|
||||
// As such the behaviour can't change after replacing `align_offset` with `usize::MAX`, only performance can.
|
||||
unsafe { intrinsics::const_eval_select((self, align), ctfe_impl, rt_impl) }
|
||||
}
|
||||
|
||||
#[cfg(not(bootstrap))]
|
||||
{
|
||||
// SAFETY: `align` has been checked to be a power of 2 above
|
||||
unsafe { align_offset(self, align) }
|
||||
|
@ -1406,8 +1386,7 @@ impl<T: ?Sized> *const T {
|
|||
/// is never aligned if cast to a type with a stricter alignment than the reference's
|
||||
/// underlying allocation.
|
||||
///
|
||||
#[cfg_attr(bootstrap, doc = "```ignore")]
|
||||
#[cfg_attr(not(bootstrap), doc = "```")]
|
||||
/// ```
|
||||
/// #![feature(pointer_is_aligned)]
|
||||
/// #![feature(const_pointer_is_aligned)]
|
||||
///
|
||||
|
@ -1433,8 +1412,7 @@ impl<T: ?Sized> *const T {
|
|||
/// Due to this behavior, it is possible that a runtime pointer derived from a compiletime
|
||||
/// pointer is aligned, even if the compiletime pointer wasn't aligned.
|
||||
///
|
||||
#[cfg_attr(bootstrap, doc = "```ignore")]
|
||||
#[cfg_attr(not(bootstrap), doc = "```")]
|
||||
/// ```
|
||||
/// #![feature(pointer_is_aligned)]
|
||||
/// #![feature(const_pointer_is_aligned)]
|
||||
///
|
||||
|
@ -1460,8 +1438,7 @@ impl<T: ?Sized> *const T {
|
|||
/// If a pointer is created from a fixed address, this function behaves the same during
|
||||
/// runtime and compiletime.
|
||||
///
|
||||
#[cfg_attr(bootstrap, doc = "```ignore")]
|
||||
#[cfg_attr(not(bootstrap), doc = "```")]
|
||||
/// ```
|
||||
/// #![feature(pointer_is_aligned)]
|
||||
/// #![feature(const_pointer_is_aligned)]
|
||||
///
|
||||
|
@ -1537,8 +1514,7 @@ impl<T: ?Sized> *const T {
|
|||
/// return `true` if the pointer is guaranteed to be aligned. This means that the pointer
|
||||
/// cannot be stricter aligned than the reference's underlying allocation.
|
||||
///
|
||||
#[cfg_attr(bootstrap, doc = "```ignore")]
|
||||
#[cfg_attr(not(bootstrap), doc = "```")]
|
||||
/// ```
|
||||
/// #![feature(pointer_is_aligned)]
|
||||
/// #![feature(const_pointer_is_aligned)]
|
||||
///
|
||||
|
@ -1563,8 +1539,7 @@ impl<T: ?Sized> *const T {
|
|||
/// Due to this behavior, it is possible that a runtime pointer derived from a compiletime
|
||||
/// pointer is aligned, even if the compiletime pointer wasn't aligned.
|
||||
///
|
||||
#[cfg_attr(bootstrap, doc = "```ignore")]
|
||||
#[cfg_attr(not(bootstrap), doc = "```")]
|
||||
/// ```
|
||||
/// #![feature(pointer_is_aligned)]
|
||||
/// #![feature(const_pointer_is_aligned)]
|
||||
///
|
||||
|
@ -1588,8 +1563,7 @@ impl<T: ?Sized> *const T {
|
|||
/// If a pointer is created from a fixed address, this function behaves the same during
|
||||
/// runtime and compiletime.
|
||||
///
|
||||
#[cfg_attr(bootstrap, doc = "```ignore")]
|
||||
#[cfg_attr(not(bootstrap), doc = "```")]
|
||||
/// ```
|
||||
/// #![feature(pointer_is_aligned)]
|
||||
/// #![feature(const_pointer_is_aligned)]
|
||||
///
|
||||
|
|
|
@ -50,7 +50,7 @@ use crate::hash::{Hash, Hasher};
|
|||
///
|
||||
/// [`to_raw_parts`]: *const::to_raw_parts
|
||||
#[lang = "pointee_trait"]
|
||||
#[cfg_attr(not(bootstrap), rustc_deny_explicit_impl)]
|
||||
#[rustc_deny_explicit_impl]
|
||||
pub trait Pointee {
|
||||
/// The type for metadata in pointers and references to `Self`.
|
||||
#[lang = "metadata_type"]
|
||||
|
|
|
@ -1618,26 +1618,6 @@ impl<T: ?Sized> *mut T {
|
|||
panic!("align_offset: align is not a power-of-two");
|
||||
}
|
||||
|
||||
#[cfg(bootstrap)]
|
||||
{
|
||||
fn rt_impl<T>(p: *mut T, align: usize) -> usize {
|
||||
// SAFETY: `align` has been checked to be a power of 2 above
|
||||
unsafe { align_offset(p, align) }
|
||||
}
|
||||
|
||||
const fn ctfe_impl<T>(_: *mut T, _: usize) -> usize {
|
||||
usize::MAX
|
||||
}
|
||||
|
||||
// SAFETY:
|
||||
// It is permissible for `align_offset` to always return `usize::MAX`,
|
||||
// algorithm correctness can not depend on `align_offset` returning non-max values.
|
||||
//
|
||||
// As such the behaviour can't change after replacing `align_offset` with `usize::MAX`, only performance can.
|
||||
unsafe { intrinsics::const_eval_select((self, align), ctfe_impl, rt_impl) }
|
||||
}
|
||||
|
||||
#[cfg(not(bootstrap))]
|
||||
{
|
||||
// SAFETY: `align` has been checked to be a power of 2 above
|
||||
unsafe { align_offset(self, align) }
|
||||
|
@ -1674,8 +1654,7 @@ impl<T: ?Sized> *mut T {
|
|||
/// is never aligned if cast to a type with a stricter alignment than the reference's
|
||||
/// underlying allocation.
|
||||
///
|
||||
#[cfg_attr(bootstrap, doc = "```ignore")]
|
||||
#[cfg_attr(not(bootstrap), doc = "```")]
|
||||
/// ```
|
||||
/// #![feature(pointer_is_aligned)]
|
||||
/// #![feature(const_pointer_is_aligned)]
|
||||
/// #![feature(const_mut_refs)]
|
||||
|
@ -1702,8 +1681,7 @@ impl<T: ?Sized> *mut T {
|
|||
/// Due to this behavior, it is possible that a runtime pointer derived from a compiletime
|
||||
/// pointer is aligned, even if the compiletime pointer wasn't aligned.
|
||||
///
|
||||
#[cfg_attr(bootstrap, doc = "```ignore")]
|
||||
#[cfg_attr(not(bootstrap), doc = "```")]
|
||||
/// ```
|
||||
/// #![feature(pointer_is_aligned)]
|
||||
/// #![feature(const_pointer_is_aligned)]
|
||||
///
|
||||
|
@ -1730,8 +1708,7 @@ impl<T: ?Sized> *mut T {
|
|||
/// If a pointer is created from a fixed address, this function behaves the same during
|
||||
/// runtime and compiletime.
|
||||
///
|
||||
#[cfg_attr(bootstrap, doc = "```ignore")]
|
||||
#[cfg_attr(not(bootstrap), doc = "```")]
|
||||
/// ```
|
||||
/// #![feature(pointer_is_aligned)]
|
||||
/// #![feature(const_pointer_is_aligned)]
|
||||
///
|
||||
|
@ -1807,8 +1784,7 @@ impl<T: ?Sized> *mut T {
|
|||
/// return `true` if the pointer is guaranteed to be aligned. This means that the pointer
|
||||
/// cannot be stricter aligned than the reference's underlying allocation.
|
||||
///
|
||||
#[cfg_attr(bootstrap, doc = "```ignore")]
|
||||
#[cfg_attr(not(bootstrap), doc = "```")]
|
||||
/// ```
|
||||
/// #![feature(pointer_is_aligned)]
|
||||
/// #![feature(const_pointer_is_aligned)]
|
||||
/// #![feature(const_mut_refs)]
|
||||
|
@ -1834,8 +1810,7 @@ impl<T: ?Sized> *mut T {
|
|||
/// Due to this behavior, it is possible that a runtime pointer derived from a compiletime
|
||||
/// pointer is aligned, even if the compiletime pointer wasn't aligned.
|
||||
///
|
||||
#[cfg_attr(bootstrap, doc = "```ignore")]
|
||||
#[cfg_attr(not(bootstrap), doc = "```")]
|
||||
/// ```
|
||||
/// #![feature(pointer_is_aligned)]
|
||||
/// #![feature(const_pointer_is_aligned)]
|
||||
///
|
||||
|
@ -1860,8 +1835,7 @@ impl<T: ?Sized> *mut T {
|
|||
/// If a pointer is created from a fixed address, this function behaves the same during
|
||||
/// runtime and compiletime.
|
||||
///
|
||||
#[cfg_attr(bootstrap, doc = "```ignore")]
|
||||
#[cfg_attr(not(bootstrap), doc = "```")]
|
||||
/// ```
|
||||
/// #![feature(pointer_is_aligned)]
|
||||
/// #![feature(const_pointer_is_aligned)]
|
||||
///
|
||||
|
|
|
@ -9,7 +9,7 @@ use crate::task::Ready;
|
|||
/// scheduled to receive a wakeup instead.
|
||||
#[must_use = "this `Poll` may be a `Pending` variant, which should be handled"]
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
||||
#[cfg_attr(not(bootstrap), lang = "Poll")]
|
||||
#[lang = "Poll"]
|
||||
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||
pub enum Poll<T> {
|
||||
/// Represents that a value is immediately ready.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue