@@ -11,6 +11,7 @@ use crate::intrinsics::{exact_div, select_unpredictable, unchecked_sub};
11
11
use crate :: mem:: { self , SizedTypeProperties } ;
12
12
use crate :: num:: NonZero ;
13
13
use crate :: ops:: { Bound , OneSidedRange , Range , RangeBounds , RangeInclusive } ;
14
+ use crate :: panic:: const_panic;
14
15
use crate :: simd:: { self , Simd } ;
15
16
use crate :: ub_checks:: assert_unsafe_precondition;
16
17
use crate :: { fmt, hint, ptr, range, slice} ;
@@ -3703,8 +3704,9 @@ impl<T> [T] {
3703
3704
/// [`split_at_mut`]: slice::split_at_mut
3704
3705
#[ doc( alias = "memcpy" ) ]
3705
3706
#[ stable( feature = "copy_from_slice" , since = "1.9.0" ) ]
3707
+ #[ rustc_const_unstable( feature = "const_copy_from_slice" , issue = "131415" ) ]
3706
3708
#[ track_caller]
3707
- pub fn copy_from_slice ( & mut self , src : & [ T ] )
3709
+ pub const fn copy_from_slice ( & mut self , src : & [ T ] )
3708
3710
where
3709
3711
T : Copy ,
3710
3712
{
@@ -3713,11 +3715,13 @@ impl<T> [T] {
3713
3715
#[ cfg_attr( not( feature = "panic_immediate_abort" ) , inline( never) , cold) ]
3714
3716
#[ cfg_attr( feature = "panic_immediate_abort" , inline) ]
3715
3717
#[ track_caller]
3716
- fn len_mismatch_fail ( dst_len : usize , src_len : usize ) -> ! {
3717
- panic ! (
3718
- "source slice length ({}) does not match destination slice length ({})" ,
3719
- src_len, dst_len,
3720
- ) ;
3718
+ const fn len_mismatch_fail ( dst_len : usize , src_len : usize ) -> ! {
3719
+ const_panic ! (
3720
+ "copy_from_slice: source slice length does not match destination slice length" ,
3721
+ "copy_from_slice: source slice length ({src_len}) does not match destination slice length ({dst_len})" ,
3722
+ src_len: usize ,
3723
+ dst_len: usize ,
3724
+ )
3721
3725
}
3722
3726
3723
3727
if self . len ( ) != src. len ( ) {
0 commit comments