diff --git a/src/test/ui/issues/issue-50518.rs b/src/test/ui/issues/issue-50518.rs
new file mode 100644
index 00000000000..d776d181b62
--- /dev/null
+++ b/src/test/ui/issues/issue-50518.rs
@@ -0,0 +1,40 @@
+// compile-pass
+use std::marker::PhantomData;
+
+struct Meta {
+ value: i32,
+ type_: PhantomData
+}
+
+trait MetaTrait {
+ fn get_value(&self) -> i32;
+}
+
+impl MetaTrait for Meta {
+ fn get_value(&self) -> i32 { self.value }
+}
+
+trait Bar {
+ fn get_const(&self) -> &dyn MetaTrait;
+}
+
+struct Foo {
+ _value: A
+}
+
+impl Foo {
+ const CONST: &'static dyn MetaTrait = &Meta:: {
+ value: 10,
+ type_: PhantomData
+ };
+}
+
+impl Bar for Foo {
+ fn get_const(&self) -> &dyn MetaTrait { Self::CONST }
+}
+
+fn main() {
+ let foo = Foo:: { _value: 10 };
+ let bar: &dyn Bar = &foo;
+ println!("const {}", bar.get_const().get_value());
+}