Skip to content

Commit 4e2a25d

Browse files
authored
Rollup merge of rust-lang#75938 - Amjad50:min_const_generics-tests-revisions, r=lcnr
Added some `min_const_generics` revisions into `const_generics` tests Help in rust-lang#75279. still a lot more to cover though r? @lcnr
2 parents 3b4797c + 668f63d commit 4e2a25d

File tree

107 files changed

+762
-375
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+762
-375
lines changed

src/test/ui/const-generics/argument_order.stderr renamed to src/test/ui/const-generics/argument_order.full.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error: lifetime parameters must be declared prior to const parameters
2-
--> $DIR/argument_order.rs:9:32
2+
--> $DIR/argument_order.rs:12:32
33
|
44
LL | struct AlsoBad<const N: usize, 'a, T, 'b, const M: usize, U> {
55
| -----------------^^-----^^-------------------- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, const N: usize, T, const M: usize, U>`
66

77
error[E0747]: lifetime provided when a type was expected
8-
--> $DIR/argument_order.rs:16:23
8+
--> $DIR/argument_order.rs:20:23
99
|
1010
LL | let _: AlsoBad<7, 'static, u32, 'static, 17, u16>;
1111
| ^^^^^^^
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
error: type parameters must be declared prior to const parameters
2+
--> $DIR/argument_order.rs:6:28
3+
|
4+
LL | struct Bad<const N: usize, T> {
5+
| -----------------^- help: reorder the parameters: lifetimes, then types, then consts: `<T, const N: usize>`
6+
7+
error: lifetime parameters must be declared prior to const parameters
8+
--> $DIR/argument_order.rs:12:32
9+
|
10+
LL | struct AlsoBad<const N: usize, 'a, T, 'b, const M: usize, U> {
11+
| -----------------^^-----^^-------------------- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T, U, const N: usize, const M: usize>`
12+
13+
error: type parameters must be declared prior to const parameters
14+
--> $DIR/argument_order.rs:12:36
15+
|
16+
LL | struct AlsoBad<const N: usize, 'a, T, 'b, const M: usize, U> {
17+
| ---------------------^----------------------^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T, U, const N: usize, const M: usize>`
18+
19+
error[E0747]: lifetime provided when a type was expected
20+
--> $DIR/argument_order.rs:20:23
21+
|
22+
LL | let _: AlsoBad<7, 'static, u32, 'static, 17, u16>;
23+
| ^^^^^^^
24+
|
25+
= note: lifetime arguments must be provided before type arguments
26+
= help: reorder the arguments: lifetimes, then types, then consts: `<'a, 'b, T, U, N, M>`
27+
28+
error: aborting due to 4 previous errors
29+
30+
For more information about this error, try `rustc --explain E0747`.

src/test/ui/const-generics/argument_order.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
#![feature(const_generics)]
2-
#![allow(incomplete_features)]
1+
// revisions: full min
2+
#![cfg_attr(full, feature(const_generics))]
3+
#![cfg_attr(full, allow(incomplete_features))]
4+
#![cfg_attr(min, feature(min_const_generics))]
35

46
struct Bad<const N: usize, T> {
7+
//[min]~^ ERROR type parameters must be declared prior to const parameters
58
arr: [u8; { N }],
69
another: T,
710
}
811

912
struct AlsoBad<const N: usize, 'a, T, 'b, const M: usize, U> {
1013
//~^ ERROR lifetime parameters must be declared prior
14+
//[min]~^^ ERROR type parameters must be declared prior to const parameters
1115
a: &'a T,
1216
b: &'b U,
1317
}

src/test/ui/const-generics/array-wrapper-struct-ctor.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// run-pass
2-
3-
#![feature(const_generics)]
4-
//~^ WARN the feature `const_generics` is incomplete
2+
// revisions: full min
3+
#![cfg_attr(full, feature(const_generics))]
4+
#![cfg_attr(full, allow(incomplete_features))]
5+
#![cfg_attr(min, feature(min_const_generics))]
56

67
#![allow(dead_code)]
78

src/test/ui/const-generics/array-wrapper-struct-ctor.stderr

-11
This file was deleted.

src/test/ui/const-generics/cannot-infer-type-for-const-param.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// check-pass
2-
#![feature(const_generics)]
3-
//~^ WARN the feature `const_generics` is incomplete
2+
// revisions: full min
3+
#![cfg_attr(full, feature(const_generics))]
4+
#![cfg_attr(full, allow(incomplete_features))]
5+
#![cfg_attr(min, feature(min_const_generics))]
46

57
// This test confirms that the types can be inferred correctly for this example with const
68
// generics. Previously this would ICE, and more recently error.

src/test/ui/const-generics/cannot-infer-type-for-const-param.stderr

-11
This file was deleted.

src/test/ui/const-generics/const-arg-type-arg-misordered.stderr renamed to src/test/ui/const-generics/const-arg-type-arg-misordered.full.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0747]: constant provided when a type was expected
2-
--> $DIR/const-arg-type-arg-misordered.rs:6:35
2+
--> $DIR/const-arg-type-arg-misordered.rs:8:35
33
|
44
LL | fn foo<const N: usize>() -> Array<N, ()> {
55
| ^
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0747]: constant provided when a type was expected
2+
--> $DIR/const-arg-type-arg-misordered.rs:8:35
3+
|
4+
LL | fn foo<const N: usize>() -> Array<N, ()> {
5+
| ^
6+
|
7+
= note: type arguments must be provided before constant arguments
8+
= help: reorder the arguments: types, then consts: `<T, N>`
9+
10+
error: aborting due to previous error
11+
12+
For more information about this error, try `rustc --explain E0747`.

src/test/ui/const-generics/const-arg-type-arg-misordered.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
#![feature(const_generics)]
2-
#![allow(incomplete_features)]
1+
// revisions: full min
2+
#![cfg_attr(full, feature(const_generics))]
3+
#![cfg_attr(full, allow(incomplete_features))]
4+
#![cfg_attr(min, feature(min_const_generics))]
35

46
type Array<T, const N: usize> = [T; N];
57

6-
fn foo<const N: usize>() -> Array<N, ()> { //~ ERROR constant provided when a type was expected
8+
fn foo<const N: usize>() -> Array<N, ()> {
9+
//~^ ERROR constant provided when a type was expected
710
unimplemented!()
811
}
912

src/test/ui/const-generics/const-param-before-other-params.stderr renamed to src/test/ui/const-generics/const-param-before-other-params.full.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: lifetime parameters must be declared prior to const parameters
2-
--> $DIR/const-param-before-other-params.rs:4:21
2+
--> $DIR/const-param-before-other-params.rs:6:21
33
|
44
LL | fn bar<const X: (), 'a>(_: &'a ()) {
55
| --------------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, const X: ()>`
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
error: lifetime parameters must be declared prior to const parameters
2+
--> $DIR/const-param-before-other-params.rs:6:21
3+
|
4+
LL | fn bar<const X: (), 'a>(_: &'a ()) {
5+
| --------------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, const X: ()>`
6+
7+
error: type parameters must be declared prior to const parameters
8+
--> $DIR/const-param-before-other-params.rs:11:21
9+
|
10+
LL | fn foo<const X: (), T>(_: &T) {}
11+
| --------------^- help: reorder the parameters: lifetimes, then types, then consts: `<T, const X: ()>`
12+
13+
error: `()` is forbidden as the type of a const generic parameter
14+
--> $DIR/const-param-before-other-params.rs:6:17
15+
|
16+
LL | fn bar<const X: (), 'a>(_: &'a ()) {
17+
| ^^
18+
|
19+
= note: the only supported types are integers, `bool` and `char`
20+
= note: more complex types are supported with `#[feature(const_generics)]`
21+
22+
error: `()` is forbidden as the type of a const generic parameter
23+
--> $DIR/const-param-before-other-params.rs:11:17
24+
|
25+
LL | fn foo<const X: (), T>(_: &T) {}
26+
| ^^
27+
|
28+
= note: the only supported types are integers, `bool` and `char`
29+
= note: more complex types are supported with `#[feature(const_generics)]`
30+
31+
error: aborting due to 4 previous errors
32+
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
#![allow(incomplete_features)]
2-
#![feature(const_generics)]
1+
// revisions: full min
2+
#![cfg_attr(full, feature(const_generics))]
3+
#![cfg_attr(full, allow(incomplete_features))]
4+
#![cfg_attr(min, feature(min_const_generics))]
35

46
fn bar<const X: (), 'a>(_: &'a ()) {
57
//~^ ERROR lifetime parameters must be declared prior to const parameters
8+
//[min]~^^ ERROR `()` is forbidden as the type of a const generic parameter
69
}
710

811
fn foo<const X: (), T>(_: &T) {}
12+
//[min]~^ ERROR type parameters must be declared prior to const parameters
13+
//[min]~^^ ERROR `()` is forbidden as the type of a const generic parameter
914

1015
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0741]: `&'static (dyn A + 'static)` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter
2+
--> $DIR/issue-63322-forbid-dyn.rs:10:18
3+
|
4+
LL | fn test<const T: &'static dyn A>() {
5+
| ^^^^^^^^^^^^^^ `&'static (dyn A + 'static)` doesn't derive both `PartialEq` and `Eq`
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0741`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
error: `&'static (dyn A + 'static)` is forbidden as the type of a const generic parameter
2+
--> $DIR/issue-63322-forbid-dyn.rs:10:18
3+
|
4+
LL | fn test<const T: &'static dyn A>() {
5+
| ^^^^^^^^^^^^^^
6+
|
7+
= note: the only supported types are integers, `bool` and `char`
8+
= note: more complex types are supported with `#[feature(const_generics)]`
9+
10+
error[E0741]: `&'static (dyn A + 'static)` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter
11+
--> $DIR/issue-63322-forbid-dyn.rs:10:18
12+
|
13+
LL | fn test<const T: &'static dyn A>() {
14+
| ^^^^^^^^^^^^^^ `&'static (dyn A + 'static)` doesn't derive both `PartialEq` and `Eq`
15+
16+
error: aborting due to 2 previous errors
17+
18+
For more information about this error, try `rustc --explain E0741`.

