]> git.proxmox.com Git - rustc.git/blob - src/test/ui/issues/issue-50518.rs
New upstream version 1.41.1+dfsg1
[rustc.git] / src / test / ui / issues / issue-50518.rs
1 // check-pass
2 use std::marker::PhantomData;
3
4 struct Meta<A> {
5 value: i32,
6 type_: PhantomData<A>
7 }
8
9 trait MetaTrait {
10 fn get_value(&self) -> i32;
11 }
12
13 impl<A> MetaTrait for Meta<A> {
14 fn get_value(&self) -> i32 { self.value }
15 }
16
17 trait Bar {
18 fn get_const(&self) -> &dyn MetaTrait;
19 }
20
21 struct Foo<A> {
22 _value: A
23 }
24
25 impl<A: 'static> Foo<A> {
26 const CONST: &'static dyn MetaTrait = &Meta::<Self> {
27 value: 10,
28 type_: PhantomData
29 };
30 }
31
32 impl<A: 'static> Bar for Foo<A> {
33 fn get_const(&self) -> &dyn MetaTrait { Self::CONST }
34 }
35
36 fn main() {
37 let foo = Foo::<i32> { _value: 10 };
38 let bar: &dyn Bar = &foo;
39 println!("const {}", bar.get_const().get_value());
40 }