diff options
Diffstat (limited to '')
-rw-r--r-- | src/test/ui/issues/issue-41849-variance-req.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/test/ui/issues/issue-41849-variance-req.rs b/src/test/ui/issues/issue-41849-variance-req.rs new file mode 100644 index 000000000..af081083a --- /dev/null +++ b/src/test/ui/issues/issue-41849-variance-req.rs @@ -0,0 +1,35 @@ +// run-pass +#![allow(dead_code)] +// Regression test for #41849. + +use std::ops::Mul; + +const C: usize = 1; +const CAPACITY: usize = 1 * C; + +struct A<X> { + f: [X; CAPACITY], +} + +struct B<T> { + f: T, +} + +impl<T> Mul for B<T> { + type Output = Self; + fn mul(self, _rhs: B<T>) -> Self::Output { + self + } +} + +impl<T> Mul<usize> for B<T> { + type Output = Self; + fn mul(self, _rhs: usize) -> Self::Output { + self + } +} + +fn main() { + let a = A { f: [1] }; + let _ = B { f: a }; +} |