From bd1df4405785a34ac494007f185744d51ddd9138 Mon Sep 17 00:00:00 2001 From: CDirkx Date: Sun, 22 Mar 2020 22:04:05 +0100 Subject: [PATCH 1/3] Add regression test for #70155. With #70166 merged, `RangeInclusive` now derives `PartialEq` and `Eq`, implementing structural equality and as a side effect the range is now usable with const generics, closing #70155. A test is added to avoid a change to the private fields or the equality implementation of the range from subtly reverting #70155. --- src/test/ui/const-generics/issues/issue-70155.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/test/ui/const-generics/issues/issue-70155.rs diff --git a/src/test/ui/const-generics/issues/issue-70155.rs b/src/test/ui/const-generics/issues/issue-70155.rs new file mode 100644 index 0000000000000..be71b347590c1 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-70155.rs @@ -0,0 +1,12 @@ +// check-pass +#![allow(incomplete_features)] +#![feature(const_generics)] + +// Regression test for #70155: +// `RangeInclusive` should be usable with const generics + +struct S>; + +const C : S<{ 0 ..= 999 }> = S; + +pub fn main() {} From f080f944f134700c48801a3b826330c9bd3aa5cc Mon Sep 17 00:00:00 2001 From: CDirkx Date: Mon, 23 Mar 2020 19:16:12 +0100 Subject: [PATCH 2/3] 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. --- .../std/range/const-generics-range-from.rs | 11 +++++++++++ .../std/range/const-generics-range-full.rs | 11 +++++++++++ .../range/const-generics-range-inclusive.rs} | 5 +++-- .../std/range/const-generics-range-to-inclusive.rs | 11 +++++++++++ .../std/range/const-generics-range-to.rs | 11 +++++++++++ .../const-generics/std/range/const-generics-range.rs | 11 +++++++++++ 6 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 src/test/ui/const-generics/std/range/const-generics-range-from.rs create mode 100644 src/test/ui/const-generics/std/range/const-generics-range-full.rs rename src/test/ui/const-generics/{issues/issue-70155.rs => std/range/const-generics-range-inclusive.rs} (66%) create mode 100644 src/test/ui/const-generics/std/range/const-generics-range-to-inclusive.rs create mode 100644 src/test/ui/const-generics/std/range/const-generics-range-to.rs create mode 100644 src/test/ui/const-generics/std/range/const-generics-range.rs 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 0000000000000..487a51ddf25c4 --- /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 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 0000000000000..2af2dd8343be3 --- /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 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 similarity index 66% rename from src/test/ui/const-generics/issues/issue-70155.rs rename to src/test/ui/const-generics/std/range/const-generics-range-inclusive.rs index be71b347590c1..c9f7420f6ac4f 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>; 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 0000000000000..dbef24f853c18 --- /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 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 0000000000000..ed479316a8239 --- /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 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 0000000000000..ea4b72780c9cc --- /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 C : S<{ 0 .. 1000 }> = S; + +pub fn main() {} From 9fdde0a000c7132fc0b79e2f44b52042dc8227dd Mon Sep 17 00:00:00 2001 From: CDirkx Date: Mon, 23 Mar 2020 19:27:13 +0100 Subject: [PATCH 3/3] Merge tests. Merge tests to a single test file. --- .../std/const-generics-range.rs | 30 +++++++++++++++++++ .../std/range/const-generics-range-from.rs | 11 ------- .../std/range/const-generics-range-full.rs | 11 ------- .../range/const-generics-range-inclusive.rs | 13 -------- .../const-generics-range-to-inclusive.rs | 11 ------- .../std/range/const-generics-range-to.rs | 11 ------- .../std/range/const-generics-range.rs | 11 ------- 7 files changed, 30 insertions(+), 68 deletions(-) create mode 100644 src/test/ui/const-generics/std/const-generics-range.rs delete mode 100644 src/test/ui/const-generics/std/range/const-generics-range-from.rs delete mode 100644 src/test/ui/const-generics/std/range/const-generics-range-full.rs delete mode 100644 src/test/ui/const-generics/std/range/const-generics-range-inclusive.rs delete mode 100644 src/test/ui/const-generics/std/range/const-generics-range-to-inclusive.rs delete mode 100644 src/test/ui/const-generics/std/range/const-generics-range-to.rs delete mode 100644 src/test/ui/const-generics/std/range/const-generics-range.rs diff --git a/src/test/ui/const-generics/std/const-generics-range.rs b/src/test/ui/const-generics/std/const-generics-range.rs new file mode 100644 index 0000000000000..6d56fe0d7b8e3 --- /dev/null +++ b/src/test/ui/const-generics/std/const-generics-range.rs @@ -0,0 +1,30 @@ +// check-pass +#![allow(incomplete_features)] +#![feature(const_generics)] + +// `Range` should be usable within const generics: +struct _Range>; +const RANGE : _Range<{ 0 .. 1000 }> = _Range; + +// `RangeFrom` should be usable within const generics: +struct _RangeFrom>; +const RANGE_FROM : _RangeFrom<{ 0 .. }> = _RangeFrom; + +// `RangeFull` should be usable within const generics: +struct _RangeFull; +const RANGE_FULL : _RangeFull<{ .. }> = _RangeFull; + +// Regression test for #70155 +// `RangeInclusive` should be usable within const generics: +struct _RangeInclusive>; +const RANGE_INCLUSIVE : _RangeInclusive<{ 0 ..= 999 }> = _RangeInclusive; + +// `RangeTo` should be usable within const generics: +struct _RangeTo>; +const RANGE_TO : _RangeTo<{ .. 1000 }> = _RangeTo; + +// `RangeToInclusive` should be usable within const generics: +struct _RangeToInclusive>; +const RANGE_TO_INCLUSIVE : _RangeToInclusive<{ ..= 999 }> = _RangeToInclusive; + +pub fn main() {} 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 deleted file mode 100644 index 487a51ddf25c4..0000000000000 --- a/src/test/ui/const-generics/std/range/const-generics-range-from.rs +++ /dev/null @@ -1,11 +0,0 @@ -// check-pass -#![allow(incomplete_features)] -#![feature(const_generics)] - -// `RangeFrom` should be usable within const generics: - -struct S>; - -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 deleted file mode 100644 index 2af2dd8343be3..0000000000000 --- a/src/test/ui/const-generics/std/range/const-generics-range-full.rs +++ /dev/null @@ -1,11 +0,0 @@ -// check-pass -#![allow(incomplete_features)] -#![feature(const_generics)] - -// `RangeFull` should be usable within const generics: - -struct S; - -const C : S<{ .. }> = S; - -pub fn main() {} diff --git a/src/test/ui/const-generics/std/range/const-generics-range-inclusive.rs b/src/test/ui/const-generics/std/range/const-generics-range-inclusive.rs deleted file mode 100644 index c9f7420f6ac4f..0000000000000 --- a/src/test/ui/const-generics/std/range/const-generics-range-inclusive.rs +++ /dev/null @@ -1,13 +0,0 @@ -// check-pass -#![allow(incomplete_features)] -#![feature(const_generics)] - -// Regression test for #70155 - -// `RangeInclusive` should be usable within const generics: - -struct S>; - -const C : S<{ 0 ..= 999 }> = S; - -pub fn main() {} 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 deleted file mode 100644 index dbef24f853c18..0000000000000 --- a/src/test/ui/const-generics/std/range/const-generics-range-to-inclusive.rs +++ /dev/null @@ -1,11 +0,0 @@ -// check-pass -#![allow(incomplete_features)] -#![feature(const_generics)] - -// `RangeToInclusive` should be usable within const generics: - -struct S>; - -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 deleted file mode 100644 index ed479316a8239..0000000000000 --- a/src/test/ui/const-generics/std/range/const-generics-range-to.rs +++ /dev/null @@ -1,11 +0,0 @@ -// check-pass -#![allow(incomplete_features)] -#![feature(const_generics)] - -// `RangeTo` should be usable within const generics: - -struct S>; - -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 deleted file mode 100644 index ea4b72780c9cc..0000000000000 --- a/src/test/ui/const-generics/std/range/const-generics-range.rs +++ /dev/null @@ -1,11 +0,0 @@ -// check-pass -#![allow(incomplete_features)] -#![feature(const_generics)] - -// `Range` should be usable within const generics: - -struct S>; - -const C : S<{ 0 .. 1000 }> = S; - -pub fn main() {}