@@ -2383,7 +2383,6 @@ impl [u8] {
2383
2383
}
2384
2384
2385
2385
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2386
- #[ rustc_on_unimplemented = "slice indices are of type `usize` or ranges of `usize`" ]
2387
2386
impl < T , I > ops:: Index < I > for [ T ]
2388
2387
where I : SliceIndex < [ T ] >
2389
2388
{
@@ -2396,7 +2395,6 @@ impl<T, I> ops::Index<I> for [T]
2396
2395
}
2397
2396
2398
2397
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2399
- #[ rustc_on_unimplemented = "slice indices are of type `usize` or ranges of `usize`" ]
2400
2398
impl < T , I > ops:: IndexMut < I > for [ T ]
2401
2399
where I : SliceIndex < [ T ] >
2402
2400
{
@@ -2447,7 +2445,19 @@ mod private_slice_index {
2447
2445
2448
2446
/// A helper trait used for indexing operations.
2449
2447
#[ stable( feature = "slice_get_slice" , since = "1.28.0" ) ]
2450
- #[ rustc_on_unimplemented = "slice indices are of type `usize` or ranges of `usize`" ]
2448
+ #[ rustc_on_unimplemented(
2449
+ on(
2450
+ T = "str" ,
2451
+ label = "string indices are ranges of `usize`" ,
2452
+ ) ,
2453
+ on(
2454
+ all( any( T = "str" , T = "&str" , T = "std::string::String" ) , _Self="{integer}" ) ,
2455
+ note="you can use `.chars().nth()` or `.bytes().nth()`
2456
+ see chapter in The Book <https://doc.rust-lang.org/book/ch08-02-strings.html#indexing-into-strings>"
2457
+ ) ,
2458
+ message = "the type `{T}` cannot be indexed by `{Self}`" ,
2459
+ label = "slice indices are of type `usize` or ranges of `usize`" ,
2460
+ ) ]
2451
2461
pub trait SliceIndex < T : ?Sized > : private_slice_index:: Sealed {
2452
2462
/// The output type returned by methods.
2453
2463
#[ stable( feature = "slice_get_slice" , since = "1.28.0" ) ]
0 commit comments