]>
Commit | Line | Data |
---|---|---|
b7449926 | 1 | // run-pass |
0bf4aa26 XL |
2 | #![allow(dead_code)] |
3 | #![allow(unused_variables)] | |
abe05a73 | 4 | // Tests that binary operators allow subtyping on both the LHS and RHS, |
0531ce1d | 5 | // and as such do not introduce unnecessarily strict lifetime constraints. |
abe05a73 XL |
6 | |
7 | use std::ops::Add; | |
8 | ||
9 | struct Foo; | |
10 | ||
11 | impl<'a> Add<&'a Foo> for &'a Foo { | |
12 | type Output = (); | |
13 | fn add(self, rhs: &'a Foo) {} | |
14 | } | |
15 | ||
16 | fn try_to_add(input: &Foo) { | |
17 | let local = Foo; | |
18 | ||
19 | // Manual reborrow worked even with invariant trait search. | |
20 | &*input + &local; | |
21 | ||
22 | // Direct use of the reference on the LHS requires additional | |
23 | // subtyping before searching (invariantly) for `LHS: Add<RHS>`. | |
24 | input + &local; | |
25 | } | |
26 | ||
27 | fn main() { | |
28 | } |