]> git.lizzy.rs Git - rust.git/blob - src/test/ui/binops-issue-22743.rs
Auto merge of #75936 - sdroege:chunks-exact-construction-bounds-check, r=nagisa
[rust.git] / src / test / ui / binops-issue-22743.rs
1 // run-pass
2
3 use std::ops::Mul;
4
5 #[derive(Copy, Clone)]
6 pub struct Foo {
7     x: f64,
8 }
9
10 impl Mul<Foo> for f64 {
11     type Output = Foo;
12
13     fn mul(self, rhs: Foo) -> Foo {
14         // intentionally do something that is not *
15         Foo { x: self + rhs.x }
16     }
17 }
18
19 pub fn main() {
20     let f: Foo = Foo { x: 5.0 };
21     let val: f64 = 3.0;
22     let f2: Foo = val * f;
23     assert_eq!(f2.x, 8.0);
24 }