about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorBastian Kauschke <bastian_kauschke@hotmail.de>2020-07-16 12:17:27 +0200
committerBastian Kauschke <bastian_kauschke@hotmail.de>2020-07-16 12:17:27 +0200
commita2b18274a890eb19db5f784b2fb6925eebcdf86f (patch)
tree8f903b7540995976544e8a3b9c9c2e79fbe33e8b /src
parenteee160cdea88da87396f5682220193a01ff177b0 (diff)
downloadrust-a2b18274a890eb19db5f784b2fb6925eebcdf86f.tar.gz
rust-a2b18274a890eb19db5f784b2fb6925eebcdf86f.zip
add regression test for #71348
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/const-generics/type-dependent/issue-71348.rs35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/test/ui/const-generics/type-dependent/issue-71348.rs b/src/test/ui/const-generics/type-dependent/issue-71348.rs
new file mode 100644
index 00000000000..ec22dcdf60b
--- /dev/null
+++ b/src/test/ui/const-generics/type-dependent/issue-71348.rs
@@ -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);
+}