Skip to content

Commit

Permalink
add regression test for rust-lang#71348
Browse files Browse the repository at this point in the history
  • Loading branch information
lcnr committed Jul 16, 2020
1 parent eee160c commit a2b1827
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/test/ui/const-generics/type-dependent/issue-71348.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// run-pass
#![feature(const_generics)]
#![allow(incomplete_features)]

struct Foo {
i: i32,
}

trait Get<'a, const N: &'static str> {
type Target: 'a;

fn get(&'a self) -> &'a Self::Target;
}

impl Foo {
fn ask<'a, const N: &'static str>(&'a self) -> &'a <Self as Get<N>>::Target
where
Self: Get<'a, N>,
{
self.get()
}
}

impl<'a> Get<'a, "int"> for Foo {
type Target = i32;

fn get(&'a self) -> &'a Self::Target {
&self.i
}
}

fn main() {
let foo = Foo { i: 123 };
assert_eq!(foo.ask::<"int">(), &123);
}

0 comments on commit a2b1827

Please sign in to comment.