about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-12-24 10:28:25 +0000
committerbors <bors@rust-lang.org>2023-12-24 10:28:25 +0000
commit08cc634f1a26f30801daa1cbe7b866b12aaf1edd (patch)
tree1c28b9a8c3c158dc7952a8ba5f3b7a04c0910f9a
parentcf6427373b8b6d4b8efed2087fb9df5149e69e67 (diff)
parent0f814e3899fb35127373816181b25ba1296352e2 (diff)
downloadrust-08cc634f1a26f30801daa1cbe7b866b12aaf1edd.tar.gz
rust-08cc634f1a26f30801daa1cbe7b866b12aaf1edd.zip
Auto merge of #117176 - bvanjoi:fix-116796, r=jackh726
mark ty::Const::Error when meet unsupport ty for const generic params

Close #116796
-rw-r--r--tests/ui/const-generics/default-ty-closure.rs6
-rw-r--r--tests/ui/const-generics/default-ty-closure.stderr10
2 files changed, 16 insertions, 0 deletions
diff --git a/tests/ui/const-generics/default-ty-closure.rs b/tests/ui/const-generics/default-ty-closure.rs
new file mode 100644
index 00000000000..36128505dda
--- /dev/null
+++ b/tests/ui/const-generics/default-ty-closure.rs
@@ -0,0 +1,6 @@
+// https://github.com/rust-lang/rust/issues/116796
+
+struct X<const FN: fn() = { || {} }>;
+//~^ ERROR using function pointers as const generic parameters is forbidden
+
+fn main() {}
diff --git a/tests/ui/const-generics/default-ty-closure.stderr b/tests/ui/const-generics/default-ty-closure.stderr
new file mode 100644
index 00000000000..9c737c1a19d
--- /dev/null
+++ b/tests/ui/const-generics/default-ty-closure.stderr
@@ -0,0 +1,10 @@
+error: using function pointers as const generic parameters is forbidden
+  --> $DIR/default-ty-closure.rs:3:20
+   |
+LL | struct X<const FN: fn() = { || {} }>;
+   |                    ^^^^
+   |
+   = note: the only supported types are integers, `bool` and `char`
+
+error: aborting due to 1 previous error
+