diff options
| author | Aleksey Kladov <aleksey.kladov@gmail.com> | 2019-04-17 00:11:19 +0300 |
|---|---|---|
| committer | Aleksey Kladov <aleksey.kladov@gmail.com> | 2019-04-17 15:31:52 +0300 |
| commit | cc3abc4d2786be6d8366eb904b8ea4ac4a3e9f7e (patch) | |
| tree | 8ddfb52ed239d61a732fdbd20fb073f8dbc416a5 /src | |
| parent | e4e032a0ae82d7db4f99872ff98626af2941c4a5 (diff) | |
| download | rust-cc3abc4d2786be6d8366eb904b8ea4ac4a3e9f7e.tar.gz rust-cc3abc4d2786be6d8366eb904b8ea4ac4a3e9f7e.zip | |
add a test for unsized index
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/unsized-locals/unsized-index.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/test/ui/unsized-locals/unsized-index.rs b/src/test/ui/unsized-locals/unsized-index.rs new file mode 100644 index 00000000000..2e6bd82bda3 --- /dev/null +++ b/src/test/ui/unsized-locals/unsized-index.rs @@ -0,0 +1,23 @@ +// compile-pass + +// `std::ops::Index` has an `: ?Sized` bound on the `Idx` type param. This is +// an accidental left-over from the times when it `Index` was by-reference. +// Tightening the bound now could be a breaking change. Although no crater +// regression were observed (https://github.com/rust-lang/rust/pull/59527), +// let's be conservative and just add a test for this. +#![feature(unsized_locals)] + +use std::ops; + +pub struct A; + +impl ops::Index<str> for A { + type Output = (); + fn index(&self, _: str) -> &Self::Output { panic!() } +} + +impl ops::IndexMut<str> for A { + fn index_mut(&mut self, _: str) -> &mut Self::Output { panic!() } +} + +fn main() {} |
