add regression test for #71348
This commit is contained in:
parent
eee160cdea
commit
a2b18274a8
1 changed files with 35 additions and 0 deletions
35
src/test/ui/const-generics/type-dependent/issue-71348.rs
Normal file
35
src/test/ui/const-generics/type-dependent/issue-71348.rs
Normal file
|
|
@ -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);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue