summaryrefslogtreecommitdiffstats
path: root/src/test/ui/const-generics/type-dependent/issue-71348.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/const-generics/type-dependent/issue-71348.rs')
-rw-r--r--src/test/ui/const-generics/type-dependent/issue-71348.rs38
1 files changed, 38 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 000000000..2ef2f066a
--- /dev/null
+++ b/src/test/ui/const-generics/type-dependent/issue-71348.rs
@@ -0,0 +1,38 @@
+// [full] run-pass
+// revisions: full min
+#![cfg_attr(full, feature(adt_const_params))]
+#![cfg_attr(full, allow(incomplete_features))]
+
+struct Foo {
+ i: i32,
+}
+
+trait Get<'a, const N: &'static str> {
+ //[min]~^ ERROR `&'static str` is forbidden as the type of a const generic parameter
+ 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
+ //[min]~^ ERROR `&'static str` is forbidden as the type of a const generic parameter
+ 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);
+}