diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/manual_slice_fill.fixed | 37 | ||||
| -rw-r--r-- | tests/ui/manual_slice_fill.rs | 37 |
2 files changed, 74 insertions, 0 deletions
diff --git a/tests/ui/manual_slice_fill.fixed b/tests/ui/manual_slice_fill.fixed index bba863247f5..d07d1d60e2c 100644 --- a/tests/ui/manual_slice_fill.fixed +++ b/tests/ui/manual_slice_fill.fixed @@ -123,3 +123,40 @@ fn issue14189() { *b = !*b; } } + +mod issue14685 { + use std::ops::{Index, IndexMut}; + + #[derive(Clone)] + struct ZipList<T>(T); + + impl<T> ZipList<T> { + fn len(&self) -> usize { + todo!() + } + + fn is_empty(&self) -> bool { + todo!() + } + } + + impl<T> Index<usize> for ZipList<T> { + type Output = T; + + fn index(&self, _: usize) -> &Self::Output { + todo!() + } + } + + impl<T> IndexMut<usize> for ZipList<T> { + fn index_mut(&mut self, _: usize) -> &mut Self::Output { + todo!() + } + } + + fn index_mut(mut zl: ZipList<usize>) { + for i in 0..zl.len() { + zl[i] = 6; + } + } +} diff --git a/tests/ui/manual_slice_fill.rs b/tests/ui/manual_slice_fill.rs index 44c60dc40f0..c74ab2225c0 100644 --- a/tests/ui/manual_slice_fill.rs +++ b/tests/ui/manual_slice_fill.rs @@ -136,3 +136,40 @@ fn issue14189() { *b = !*b; } } + +mod issue14685 { + use std::ops::{Index, IndexMut}; + + #[derive(Clone)] + struct ZipList<T>(T); + + impl<T> ZipList<T> { + fn len(&self) -> usize { + todo!() + } + + fn is_empty(&self) -> bool { + todo!() + } + } + + impl<T> Index<usize> for ZipList<T> { + type Output = T; + + fn index(&self, _: usize) -> &Self::Output { + todo!() + } + } + + impl<T> IndexMut<usize> for ZipList<T> { + fn index_mut(&mut self, _: usize) -> &mut Self::Output { + todo!() + } + } + + fn index_mut(mut zl: ZipList<usize>) { + for i in 0..zl.len() { + zl[i] = 6; + } + } +} |
