diff options
Diffstat (limited to '')
-rw-r--r-- | src/test/ui/issues/issue-22312.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/test/ui/issues/issue-22312.rs b/src/test/ui/issues/issue-22312.rs new file mode 100644 index 000000000..4e359b341 --- /dev/null +++ b/src/test/ui/issues/issue-22312.rs @@ -0,0 +1,17 @@ +use std::ops::Index; + +pub trait Array2D: Index<usize> + Sized { + fn rows(&self) -> usize; + fn columns(&self) -> usize; + fn get<'a>(&'a self, y: usize, x: usize) -> Option<&'a <Self as Index<usize>>::Output> { + if y >= self.rows() || x >= self.columns() { + return None; + } + let i = y * self.columns() + x; + let indexer = &(*self as &dyn Index<usize, Output = <Self as Index<usize>>::Output>); + //~^ERROR non-primitive cast + Some(indexer.index(i)) + } +} + +fn main() {} |