summaryrefslogtreecommitdiffstats
path: root/tests/ui/const-generics/generic_const_exprs/auxiliary
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
commit218caa410aa38c29984be31a5229b9fa717560ee (patch)
treec54bd55eeb6e4c508940a30e94c0032fbd45d677 /tests/ui/const-generics/generic_const_exprs/auxiliary
parentReleasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz
rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/const-generics/generic_const_exprs/auxiliary')
-rw-r--r--tests/ui/const-generics/generic_const_exprs/auxiliary/anon_const_non_local.rs8
-rw-r--r--tests/ui/const-generics/generic_const_exprs/auxiliary/const_evaluatable_lib.rs9
-rw-r--r--tests/ui/const-generics/generic_const_exprs/auxiliary/issue-94287-aux.rs21
3 files changed, 38 insertions, 0 deletions
diff --git a/tests/ui/const-generics/generic_const_exprs/auxiliary/anon_const_non_local.rs b/tests/ui/const-generics/generic_const_exprs/auxiliary/anon_const_non_local.rs
new file mode 100644
index 000000000..97be07493
--- /dev/null
+++ b/tests/ui/const-generics/generic_const_exprs/auxiliary/anon_const_non_local.rs
@@ -0,0 +1,8 @@
+#![feature(generic_const_exprs)]
+#![allow(incomplete_features)]
+
+pub struct Foo<const N: usize>;
+
+pub fn foo<const N: usize>() -> Foo<{ N + 1 }> {
+ Foo
+}
diff --git a/tests/ui/const-generics/generic_const_exprs/auxiliary/const_evaluatable_lib.rs b/tests/ui/const-generics/generic_const_exprs/auxiliary/const_evaluatable_lib.rs
new file mode 100644
index 000000000..15d618cae
--- /dev/null
+++ b/tests/ui/const-generics/generic_const_exprs/auxiliary/const_evaluatable_lib.rs
@@ -0,0 +1,9 @@
+#![feature(generic_const_exprs)]
+#![allow(incomplete_features)]
+
+pub fn test1<T>() -> [u8; std::mem::size_of::<T>() - 1]
+where
+ [u8; std::mem::size_of::<T>() - 1]: Sized,
+{
+ [0; std::mem::size_of::<T>() - 1]
+}
diff --git a/tests/ui/const-generics/generic_const_exprs/auxiliary/issue-94287-aux.rs b/tests/ui/const-generics/generic_const_exprs/auxiliary/issue-94287-aux.rs
new file mode 100644
index 000000000..df454dae7
--- /dev/null
+++ b/tests/ui/const-generics/generic_const_exprs/auxiliary/issue-94287-aux.rs
@@ -0,0 +1,21 @@
+#![feature(generic_const_exprs)]
+
+use std::str::FromStr;
+
+pub struct If<const CONDITION: bool>;
+
+pub trait True {}
+
+impl True for If<true> {}
+
+pub struct FixedI32<const FRAC: u32>;
+
+impl<const FRAC: u32> FromStr for FixedI32<FRAC>
+where
+ If<{ FRAC <= 32 }>: True,
+{
+ type Err = ();
+ fn from_str(_s: &str) -> Result<Self, Self::Err> {
+ unimplemented!()
+ }
+}