summaryrefslogtreecommitdiffstats
path: root/tests/ui/const-generics/generic_const_exprs/const_kind_expr
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
commit9918693037dce8aa4bb6f08741b6812923486c18 (patch)
tree21d2b40bec7e6a7ea664acee056eb3d08e15a1cf /tests/ui/const-generics/generic_const_exprs/const_kind_expr
parentReleasing progress-linux version 1.75.0+dfsg1-5~progress7.99u1. (diff)
downloadrustc-9918693037dce8aa4bb6f08741b6812923486c18.tar.xz
rustc-9918693037dce8aa4bb6f08741b6812923486c18.zip
Merging upstream version 1.76.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/const-generics/generic_const_exprs/const_kind_expr')
-rw-r--r--tests/ui/const-generics/generic_const_exprs/const_kind_expr/issue_114151.rs25
-rw-r--r--tests/ui/const-generics/generic_const_exprs/const_kind_expr/issue_114151.stderr64
2 files changed, 89 insertions, 0 deletions
diff --git a/tests/ui/const-generics/generic_const_exprs/const_kind_expr/issue_114151.rs b/tests/ui/const-generics/generic_const_exprs/const_kind_expr/issue_114151.rs
new file mode 100644
index 000000000..6256000b4
--- /dev/null
+++ b/tests/ui/const-generics/generic_const_exprs/const_kind_expr/issue_114151.rs
@@ -0,0 +1,25 @@
+#![feature(generic_const_exprs)]
+#![allow(incomplete_features)]
+
+fn foo<const N: usize>(
+ _: [u8; {
+ {
+ N
+ }
+ }],
+) {
+}
+
+fn ice<const L: usize>()
+where
+ [(); (L - 1) + 1 + L]:,
+{
+ foo::<_, L>([(); L + 1 + L]);
+ //~^ ERROR: mismatched types
+ //~^^ ERROR: unconstrained generic constant
+ //~^^^ ERROR: function takes 1 generic argument but 2 generic arguments were supplied
+ //~^^^^ ERROR: unconstrained generic constant
+ //~^^^^^ ERROR: unconstrained generic constant `{const expr}`
+}
+
+fn main() {}
diff --git a/tests/ui/const-generics/generic_const_exprs/const_kind_expr/issue_114151.stderr b/tests/ui/const-generics/generic_const_exprs/const_kind_expr/issue_114151.stderr
new file mode 100644
index 000000000..6001d8247
--- /dev/null
+++ b/tests/ui/const-generics/generic_const_exprs/const_kind_expr/issue_114151.stderr
@@ -0,0 +1,64 @@
+error[E0107]: function takes 1 generic argument but 2 generic arguments were supplied
+ --> $DIR/issue_114151.rs:17:5
+ |
+LL | foo::<_, L>([(); L + 1 + L]);
+ | ^^^ - help: remove this generic argument
+ | |
+ | expected 1 generic argument
+ |
+note: function defined here, with 1 generic parameter: `N`
+ --> $DIR/issue_114151.rs:4:4
+ |
+LL | fn foo<const N: usize>(
+ | ^^^ --------------
+
+error[E0308]: mismatched types
+ --> $DIR/issue_114151.rs:17:18
+ |
+LL | foo::<_, L>([(); L + 1 + L]);
+ | ^^ expected `u8`, found `()`
+
+error: unconstrained generic constant
+ --> $DIR/issue_114151.rs:17:22
+ |
+LL | foo::<_, L>([(); L + 1 + L]);
+ | ^^^^^^^^^
+ |
+ = help: try adding a `where` bound using this expression: `where [(); L + 1 + L]:`
+
+error: unconstrained generic constant
+ --> $DIR/issue_114151.rs:17:17
+ |
+LL | foo::<_, L>([(); L + 1 + L]);
+ | ----------- ^^^^^^^^^^^^^^^
+ | |
+ | required by a bound introduced by this call
+ |
+ = help: try adding a `where` bound using this expression: `where [(); {
+ {
+ N
+ }
+ }]:`
+note: required by a bound in `foo`
+ --> $DIR/issue_114151.rs:5:13
+ |
+LL | fn foo<const N: usize>(
+ | --- required by a bound in this function
+LL | _: [u8; {
+ | _____________^
+LL | | {
+LL | | N
+LL | | }
+LL | | }],
+ | |_____^ required by this bound in `foo`
+
+error: unconstrained generic constant `{const expr}`
+ --> $DIR/issue_114151.rs:17:5
+ |
+LL | foo::<_, L>([(); L + 1 + L]);
+ | ^^^^^^^^^^^
+
+error: aborting due to 5 previous errors
+
+Some errors have detailed explanations: E0107, E0308.
+For more information about an error, try `rustc --explain E0107`.