We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c3b8ab5 commit c87d2ccCopy full SHA for c87d2cc
src/test/ui/issues/issue-50518.rs
@@ -0,0 +1,40 @@
1
+// compile-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
0 commit comments