Rename ~const Drop
to ~const Destruct
This commit is contained in:
parent
4df2a28aee
commit
1f3ee7f32e
32 changed files with 296 additions and 192 deletions
|
@ -14,6 +14,8 @@ use core::ptr::{self, NonNull};
|
|||
#[doc(inline)]
|
||||
pub use core::alloc::*;
|
||||
|
||||
use core::marker::Destruct;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
|
@ -324,12 +326,16 @@ unsafe fn exchange_malloc(size: usize, align: usize) -> *mut u8 {
|
|||
#[cfg_attr(not(test), lang = "box_free")]
|
||||
#[inline]
|
||||
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
|
||||
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
|
||||
// This signature has to be the same as `Box`, otherwise an ICE will happen.
|
||||
// When an additional parameter to `Box` is added (like `A: Allocator`), this has to be added here as
|
||||
// well.
|
||||
// For example if `Box` is changed to `struct Box<T: ?Sized, A: Allocator>(Unique<T>, A)`,
|
||||
// this function has to be changed to `fn box_free<T: ?Sized, A: Allocator>(Unique<T>, A)` as well.
|
||||
pub(crate) const unsafe fn box_free<T: ?Sized, A: ~const Allocator + ~const Drop>(
|
||||
pub(crate) const unsafe fn box_free<
|
||||
T: ?Sized,
|
||||
A: ~const Allocator + ~const Drop + ~const Destruct,
|
||||
>(
|
||||
ptr: Unique<T>,
|
||||
alloc: A,
|
||||
) {
|
||||
|
|
|
@ -331,6 +331,7 @@ impl<B: ?Sized + ToOwned> Cow<'_, B> {
|
|||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_deref", issue = "88955")]
|
||||
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
|
||||
impl<B: ?Sized + ToOwned> const Deref for Cow<'_, B>
|
||||
where
|
||||
B::Owned: ~const Borrow<B>,
|
||||
|
|
|
@ -143,7 +143,7 @@ use core::hash::{Hash, Hasher};
|
|||
#[cfg(not(no_global_oom_handling))]
|
||||
use core::iter::FromIterator;
|
||||
use core::iter::{FusedIterator, Iterator};
|
||||
use core::marker::{Unpin, Unsize};
|
||||
use core::marker::{Destruct, Unpin, Unsize};
|
||||
use core::mem;
|
||||
use core::ops::{
|
||||
CoerceUnsized, Deref, DerefMut, DispatchFromDyn, Generator, GeneratorState, Receiver,
|
||||
|
@ -349,9 +349,10 @@ impl<T, A: Allocator> Box<T, A> {
|
|||
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
|
||||
pub const fn new_in(x: T, alloc: A) -> Self
|
||||
where
|
||||
A: ~const Allocator + ~const Drop,
|
||||
A: ~const Allocator + ~const Drop + ~const Destruct,
|
||||
{
|
||||
let mut boxed = Self::new_uninit_in(alloc);
|
||||
unsafe {
|
||||
|
@ -378,10 +379,11 @@ impl<T, A: Allocator> Box<T, A> {
|
|||
#[unstable(feature = "allocator_api", issue = "32838")]
|
||||
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
|
||||
#[inline]
|
||||
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
|
||||
pub const fn try_new_in(x: T, alloc: A) -> Result<Self, AllocError>
|
||||
where
|
||||
T: ~const Drop,
|
||||
A: ~const Allocator + ~const Drop,
|
||||
T: ~const Drop + ~const Destruct,
|
||||
A: ~const Allocator + ~const Drop + ~const Destruct,
|
||||
{
|
||||
let mut boxed = Self::try_new_uninit_in(alloc)?;
|
||||
unsafe {
|
||||
|
@ -415,9 +417,10 @@ impl<T, A: Allocator> Box<T, A> {
|
|||
#[cfg(not(no_global_oom_handling))]
|
||||
#[must_use]
|
||||
// #[unstable(feature = "new_uninit", issue = "63291")]
|
||||
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
|
||||
pub const fn new_uninit_in(alloc: A) -> Box<mem::MaybeUninit<T>, A>
|
||||
where
|
||||
A: ~const Allocator + ~const Drop,
|
||||
A: ~const Allocator + ~const Drop + ~const Destruct,
|
||||
{
|
||||
let layout = Layout::new::<mem::MaybeUninit<T>>();
|
||||
// NOTE: Prefer match over unwrap_or_else since closure sometimes not inlineable.
|
||||
|
@ -453,9 +456,10 @@ impl<T, A: Allocator> Box<T, A> {
|
|||
#[unstable(feature = "allocator_api", issue = "32838")]
|
||||
// #[unstable(feature = "new_uninit", issue = "63291")]
|
||||
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
|
||||
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
|
||||
pub const fn try_new_uninit_in(alloc: A) -> Result<Box<mem::MaybeUninit<T>, A>, AllocError>
|
||||
where
|
||||
A: ~const Allocator + ~const Drop,
|
||||
A: ~const Allocator + ~const Drop + ~const Destruct,
|
||||
{
|
||||
let layout = Layout::new::<mem::MaybeUninit<T>>();
|
||||
let ptr = alloc.allocate(layout)?.cast();
|
||||
|
@ -487,9 +491,10 @@ impl<T, A: Allocator> Box<T, A> {
|
|||
#[cfg(not(no_global_oom_handling))]
|
||||
// #[unstable(feature = "new_uninit", issue = "63291")]
|
||||
#[must_use]
|
||||
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
|
||||
pub const fn new_zeroed_in(alloc: A) -> Box<mem::MaybeUninit<T>, A>
|
||||
where
|
||||
A: ~const Allocator + ~const Drop,
|
||||
A: ~const Allocator + ~const Drop + ~const Destruct,
|
||||
{
|
||||
let layout = Layout::new::<mem::MaybeUninit<T>>();
|
||||
// NOTE: Prefer match over unwrap_or_else since closure sometimes not inlineable.
|
||||
|
@ -525,9 +530,10 @@ impl<T, A: Allocator> Box<T, A> {
|
|||
#[unstable(feature = "allocator_api", issue = "32838")]
|
||||
// #[unstable(feature = "new_uninit", issue = "63291")]
|
||||
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
|
||||
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
|
||||
pub const fn try_new_zeroed_in(alloc: A) -> Result<Box<mem::MaybeUninit<T>, A>, AllocError>
|
||||
where
|
||||
A: ~const Allocator + ~const Drop,
|
||||
A: ~const Allocator + ~const Drop + ~const Destruct,
|
||||
{
|
||||
let layout = Layout::new::<mem::MaybeUninit<T>>();
|
||||
let ptr = alloc.allocate_zeroed(layout)?.cast();
|
||||
|
@ -541,9 +547,10 @@ impl<T, A: Allocator> Box<T, A> {
|
|||
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
|
||||
#[must_use]
|
||||
#[inline(always)]
|
||||
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
|
||||
pub const fn pin_in(x: T, alloc: A) -> Pin<Self>
|
||||
where
|
||||
A: 'static + ~const Allocator + ~const Drop,
|
||||
A: 'static + ~const Allocator + ~const Drop + ~const Destruct,
|
||||
{
|
||||
Self::into_pin(Self::new_in(x, alloc))
|
||||
}
|
||||
|
@ -572,9 +579,10 @@ impl<T, A: Allocator> Box<T, A> {
|
|||
#[unstable(feature = "box_into_inner", issue = "80437")]
|
||||
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
|
||||
#[inline]
|
||||
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
|
||||
pub const fn into_inner(boxed: Self) -> T
|
||||
where
|
||||
Self: ~const Drop,
|
||||
Self: ~const Drop + ~const Destruct,
|
||||
{
|
||||
*boxed
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
//! impl bool {}
|
||||
|
||||
use crate::marker::Destruct;
|
||||
|
||||
#[lang = "bool"]
|
||||
impl bool {
|
||||
/// Returns `Some(t)` if the `bool` is [`true`](../std/keyword.true.html),
|
||||
|
@ -16,9 +18,10 @@ impl bool {
|
|||
#[unstable(feature = "bool_to_option", issue = "80967")]
|
||||
#[rustc_const_unstable(feature = "const_bool_to_option", issue = "91917")]
|
||||
#[inline]
|
||||
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
|
||||
pub const fn then_some<T>(self, t: T) -> Option<T>
|
||||
where
|
||||
T: ~const Drop,
|
||||
T: ~const Drop + ~const Destruct,
|
||||
{
|
||||
if self { Some(t) } else { None }
|
||||
}
|
||||
|
@ -35,10 +38,11 @@ impl bool {
|
|||
#[stable(feature = "lazy_bool_to_option", since = "1.50.0")]
|
||||
#[rustc_const_unstable(feature = "const_bool_to_option", issue = "91917")]
|
||||
#[inline]
|
||||
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
|
||||
pub const fn then<T, F>(self, f: F) -> Option<T>
|
||||
where
|
||||
F: ~const FnOnce() -> T,
|
||||
F: ~const Drop,
|
||||
F: ~const Drop + ~const Destruct,
|
||||
{
|
||||
if self { Some(f()) } else { None }
|
||||
}
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
|
||||
#![stable(feature = "rust1", since = "1.0.0")]
|
||||
|
||||
use crate::marker::Destruct;
|
||||
|
||||
/// A common trait for the ability to explicitly duplicate an object.
|
||||
///
|
||||
/// Differs from [`Copy`] in that [`Copy`] is implicit and an inexpensive bit-wise copy, while
|
||||
|
@ -128,9 +130,10 @@ pub trait Clone: Sized {
|
|||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[default_method_body_is_const]
|
||||
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
|
||||
fn clone_from(&mut self, source: &Self)
|
||||
where
|
||||
Self: ~const Drop,
|
||||
Self: ~const Drop + ~const Destruct,
|
||||
{
|
||||
*self = source.clone()
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
)]
|
||||
#![allow(missing_docs)]
|
||||
|
||||
use crate::marker::DiscriminantKind;
|
||||
use crate::marker::{Destruct, DiscriminantKind};
|
||||
use crate::mem;
|
||||
|
||||
// These imports are used for simplifying intra-doc links
|
||||
|
@ -2353,6 +2353,7 @@ pub const unsafe fn write_bytes<T>(dst: *mut T, val: u8, count: usize) {
|
|||
#[rustc_const_unstable(feature = "const_eval_select", issue = "none")]
|
||||
#[lang = "const_eval_select"]
|
||||
#[rustc_do_not_const_check]
|
||||
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
|
||||
pub const unsafe fn const_eval_select<ARG, F, G, RET>(
|
||||
arg: ARG,
|
||||
_called_in_const: F,
|
||||
|
@ -2360,7 +2361,7 @@ pub const unsafe fn const_eval_select<ARG, F, G, RET>(
|
|||
) -> RET
|
||||
where
|
||||
F: ~const FnOnce<ARG, Output = RET>,
|
||||
G: FnOnce<ARG, Output = RET> + ~const Drop,
|
||||
G: FnOnce<ARG, Output = RET> + ~const Drop + ~const Destruct,
|
||||
{
|
||||
called_at_rt.call_once(arg)
|
||||
}
|
||||
|
@ -2372,6 +2373,7 @@ where
|
|||
)]
|
||||
#[rustc_const_unstable(feature = "const_eval_select", issue = "none")]
|
||||
#[lang = "const_eval_select_ct"]
|
||||
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
|
||||
pub const unsafe fn const_eval_select_ct<ARG, F, G, RET>(
|
||||
arg: ARG,
|
||||
called_in_const: F,
|
||||
|
@ -2379,7 +2381,7 @@ pub const unsafe fn const_eval_select_ct<ARG, F, G, RET>(
|
|||
) -> RET
|
||||
where
|
||||
F: ~const FnOnce<ARG, Output = RET>,
|
||||
G: FnOnce<ARG, Output = RET> + ~const Drop,
|
||||
G: FnOnce<ARG, Output = RET> + ~const Drop + ~const Destruct,
|
||||
{
|
||||
called_in_const.call_once(arg)
|
||||
}
|
||||
|
|
|
@ -794,10 +794,19 @@ impl<T: ?Sized> Unpin for *mut T {}
|
|||
|
||||
/// A marker for types that can be dropped.
|
||||
///
|
||||
/// The compiler logic for this trait is currently unimplemented.
|
||||
/// This should be used for `~const` bounds,
|
||||
/// as non-const bounds will always hold for every type.
|
||||
#[unstable(feature = "const_trait_impl", issue = "67792")]
|
||||
#[cfg_attr(not(bootstrap), lang = "destructible")]
|
||||
pub trait Destructible {}
|
||||
#[cfg_attr(not(bootstrap), lang = "destruct")]
|
||||
#[cfg_attr(
|
||||
not(bootstrap),
|
||||
rustc_on_unimplemented(message = "can't drop `{Self}`", append_const_msg,)
|
||||
)]
|
||||
pub trait Destruct {}
|
||||
|
||||
#[cfg(bootstrap)]
|
||||
#[unstable(feature = "const_trait_impl", issue = "67792")]
|
||||
impl<T: ?Sized> const Destruct for T {}
|
||||
|
||||
/// Implementations of `Copy` for primitive types.
|
||||
///
|
||||
|
|
|
@ -503,6 +503,7 @@
|
|||
#![stable(feature = "rust1", since = "1.0.0")]
|
||||
|
||||
use crate::iter::{self, FromIterator, FusedIterator, TrustedLen};
|
||||
use crate::marker::Destruct;
|
||||
use crate::panicking::{panic, panic_str};
|
||||
use crate::pin::Pin;
|
||||
use crate::{
|
||||
|
@ -772,9 +773,10 @@ impl<T> Option<T> {
|
|||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
|
||||
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
|
||||
pub const fn unwrap_or(self, default: T) -> T
|
||||
where
|
||||
T: ~const Drop,
|
||||
T: ~const Drop + ~const Destruct,
|
||||
{
|
||||
match self {
|
||||
Some(x) => x,
|
||||
|
@ -794,10 +796,11 @@ impl<T> Option<T> {
|
|||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
|
||||
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
|
||||
pub const fn unwrap_or_else<F>(self, f: F) -> T
|
||||
where
|
||||
F: ~const FnOnce() -> T,
|
||||
F: ~const Drop,
|
||||
F: ~const Drop + ~const Destruct,
|
||||
{
|
||||
match self {
|
||||
Some(x) => x,
|
||||
|
@ -899,10 +902,11 @@ impl<T> Option<T> {
|
|||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
|
||||
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
|
||||
pub const fn map<U, F>(self, f: F) -> Option<U>
|
||||
where
|
||||
F: ~const FnOnce(T) -> U,
|
||||
F: ~const Drop,
|
||||
F: ~const Drop + ~const Destruct,
|
||||
{
|
||||
match self {
|
||||
Some(x) => Some(f(x)),
|
||||
|
@ -928,10 +932,11 @@ impl<T> Option<T> {
|
|||
#[inline]
|
||||
#[unstable(feature = "result_option_inspect", issue = "91345")]
|
||||
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
|
||||
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
|
||||
pub const fn inspect<F>(self, f: F) -> Self
|
||||
where
|
||||
F: ~const FnOnce(&T),
|
||||
F: ~const Drop,
|
||||
F: ~const Drop + ~const Destruct,
|
||||
{
|
||||
if let Some(ref x) = self {
|
||||
f(x);
|
||||
|
@ -961,11 +966,12 @@ impl<T> Option<T> {
|
|||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
|
||||
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
|
||||
pub const fn map_or<U, F>(self, default: U, f: F) -> U
|
||||
where
|
||||
F: ~const FnOnce(T) -> U,
|
||||
F: ~const Drop,
|
||||
U: ~const Drop,
|
||||
F: ~const Drop + ~const Destruct,
|
||||
U: ~const Drop + ~const Destruct,
|
||||
{
|
||||
match self {
|
||||
Some(t) => f(t),
|
||||
|
@ -990,12 +996,13 @@ impl<T> Option<T> {
|
|||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
|
||||
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
|
||||
pub const fn map_or_else<U, D, F>(self, default: D, f: F) -> U
|
||||
where
|
||||
D: ~const FnOnce() -> U,
|
||||
D: ~const Drop,
|
||||
D: ~const Drop + ~const Destruct,
|
||||
F: ~const FnOnce(T) -> U,
|
||||
F: ~const Drop,
|
||||
F: ~const Drop + ~const Destruct,
|
||||
{
|
||||
match self {
|
||||
Some(t) => f(t),
|
||||
|
@ -1027,9 +1034,10 @@ impl<T> Option<T> {
|
|||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
|
||||
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
|
||||
pub const fn ok_or<E>(self, err: E) -> Result<T, E>
|
||||
where
|
||||
E: ~const Drop,
|
||||
E: ~const Drop + ~const Destruct,
|
||||
{
|
||||
match self {
|
||||
Some(v) => Ok(v),
|
||||
|
@ -1056,10 +1064,11 @@ impl<T> Option<T> {
|
|||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
|
||||
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
|
||||
pub const fn ok_or_else<E, F>(self, err: F) -> Result<T, E>
|
||||
where
|
||||
F: ~const FnOnce() -> E,
|
||||
F: ~const Drop,
|
||||
F: ~const Drop + ~const Destruct,
|
||||
{
|
||||
match self {
|
||||
Some(v) => Ok(v),
|
||||
|
@ -1190,10 +1199,11 @@ impl<T> Option<T> {
|
|||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
|
||||
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
|
||||
pub const fn and<U>(self, optb: Option<U>) -> Option<U>
|
||||
where
|
||||
T: ~const Drop,
|
||||
U: ~const Drop,
|
||||
T: ~const Drop + ~const Destruct,
|
||||
U: ~const Drop + ~const Destruct,
|
||||
{
|
||||
match self {
|
||||
Some(_) => optb,
|
||||
|
@ -1232,10 +1242,11 @@ impl<T> Option<T> {
|
|||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
|
||||
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
|
||||
pub const fn and_then<U, F>(self, f: F) -> Option<U>
|
||||
where
|
||||
F: ~const FnOnce(T) -> Option<U>,
|
||||
F: ~const Drop,
|
||||
F: ~const Drop + ~const Destruct,
|
||||
{
|
||||
match self {
|
||||
Some(x) => f(x),
|
||||
|
@ -1270,11 +1281,12 @@ impl<T> Option<T> {
|
|||
#[inline]
|
||||
#[stable(feature = "option_filter", since = "1.27.0")]
|
||||
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
|
||||
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
|
||||
pub const fn filter<P>(self, predicate: P) -> Self
|
||||
where
|
||||
T: ~const Drop,
|
||||
T: ~const Drop + ~const Destruct,
|
||||
P: ~const FnOnce(&T) -> bool,
|
||||
P: ~const Drop,
|
||||
P: ~const Drop + ~const Destruct,
|
||||
{
|
||||
if let Some(x) = self {
|
||||
if predicate(&x) {
|
||||
|
@ -1314,9 +1326,10 @@ impl<T> Option<T> {
|
|||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
|
||||
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
|
||||
pub const fn or(self, optb: Option<T>) -> Option<T>
|
||||
where
|
||||
T: ~const Drop,
|
||||
T: ~const Drop + ~const Destruct,
|
||||
{
|
||||
match self {
|
||||
Some(x) => Some(x),
|
||||
|
@ -1340,10 +1353,11 @@ impl<T> Option<T> {
|
|||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
|
||||
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
|
||||
pub const fn or_else<F>(self, f: F) -> Option<T>
|
||||
where
|
||||
F: ~const FnOnce() -> Option<T>,
|
||||
F: ~const Drop,
|
||||
F: ~const Drop + ~const Destruct,
|
||||
{
|
||||
match self {
|
||||
Some(x) => Some(x),
|
||||
|
@ -1375,9 +1389,10 @@ impl<T> Option<T> {
|
|||
#[inline]
|
||||
#[stable(feature = "option_xor", since = "1.37.0")]
|
||||
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
|
||||
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
|
||||
pub const fn xor(self, optb: Option<T>) -> Option<T>
|
||||
where
|
||||
T: ~const Drop,
|
||||
T: ~const Drop + ~const Destruct,
|
||||
{
|
||||
match (self, optb) {
|
||||
(Some(a), None) => Some(a),
|
||||
|
@ -1413,9 +1428,10 @@ impl<T> Option<T> {
|
|||
#[inline]
|
||||
#[stable(feature = "option_insert", since = "1.53.0")]
|
||||
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
|
||||
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
|
||||
pub const fn insert(&mut self, value: T) -> &mut T
|
||||
where
|
||||
T: ~const Drop,
|
||||
T: ~const Drop + ~const Destruct,
|
||||
{
|
||||
*self = Some(value);
|
||||
|
||||
|
@ -1446,9 +1462,10 @@ impl<T> Option<T> {
|
|||
#[inline]
|
||||
#[stable(feature = "option_entry", since = "1.20.0")]
|
||||
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
|
||||
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
|
||||
pub const fn get_or_insert(&mut self, value: T) -> &mut T
|
||||
where
|
||||
T: ~const Drop,
|
||||
T: ~const Drop + ~const Destruct,
|
||||
{
|
||||
if let None = *self {
|
||||
*self = Some(value);
|
||||
|
@ -1513,10 +1530,11 @@ impl<T> Option<T> {
|
|||
#[inline]
|
||||
#[stable(feature = "option_entry", since = "1.20.0")]
|
||||
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
|
||||
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
|
||||
pub const fn get_or_insert_with<F>(&mut self, f: F) -> &mut T
|
||||
where
|
||||
F: ~const FnOnce() -> T,
|
||||
F: ~const Drop,
|
||||
F: ~const Drop + ~const Destruct,
|
||||
{
|
||||
if let None = *self {
|
||||
// the compiler isn't smart enough to know that we are not dropping a `T`
|
||||
|
@ -1627,10 +1645,11 @@ impl<T> Option<T> {
|
|||
/// ```
|
||||
#[stable(feature = "option_zip_option", since = "1.46.0")]
|
||||
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
|
||||
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
|
||||
pub const fn zip<U>(self, other: Option<U>) -> Option<(T, U)>
|
||||
where
|
||||
T: ~const Drop,
|
||||
U: ~const Drop,
|
||||
T: ~const Drop + ~const Destruct,
|
||||
U: ~const Drop + ~const Destruct,
|
||||
{
|
||||
match (self, other) {
|
||||
(Some(a), Some(b)) => Some((a, b)),
|
||||
|
@ -1668,12 +1687,13 @@ impl<T> Option<T> {
|
|||
/// ```
|
||||
#[unstable(feature = "option_zip", issue = "70086")]
|
||||
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
|
||||
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
|
||||
pub const fn zip_with<U, F, R>(self, other: Option<U>, f: F) -> Option<R>
|
||||
where
|
||||
F: ~const FnOnce(T, U) -> R,
|
||||
F: ~const Drop,
|
||||
T: ~const Drop,
|
||||
U: ~const Drop,
|
||||
F: ~const Drop + ~const Destruct,
|
||||
T: ~const Drop + ~const Destruct,
|
||||
U: ~const Drop + ~const Destruct,
|
||||
{
|
||||
match (self, other) {
|
||||
(Some(a), Some(b)) => Some(f(a, b)),
|
||||
|
@ -1860,9 +1880,10 @@ const fn expect_failed(msg: &str) -> ! {
|
|||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_clone", issue = "91805")]
|
||||
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
|
||||
impl<T> const Clone for Option<T>
|
||||
where
|
||||
T: ~const Clone + ~const Drop,
|
||||
T: ~const Clone + ~const Drop + ~const Destruct,
|
||||
{
|
||||
#[inline]
|
||||
fn clone(&self) -> Self {
|
||||
|
|
|
@ -490,6 +490,7 @@
|
|||
#![stable(feature = "rust1", since = "1.0.0")]
|
||||
|
||||
use crate::iter::{self, FromIterator, FusedIterator, TrustedLen};
|
||||
use crate::marker::Destruct;
|
||||
use crate::ops::{self, ControlFlow, Deref, DerefMut};
|
||||
use crate::{convert, fmt, hint};
|
||||
|
||||
|
@ -635,7 +636,7 @@ impl<T, E> Result<T, E> {
|
|||
#[rustc_const_unstable(feature = "const_result_drop", issue = "92384")]
|
||||
pub const fn ok(self) -> Option<T>
|
||||
where
|
||||
E: ~const Drop,
|
||||
E: ~const Drop + ~const Destruct,
|
||||
{
|
||||
match self {
|
||||
Ok(x) => Some(x),
|
||||
|
@ -666,7 +667,7 @@ impl<T, E> Result<T, E> {
|
|||
#[rustc_const_unstable(feature = "const_result_drop", issue = "92384")]
|
||||
pub const fn err(self) -> Option<E>
|
||||
where
|
||||
T: ~const Drop,
|
||||
T: ~const Drop + ~const Destruct,
|
||||
{
|
||||
match self {
|
||||
// FIXME: ~const Drop doesn't quite work right yet
|
||||
|
@ -1282,9 +1283,9 @@ impl<T, E> Result<T, E> {
|
|||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub const fn and<U>(self, res: Result<U, E>) -> Result<U, E>
|
||||
where
|
||||
T: ~const Drop,
|
||||
U: ~const Drop,
|
||||
E: ~const Drop,
|
||||
T: ~const Drop + ~const Destruct,
|
||||
U: ~const Drop + ~const Destruct,
|
||||
E: ~const Drop + ~const Destruct,
|
||||
{
|
||||
match self {
|
||||
// FIXME: ~const Drop doesn't quite work right yet
|
||||
|
@ -1367,9 +1368,9 @@ impl<T, E> Result<T, E> {
|
|||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub const fn or<F>(self, res: Result<T, F>) -> Result<T, F>
|
||||
where
|
||||
T: ~const Drop,
|
||||
E: ~const Drop,
|
||||
F: ~const Drop,
|
||||
T: ~const Drop + ~const Destruct,
|
||||
E: ~const Drop + ~const Destruct,
|
||||
F: ~const Drop + ~const Destruct,
|
||||
{
|
||||
match self {
|
||||
Ok(v) => Ok(v),
|
||||
|
@ -1431,8 +1432,8 @@ impl<T, E> Result<T, E> {
|
|||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub const fn unwrap_or(self, default: T) -> T
|
||||
where
|
||||
T: ~const Drop,
|
||||
E: ~const Drop,
|
||||
T: ~const Drop + ~const Destruct,
|
||||
E: ~const Drop + ~const Destruct,
|
||||
{
|
||||
match self {
|
||||
Ok(t) => t,
|
||||
|
@ -1802,10 +1803,11 @@ fn unwrap_failed<T>(_msg: &str, _error: &T) -> ! {
|
|||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_clone", issue = "91805")]
|
||||
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
|
||||
impl<T, E> const Clone for Result<T, E>
|
||||
where
|
||||
T: ~const Clone + ~const Drop,
|
||||
E: ~const Clone + ~const Drop,
|
||||
T: ~const Clone + ~const Drop + ~const Destruct,
|
||||
E: ~const Clone + ~const Drop + ~const Destruct,
|
||||
{
|
||||
#[inline]
|
||||
fn clone(&self) -> Self {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue