Skip to content

Commit 5181002

Browse files
committedApr 23, 2018
Auto merge of #50182 - alexcrichton:beta-next, r=alexcrichton
[beta] Another round of backports This is a backport of: * #50039 * #50121
2 parents d7c60a1 + 1ca8ce9 commit 5181002

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+221
-55
lines changed
 

‎src/liballoc/tests/str.rs

+30
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,36 @@ fn test_str_get_maxinclusive() {
401401
}
402402
}
403403

404+
#[test]
405+
fn test_str_slice_rangetoinclusive_ok() {
406+
let s = "abcαβγ";
407+
assert_eq!(&s[..=2], "abc");
408+
assert_eq!(&s[..=4], "abcα");
409+
}
410+
411+
#[test]
412+
#[should_panic]
413+
fn test_str_slice_rangetoinclusive_notok() {
414+
let s = "abcαβγ";
415+
&s[..=3];
416+
}
417+
418+
#[test]
419+
fn test_str_slicemut_rangetoinclusive_ok() {
420+
let mut s = "abcαβγ".to_owned();
421+
let s: &mut str = &mut s;
422+
assert_eq!(&mut s[..=2], "abc");
423+
assert_eq!(&mut s[..=4], "abcα");
424+
}
425+
426+
#[test]
427+
#[should_panic]
428+
fn test_str_slicemut_rangetoinclusive_notok() {
429+
let mut s = "abcαβγ".to_owned();
430+
let s: &mut str = &mut s;
431+
&mut s[..=3];
432+
}
433+
404434
#[test]
405435
fn test_is_char_boundary() {
406436
let s = "ศไทย中华Việt Nam β-release 🐱123";

‎src/libcore/array.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ unsafe impl<T, A: Unsize<[T]>> FixedSizeArray<T> for A {
5959
}
6060

6161
/// The error type returned when a conversion from a slice to an array fails.
62-
#[stable(feature = "try_from", since = "1.26.0")]
62+
#[unstable(feature = "try_from", issue = "33417")]
6363
#[derive(Debug, Copy, Clone)]
6464
pub struct TryFromSliceError(());
6565

@@ -148,7 +148,7 @@ macro_rules! array_impls {
148148
}
149149
}
150150

151-
#[stable(feature = "try_from", since = "1.26.0")]
151+
#[unstable(feature = "try_from", issue = "33417")]
152152
impl<'a, T> TryFrom<&'a [T]> for &'a [T; $N] {
153153
type Error = TryFromSliceError;
154154

@@ -162,7 +162,7 @@ macro_rules! array_impls {
162162
}
163163
}
164164

165-
#[stable(feature = "try_from", since = "1.26.0")]
165+
#[unstable(feature = "try_from", issue = "33417")]
166166
impl<'a, T> TryFrom<&'a mut [T]> for &'a mut [T; $N] {
167167
type Error = TryFromSliceError;
168168

0 commit comments

Comments
 (0)