]> git.proxmox.com Git - rustc.git/blob - tests/ui/traits/vtable/issue-97381.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / ui / traits / vtable / issue-97381.rs
1 use std::ops::Deref;
2 trait MyTrait: Deref<Target = u32> {}
3 struct MyStruct(u32);
4 impl MyTrait for MyStruct {}
5 impl Deref for MyStruct {
6 type Target = u32;
7
8 fn deref(&self) -> &Self::Target {
9 &self.0
10 }
11 }
12 fn get_concrete_value(i: u32) -> MyStruct {
13 MyStruct(i)
14 }
15 fn get_boxed_value(i: u32) -> Box<dyn MyTrait> {
16 Box::new(get_concrete_value(i))
17 }
18 fn main() {
19 let v = [1, 2, 3]
20 .iter()
21 .map(|i| get_boxed_value(*i))
22 .collect::<Vec<_>>();
23
24 let el = &v[0];
25
26 for _ in v {
27 //~^ ERROR cannot move out of `v` because it is borrowed
28 println!("{}", ***el > 0);
29 }
30 }