about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorCDirkx <christiaan@dirkx.com>2020-03-23 19:16:12 +0100
committerCDirkx <christiaan@dirkx.com>2020-03-23 19:16:12 +0100
commitf080f944f134700c48801a3b826330c9bd3aa5cc (patch)
treeaeb927b8608b7b74875a2c691bf0aceabdfc3531 /src/test
parentbd1df4405785a34ac494007f185744d51ddd9138 (diff)
downloadrust-f080f944f134700c48801a3b826330c9bd3aa5cc.tar.gz
rust-f080f944f134700c48801a3b826330c9bd3aa5cc.zip
Add const generics test for all range types.
In addition to the regression test of `RangeInclusive` for #70155, now all range types are checked for usability within const generics:

- `RangeFrom`
- `RangeFull`
- `RangeToInclusive`
- `RangeTo`
- `Range`

The test are moved from `test\ui\const-generics\issues\issue-70155` to `test\ui\const-generics\std\range` in anticipation of future similar tests for std types.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/const-generics/std/range/const-generics-range-from.rs11
-rw-r--r--src/test/ui/const-generics/std/range/const-generics-range-full.rs11
-rw-r--r--src/test/ui/const-generics/std/range/const-generics-range-inclusive.rs (renamed from src/test/ui/const-generics/issues/issue-70155.rs)5
-rw-r--r--src/test/ui/const-generics/std/range/const-generics-range-to-inclusive.rs11
-rw-r--r--src/test/ui/const-generics/std/range/const-generics-range-to.rs11
-rw-r--r--src/test/ui/const-generics/std/range/const-generics-range.rs11
6 files changed, 58 insertions, 2 deletions
diff --git a/src/test/ui/const-generics/std/range/const-generics-range-from.rs b/src/test/ui/const-generics/std/range/const-generics-range-from.rs
new file mode 100644
index 00000000000..487a51ddf25
--- /dev/null
+++ b/src/test/ui/const-generics/std/range/const-generics-range-from.rs
@@ -0,0 +1,11 @@
+// check-pass
+#![allow(incomplete_features)]
+#![feature(const_generics)]
+
+// `RangeFrom` should be usable within const generics:
+
+struct S<const R: std::ops::RangeFrom<usize>>;
+
+const C : S<{ 0 .. }> = S;
+
+pub fn main() {}
diff --git a/src/test/ui/const-generics/std/range/const-generics-range-full.rs b/src/test/ui/const-generics/std/range/const-generics-range-full.rs
new file mode 100644
index 00000000000..2af2dd8343b
--- /dev/null
+++ b/src/test/ui/const-generics/std/range/const-generics-range-full.rs
@@ -0,0 +1,11 @@
+// check-pass
+#![allow(incomplete_features)]
+#![feature(const_generics)]
+
+// `RangeFull` should be usable within const generics:
+
+struct S<const R: std::ops::RangeFull>;
+
+const C : S<{ .. }> = S;
+
+pub fn main() {}
diff --git a/src/test/ui/const-generics/issues/issue-70155.rs b/src/test/ui/const-generics/std/range/const-generics-range-inclusive.rs
index be71b347590..c9f7420f6ac 100644
--- a/src/test/ui/const-generics/issues/issue-70155.rs
+++ b/src/test/ui/const-generics/std/range/const-generics-range-inclusive.rs
@@ -2,8 +2,9 @@
 #![allow(incomplete_features)]
 #![feature(const_generics)]
 
-// Regression test for #70155:
-// `RangeInclusive` should be usable with const generics
+// Regression test for #70155
+
+// `RangeInclusive` should be usable within const generics:
 
 struct S<const R: std::ops::RangeInclusive<usize>>;
 
diff --git a/src/test/ui/const-generics/std/range/const-generics-range-to-inclusive.rs b/src/test/ui/const-generics/std/range/const-generics-range-to-inclusive.rs
new file mode 100644
index 00000000000..dbef24f853c
--- /dev/null
+++ b/src/test/ui/const-generics/std/range/const-generics-range-to-inclusive.rs
@@ -0,0 +1,11 @@
+// check-pass
+#![allow(incomplete_features)]
+#![feature(const_generics)]
+
+// `RangeToInclusive` should be usable within const generics:
+
+struct S<const R: std::ops::RangeToInclusive<usize>>;
+
+const C : S<{ ..= 999 }> = S;
+
+pub fn main() {}
diff --git a/src/test/ui/const-generics/std/range/const-generics-range-to.rs b/src/test/ui/const-generics/std/range/const-generics-range-to.rs
new file mode 100644
index 00000000000..ed479316a82
--- /dev/null
+++ b/src/test/ui/const-generics/std/range/const-generics-range-to.rs
@@ -0,0 +1,11 @@
+// check-pass
+#![allow(incomplete_features)]
+#![feature(const_generics)]
+
+// `RangeTo` should be usable within const generics:
+
+struct S<const R: std::ops::RangeTo<usize>>;
+
+const C : S<{ .. 1000 }> = S;
+
+pub fn main() {}
diff --git a/src/test/ui/const-generics/std/range/const-generics-range.rs b/src/test/ui/const-generics/std/range/const-generics-range.rs
new file mode 100644
index 00000000000..ea4b72780c9
--- /dev/null
+++ b/src/test/ui/const-generics/std/range/const-generics-range.rs
@@ -0,0 +1,11 @@
+// check-pass
+#![allow(incomplete_features)]
+#![feature(const_generics)]
+
+// `Range` should be usable within const generics:
+
+struct S<const R: std::ops::Range<usize>>;
+
+const C : S<{ 0 .. 1000 }> = S;
+
+pub fn main() {}