]> git.lizzy.rs Git - rust.git/blob - tests/ui/moves/move-deref-coercion.rs
Rollup merge of #107102 - compiler-errors:new-solver-new-candidats-4, r=lcnr
[rust.git] / tests / ui / moves / move-deref-coercion.rs
1 use std::ops::Deref;
2
3 struct NotCopy {
4     inner: bool
5 }
6
7 impl NotCopy {
8     fn inner_method(&self) {}
9 }
10
11 struct Foo {
12     first: NotCopy,
13     second: NotCopy
14 }
15
16 impl Deref for Foo {
17     type Target = NotCopy;
18     fn deref(&self) -> &NotCopy {
19         &self.second
20     }
21 }
22
23 fn use_field(val: Foo) {
24     let _val = val.first;
25     val.inner; //~ ERROR borrow of
26 }
27
28 fn use_method(val: Foo) {
29     let _val = val.first;
30     val.inner_method(); //~ ERROR borrow of
31 }
32
33 fn main() {}