/// allocations.
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
- fn clone_from(&mut self, source: &Self) {
+ #[default_method_body_is_const]
+ fn clone_from(&mut self, source: &Self)
+ where
+ Self: ~const Drop,
+ {
*self = source.clone()
}
}
($($t:ty)*) => {
$(
#[stable(feature = "rust1", since = "1.0.0")]
- impl Clone for $t {
+ #[rustc_const_unstable(feature = "const_clone", issue = "91805")]
+ impl const Clone for $t {
#[inline]
fn clone(&self) -> Self {
*self
}
#[unstable(feature = "never_type", issue = "35121")]
- impl Clone for ! {
+ #[rustc_const_unstable(feature = "const_clone", issue = "91805")]
+ impl const Clone for ! {
#[inline]
fn clone(&self) -> Self {
*self
}
#[stable(feature = "rust1", since = "1.0.0")]
- impl<T: ?Sized> Clone for *const T {
+ #[rustc_const_unstable(feature = "const_clone", issue = "91805")]
+ impl<T: ?Sized> const Clone for *const T {
#[inline]
fn clone(&self) -> Self {
*self
}
#[stable(feature = "rust1", since = "1.0.0")]
- impl<T: ?Sized> Clone for *mut T {
+ #[rustc_const_unstable(feature = "const_clone", issue = "91805")]
+ impl<T: ?Sized> const Clone for *mut T {
#[inline]
fn clone(&self) -> Self {
*self
/// Shared references can be cloned, but mutable references *cannot*!
#[stable(feature = "rust1", since = "1.0.0")]
- impl<T: ?Sized> Clone for &T {
+ #[rustc_const_unstable(feature = "const_clone", issue = "91805")]
+ impl<T: ?Sized> const Clone for &T {
#[inline]
#[rustc_diagnostic_item = "noop_method_clone"]
fn clone(&self) -> Self {
pub enum Infallible {}
#[stable(feature = "convert_infallible", since = "1.34.0")]
-impl Clone for Infallible {
+#[rustc_const_unstable(feature = "const_clone", issue = "91805")]
+impl const Clone for Infallible {
fn clone(&self) -> Infallible {
match *self {}
}
#![feature(const_caller_location)]
#![feature(const_cell_into_inner)]
#![feature(const_char_convert)]
+#![feature(const_clone)]
#![feature(const_discriminant)]
#![feature(const_eval_select)]
#![feature(const_float_bits_conv)]
/////////////////////////////////////////////////////////////////////////////
#[stable(feature = "rust1", since = "1.0.0")]
-impl<T: Clone> Clone for Option<T> {
+#[rustc_const_unstable(feature = "const_clone", issue = "91805")]
+impl<T> const Clone for Option<T>
+where
+ T: ~const Clone + ~const Drop,
+{
#[inline]
fn clone(&self) -> Self {
match self {
}
#[stable(feature = "nonnull", since = "1.25.0")]
-impl<T: ?Sized> Clone for NonNull<T> {
+#[rustc_const_unstable(feature = "const_clone", issue = "91805")]
+impl<T: ?Sized> const Clone for NonNull<T> {
#[inline]
fn clone(&self) -> Self {
*self
}
#[unstable(feature = "ptr_internals", issue = "none")]
-impl<T: ?Sized> Clone for Unique<T> {
+#[rustc_const_unstable(feature = "const_clone", issue = "91805")]
+impl<T: ?Sized> const Clone for Unique<T> {
#[inline]
fn clone(&self) -> Self {
*self
/////////////////////////////////////////////////////////////////////////////
#[stable(feature = "rust1", since = "1.0.0")]
-impl<T: Clone, E: Clone> Clone for Result<T, E> {
+#[rustc_const_unstable(feature = "const_clone", issue = "91805")]
+impl<T, E> const Clone for Result<T, E>
+where
+ T: ~const Clone + ~const Drop,
+ E: ~const Clone + ~const Drop,
+{
#[inline]
fn clone(&self) -> Self {
match self {