@@ -49,6 +49,7 @@ use core::iter::{FromIterator, FusedIterator};
4949use core:: ops:: Bound :: { Excluded , Included , Unbounded } ;
5050use core:: ops:: { self , Add , AddAssign , Index , IndexMut , Range , RangeBounds } ;
5151use core:: ptr;
52+ use core:: slice;
5253use core:: str:: { lossy, pattern:: Pattern } ;
5354
5455use crate :: borrow:: { Cow , ToOwned } ;
@@ -1510,14 +1511,14 @@ impl String {
15101511 // of the vector version. The data is just plain bytes.
15111512 // Because the range removal happens in Drop, if the Drain iterator is leaked,
15121513 // the removal will not happen.
1513- let Range { start, end } = range. assert_len ( self . len ( ) ) ;
1514+ let Range { start, end } = slice :: range ( range , .. self . len ( ) ) ;
15141515 assert ! ( self . is_char_boundary( start) ) ;
15151516 assert ! ( self . is_char_boundary( end) ) ;
15161517
15171518 // Take out two simultaneous borrows. The &mut String won't be accessed
15181519 // until iteration is over, in Drop.
15191520 let self_ptr = self as * mut _ ;
1520- // SAFETY: `assert_len ` and `is_char_boundary` do the appropriate bounds checks.
1521+ // SAFETY: `slice::range ` and `is_char_boundary` do the appropriate bounds checks.
15211522 let chars_iter = unsafe { self . get_unchecked ( start..end) } . chars ( ) ;
15221523
15231524 Drain { start, end, iter : chars_iter, string : self_ptr }
@@ -2174,6 +2175,7 @@ impl FromStr for String {
21742175/// implementation for free.
21752176///
21762177/// [`Display`]: fmt::Display
2178+ #[ cfg_attr( not( test) , rustc_diagnostic_item = "ToString" ) ]
21772179#[ stable( feature = "rust1" , since = "1.0.0" ) ]
21782180pub trait ToString {
21792181 /// Converts the given value to a `String`.
0 commit comments