Skip to content

Commit ca9d7d5

Browse files
committed
Add test
1 parent 5ff4e2d commit ca9d7d5

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

library/core/src/clone.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,8 @@ pub macro Clone($item:item) {
258258
/// Use closures allow captured values to be automatically used.
259259
/// This is similar to have a closure that you would call `.use` over each captured value.
260260
#[unstable(feature = "ergonomic_clones", issue = "132290")]
261-
#[rustc_const_unstable(feature = "const_clone", issue = "142757")]
262-
#[const_trait]
263261
#[lang = "use_cloned"]
264-
pub trait UseCloned: ~const Clone {
262+
pub trait UseCloned: Clone {
265263
// Empty.
266264
}
267265

@@ -270,7 +268,7 @@ macro_rules! impl_use_cloned {
270268
$(
271269
#[unstable(feature = "ergonomic_clones", issue = "132290")]
272270
#[rustc_const_unstable(feature = "const_clone", issue = "142757")]
273-
impl const UseCloned for $t {}
271+
impl UseCloned for $t {}
274272
)*
275273
}
276274
}
@@ -565,7 +563,8 @@ mod impls {
565563
}
566564

567565
#[unstable(feature = "never_type", issue = "35121")]
568-
impl Clone for ! {
566+
#[rustc_const_unstable(feature = "const_clone", issue = "142757")]
567+
impl const Clone for ! {
569568
#[inline]
570569
fn clone(&self) -> Self {
571570
*self

tests/ui/traits/const-traits/const-traits-core.rs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
//@ run-pass
21
#![feature(
3-
const_trait_impl, const_default, ptr_alignment_type, ascii_char, f16, f128, sync_unsafe_cell,
2+
const_trait_impl, const_default, const_clone, ptr_alignment_type,
3+
ascii_char, f16, f128, sync_unsafe_cell,
44
)]
55
#![allow(dead_code)]
66
// core::default
@@ -43,4 +43,27 @@ const REF_CELL: std::cell::RefCell<()> = Default::default();
4343
const UNSAFE_CELL: std::cell::UnsafeCell<()> = Default::default();
4444
const SYNC_UNSAFE_CELL: std::cell::SyncUnsafeCell<()> = Default::default();
4545

46+
// core::clone
47+
const UNIT_CLONE: () = UNIT.clone();
48+
//~^ ERROR: the trait bound `(): const Clone` is not satisfied
49+
const BOOL_CLONE: bool = BOOL.clone();
50+
const CHAR_CLONE: char = CHAR.clone();
51+
const ASCII_CHAR_CLONE: std::ascii::Char = ASCII_CHAR.clone();
52+
//~^ ERROR: the trait bound `Char: const Clone` is not satisfied
53+
const USIZE_CLONE: usize = USIZE.clone();
54+
const U8_CLONE: u8 = U8.clone();
55+
const U16_CLONE: u16 = U16.clone();
56+
const U32_CLONE: u32 = U32.clone();
57+
const U64_CLONE: u64 = U64.clone();
58+
const U128_CLONE: u128 = U128.clone();
59+
const I8_CLONE: i8 = I8.clone();
60+
const I16_CLONE: i16 = I16.clone();
61+
const I32_CLONE: i32 = I32.clone();
62+
const I64_CLONE: i64 = I64.clone();
63+
const I128_CLONE: i128 = I128.clone();
64+
const F16_CLONE: f16 = F16.clone();
65+
const F32_CLONE: f32 = F32.clone();
66+
const F64_CLONE: f64 = F64.clone();
67+
const F128_CLONE: f128 = F128.clone();
68+
4669
fn main() {}

0 commit comments

Comments
 (0)