Skip to content

Commit d20b692

Browse files
authored
Rollup merge of rust-lang#60627 - matklad:test, r=estebank
test for rust-lang#50518 It was fixed somewhere between 1.28.0 and 1.31.1 closes rust-lang#50518 r? @estebank Where's the best place to add this test? I *think* we want "compile-pass" for this test (no need to run a binary, and not running saves us a millisecond of process creation) , but there's no compile-pass anymore. Should this be UI test with empty stdout, stderr and zero return code?
2 parents b04f87f + c87d2cc commit d20b692

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

src/test/ui/issues/issue-50518.rs

+40
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)