src/test/ui/const-generics/issues/issue-63322-forbid-dyn.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
#![feature(const_generics)]
2-
//~^ WARN the feature `const_generics` is incomplete
1+
// revisions: full min
2+
#![cfg_attr(full, feature(const_generics))]
3+
#![cfg_attr(full, allow(incomplete_features))]
4+
#![cfg_attr(min, feature(min_const_generics))]
35

46
trait A {}
57
struct B;
68
impl A for B {}
79

810
fn test<const T: &'static dyn A>() {
911
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` to be used
12+
//[min]~^^ ERROR `&'static (dyn A + 'static)` is forbidden
1013
unimplemented!()
1114
}
1215

src/test/ui/const-generics/issues/issue-63322-forbid-dyn.stderr

-18
This file was deleted.

src/test/ui/const-generics/issues/issue-64494.stderr renamed to src/test/ui/const-generics/issues/issue-64494.full.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error: constant expression depends on a generic parameter
2-
--> $DIR/issue-64494.rs:14:53
2+
--> $DIR/issue-64494.rs:16:53
33
|
44
LL | impl<T: Foo> MyTrait for T where Is<{T::VAL == 5}>: True {}
55
| ^^^^
66
|
77
= note: this may fail depending on what value the parameter takes
88

99
error: constant expression depends on a generic parameter
10-
--> $DIR/issue-64494.rs:16:53
10+
--> $DIR/issue-64494.rs:19:53
1111
|
1212
LL | impl<T: Foo> MyTrait for T where Is<{T::VAL == 6}>: True {}
1313
| ^^^^
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
error: generic parameters must not be used inside of non trivial constant values
2+
--> $DIR/issue-64494.rs:16:38
3+
|
4+
LL | impl<T: Foo> MyTrait for T where Is<{T::VAL == 5}>: True {}
5+
| ^^^^^^ non-trivial anonymous constants must not depend on the parameter `T`
6+
|
7+
= help: it is currently only allowed to use either `T` or `{ T }` as generic constants
8+
9+
error: generic parameters must not be used inside of non trivial constant values
10+
--> $DIR/issue-64494.rs:19:38
11+
|
12+
LL | impl<T: Foo> MyTrait for T where Is<{T::VAL == 6}>: True {}
13+
| ^^^^^^ non-trivial anonymous constants must not depend on the parameter `T`
14+
|
15+
= help: it is currently only allowed to use either `T` or `{ T }` as generic constants
16+
17+
error[E0119]: conflicting implementations of trait `MyTrait`:
18+
--> $DIR/issue-64494.rs:19:1
19+
|
20+
LL | impl<T: Foo> MyTrait for T where Is<{T::VAL == 5}>: True {}
21+
| ------------------------------------ first implementation here
22+
...
23+
LL | impl<T: Foo> MyTrait for T where Is<{T::VAL == 6}>: True {}
24+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation
25+
26+
error: aborting due to 3 previous errors
27+
28+
For more information about this error, try `rustc --explain E0119`.

src/test/ui/const-generics/issues/issue-64494.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
#![feature(const_generics)]
2-
#![allow(incomplete_features)]
1+
// revisions: full min
2+
#![cfg_attr(full, feature(const_generics))]
3+
#![cfg_attr(full, allow(incomplete_features))]
4+
#![cfg_attr(min, feature(min_const_generics))]
35

46
trait Foo {
57
const VAL: usize;
@@ -12,8 +14,11 @@ struct Is<const T: bool>;
1214
impl True for Is<{true}> {}
1315

1416
impl<T: Foo> MyTrait for T where Is<{T::VAL == 5}>: True {}
15-
//~^ ERROR constant expression depends on a generic parameter
17+
//[full]~^ ERROR constant expression depends on a generic parameter
18+
//[min]~^^ ERROR generic parameters must not be used inside of non trivial constant values
1619
impl<T: Foo> MyTrait for T where Is<{T::VAL == 6}>: True {}
17-
//~^ ERROR constant expression depends on a generic parameter
20+
//[full]~^ ERROR constant expression depends on a generic parameter
21+
//[min]~^^ ERROR generic parameters must not be used inside of non trivial constant values
22+
//[min]~| ERROR conflicting implementations of trait `MyTrait`
1823

1924
fn main() {}

src/test/ui/const-generics/issues/issue-64519.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// check-pass
2-
3-
#![feature(const_generics)]
4-
//~^ WARN the feature `const_generics` is incomplete
2+
// revisions: full min
3+
#![cfg_attr(full, feature(const_generics))]
4+
#![cfg_attr(full, allow(incomplete_features))]
5+
#![cfg_attr(min, feature(min_const_generics))]
56

67
struct Foo<const D: usize> {
78
state: Option<[u8; D]>,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: constant expression depends on a generic parameter
2+
--> $DIR/issue-66205.rs:8:12
3+
|
4+
LL | fact::<{ N - 1 }>();
5+
| ^^^^^^^^^
6+
|
7+
= note: this may fail depending on what value the parameter takes
8+
9+
error: aborting due to previous error
10+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: generic parameters must not be used inside of non trivial constant values
2+
--> $DIR/issue-66205.rs:8:14
3+
|
4+
LL | fact::<{ N - 1 }>();
5+
| ^ non-trivial anonymous constants must not depend on the parameter `N`
6+
|
7+
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
8+
9+
error: aborting due to previous error
10+
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
// revisions: full min
2+
#![cfg_attr(full, feature(const_generics))]
3+
#![cfg_attr(full, allow(incomplete_features))]
4+
#![cfg_attr(min, feature(min_const_generics))]
15
#![allow(dead_code, unconditional_recursion)]
2-
#![feature(const_generics)]
3-
//~^ WARN the feature `const_generics` is incomplete
46

57
fn fact<const N: usize>() {
68
fact::<{ N - 1 }>();
7-
//~^ ERROR constant expression depends on a generic parameter
9+
//[full]~^ ERROR constant expression depends on a generic parameter
10+
//[min]~^^ ERROR generic parameters must not be used inside of non trivial constant values
811
}
912

1013
fn main() {}

0 commit comments

Comments
 (0)