Skip to content

Commit a2b1827

Browse files
committed
add regression test for rust-lang#71348
1 parent eee160c commit a2b1827

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// run-pass
2+
#![feature(const_generics)]
3+
#![allow(incomplete_features)]
4+
5+
struct Foo {
6+
i: i32,
7+
}
8+
9+
trait Get<'a, const N: &'static str> {
10+
type Target: 'a;
11+
12+
fn get(&'a self) -> &'a Self::Target;
13+
}
14+
15+
impl Foo {
16+
fn ask<'a, const N: &'static str>(&'a self) -> &'a <Self as Get<N>>::Target
17+
where
18+
Self: Get<'a, N>,
19+
{
20+
self.get()
21+
}
22+
}
23+
24+
impl<'a> Get<'a, "int"> for Foo {
25+
type Target = i32;
26+
27+
fn get(&'a self) -> &'a Self::Target {
28+
&self.i
29+
}
30+
}
31+
32+
fn main() {
33+
let foo = Foo { i: 123 };
34+
assert_eq!(foo.ask::<"int">(), &123);
35+
}

0 commit comments

Comments
 (0)