]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-32008.rs
point at private fields in struct literal
[rust.git] / src / test / ui / issues / issue-32008.rs
1 // run-pass
2 #![allow(dead_code)]
3 #![allow(unused_variables)]
4 // Tests that binary operators allow subtyping on both the LHS and RHS,
5 // and as such do not introduce unnecessarily strict lifetime constraints.
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 }