@@ -2312,7 +2312,6 @@ impl [u8] {
2312
2312
}
2313
2313
2314
2314
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2315
- #[ rustc_on_unimplemented = "slice indices are of type `usize` or ranges of `usize`" ]
2316
2315
impl < T , I > ops:: Index < I > for [ T ]
2317
2316
where I : SliceIndex < [ T ] >
2318
2317
{
@@ -2325,7 +2324,6 @@ impl<T, I> ops::Index<I> for [T]
2325
2324
}
2326
2325
2327
2326
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2328
- #[ rustc_on_unimplemented = "slice indices are of type `usize` or ranges of `usize`" ]
2329
2327
impl < T , I > ops:: IndexMut < I > for [ T ]
2330
2328
where I : SliceIndex < [ T ] >
2331
2329
{
@@ -2376,7 +2374,19 @@ mod private_slice_index {
2376
2374
2377
2375
/// A helper trait used for indexing operations.
2378
2376
#[ stable( feature = "slice_get_slice" , since = "1.28.0" ) ]
2379
- #[ rustc_on_unimplemented = "slice indices are of type `usize` or ranges of `usize`" ]
2377
+ #[ rustc_on_unimplemented(
2378
+ on(
2379
+ T = "str" ,
2380
+ label = "string indices are ranges of `usize`" ,
2381
+ ) ,
2382
+ on(
2383
+ all( any( T = "str" , T = "&str" , T = "std::string::String" ) , _Self="{integer}" ) ,
2384
+ note="you can use `.chars().nth()` or `.bytes().nth()`
2385
+ see chapter in The Book <https://doc.rust-lang.org/book/ch08-02-strings.html#indexing-into-strings>"
2386
+ ) ,
2387
+ message = "the type `{T}` cannot be indexed by `{Self}`" ,
2388
+ label = "slice indices are of type `usize` or ranges of `usize`" ,
2389
+ ) ]
2380
2390
pub trait SliceIndex < T : ?Sized > : private_slice_index:: Sealed {
2381
2391
/// The output type returned by methods.
2382
2392
#[ stable( feature = "slice_get_slice" , since = "1.28.0" ) ]
0 commit comments