summaryrefslogtreecommitdiffstats
path: root/src/test/ui/const-generics/issues/issue-71381.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/const-generics/issues/issue-71381.rs')
-rw-r--r--src/test/ui/const-generics/issues/issue-71381.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/test/ui/const-generics/issues/issue-71381.rs b/src/test/ui/const-generics/issues/issue-71381.rs
new file mode 100644
index 000000000..66f819dbe
--- /dev/null
+++ b/src/test/ui/const-generics/issues/issue-71381.rs
@@ -0,0 +1,36 @@
+// revisions: full min
+#![cfg_attr(full, feature(adt_const_params))]
+#![cfg_attr(full, allow(incomplete_features))]
+
+struct Test(*const usize);
+
+type PassArg = ();
+
+unsafe extern "C" fn pass(args: PassArg) {
+ println!("Hello, world!");
+}
+
+impl Test {
+ pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "C" fn(Args)>(&self) {
+ //~^ ERROR: using function pointers as const generic parameters is forbidden
+ //~| ERROR: the type of const parameters must not depend on other generic parameters
+ self.0 = Self::trampiline::<Args, IDX, FN> as _
+ }
+
+ unsafe extern "C" fn trampiline<
+ Args: Sized,
+ const IDX: usize,
+ const FN: unsafe extern "C" fn(Args),
+ //~^ ERROR: using function pointers as const generic parameters is forbidden
+ //~| ERROR: the type of const parameters must not depend on other generic parameters
+ >(
+ args: Args,
+ ) {
+ FN(args)
+ }
+}
+
+fn main() {
+ let x = Test();
+ x.call_me::<PassArg, 30, pass>()
+}