Why is type parameter of std::ops::Index ?Sized

I wonder why the type parameter of std::ops::Index is ?Sized. Afterall, I can't implement it with an unsized type, because the mandatory index method requires the index as an argument:

struct A;

impl std::ops::Index<str> for A {
    type Output = ();
    fn index(&self, index: str) -> &() {
        &()
    }
}

(Playground)

Errors:

   Compiling playground v0.0.1 (/playground)
error[E0277]: the size for values of type `str` cannot be known at compilation time
 --> src/lib.rs:5:21
  |
5 |     fn index(&self, index: str) -> &() {
  |                     ^^^^^ doesn't have a size known at compile-time
  |
  = help: the trait `Sized` is not implemented for `str`
help: function arguments must have a statically known size, borrowed types always have a known size
  |
5 |     fn index(&self, index: &str) -> &() {
  |                            +

For more information about this error, try `rustc --explain E0277`.
error: could not compile `playground` (lib) due to previous error

Maybe this is to support certain language built-in indexing mechanisms that I can't reproduce in user code?

This is probably just an oversight.

Oops, I didn't properly check the existing posts on this issue here. I found these threads:

One answer indicates it may be for forward-compatibility. Another one says it's a historic accident.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.