Skip to content

Commit 1a7d9f5

Browse files
committed
Auto merge of rust-lang#75322 - JulianKnodt:revisions, r=lcnr
Add a bunch of const-generic revisions for `min_const_generics` This adds a bunch of revisions to `const-generic` tests which is part of rust-lang#75279, but doesn't cover everything. r? @lcnr
2 parents 3fbed17 + 5c0b416 commit 1a7d9f5

File tree

155 files changed

+1325
-853
lines changed

Some content is hidden

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

155 files changed

+1325
-853
lines changed

src/test/ui/const-generics/apit-with-const-param.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// check-pass
2+
// revisions: full min
23

3-
#![feature(const_generics)]
4-
//~^ WARN the feature `const_generics` is incomplete
4+
#![cfg_attr(full, feature(const_generics))]
5+
#![cfg_attr(full, allow(incomplete_features))]
6+
#![cfg_attr(min, feature(min_const_generics))]
57

68
trait Trait {}
79

src/test/ui/const-generics/apit-with-const-param.stderr

-11
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
error: constant expression depends on a generic parameter
2+
--> $DIR/array-size-in-generic-struct-param.rs:9:38
3+
|
4+
LL | struct ArithArrayLen<const N: usize>([u32; 0 + N]);
5+
| ^^^^^^^^^^^^
6+
|
7+
= note: this may fail depending on what value the parameter takes
8+
9+
error: constant expression depends on a generic parameter
10+
--> $DIR/array-size-in-generic-struct-param.rs:20:10
11+
|
12+
LL | arr: [u8; CFG.arr_size],
13+
| ^^^^^^^^^^^^^^^^^^
14+
|
15+
= note: this may fail depending on what value the parameter takes
16+
17+
error: aborting due to 2 previous errors
18+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
error: generic parameters must not be used inside of non trivial constant values
2+
--> $DIR/array-size-in-generic-struct-param.rs:9:48
3+
|
4+
LL | struct ArithArrayLen<const N: usize>([u32; 0 + N]);
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: generic parameters must not be used inside of non trivial constant values
10+
--> $DIR/array-size-in-generic-struct-param.rs:20:15
11+
|
12+
LL | arr: [u8; CFG.arr_size],
13+
| ^^^ non-trivial anonymous constants must not depend on the parameter `CFG`
14+
|
15+
= help: it is currently only allowed to use either `CFG` or `{ CFG }` as generic constants
16+
17+
error: using `Config` as const generic parameters is forbidden
18+
--> $DIR/array-size-in-generic-struct-param.rs:18:21
19+
|
20+
LL | struct B<const CFG: Config> {
21+
| ^^^^^^
22+
|
23+
= note: the only supported types are integers, `bool` and `char`
24+
= note: more complex types are supported with `#[feature(const_generics)]`
25+
26+
error: aborting due to 3 previous errors
27+

src/test/ui/const-generics/array-size-in-generic-struct-param.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
1-
#![feature(const_generics)]
2-
//~^ WARN the feature `const_generics` is incomplete
1+
// Tests that array sizes that depend on const-params are checked using `ConstEvaluatable`.
2+
// revisions: full min
3+
4+
#![cfg_attr(full, feature(const_generics))]
5+
#![cfg_attr(full, allow(incomplete_features))]
6+
#![cfg_attr(min, feature(min_const_generics))]
37

48
#[allow(dead_code)]
59
struct ArithArrayLen<const N: usize>([u32; 0 + N]);
6-
//~^ ERROR constant expression depends on a generic parameter
10+
//[full]~^ ERROR constant expression depends on a generic parameter
11+
//[min]~^^ ERROR generic parameters must not be used inside of non trivial constant values
712

813
#[derive(PartialEq, Eq)]
914
struct Config {
1015
arr_size: usize,
1116
}
1217

1318
struct B<const CFG: Config> {
14-
arr: [u8; CFG.arr_size], //~ ERROR constant expression depends on a generic parameter
19+
//[min]~^ ERROR using `Config` as const generic parameters is forbidden
20+
arr: [u8; CFG.arr_size],
21+
//[full]~^ ERROR constant expression depends on a generic parameter
22+
//[min]~^^ ERROR generic parameters must not be used inside of non trivial
1523
}
1624

1725
const C: Config = Config { arr_size: 5 };

src/test/ui/const-generics/array-size-in-generic-struct-param.stderr

-27
This file was deleted.

src/test/ui/const-generics/broken-mir-1.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// run-pass
2+
// revisions: full min
23

3-
#![feature(const_generics)]
4-
//~^ WARN the feature `const_generics` is incomplete
4+
#![cfg_attr(full, feature(const_generics))]
5+
#![cfg_attr(full, allow(incomplete_features))]
6+
#![cfg_attr(min, feature(min_const_generics))]
57

68
pub trait Foo {
79
fn foo(&self);

src/test/ui/const-generics/broken-mir-1.stderr

-11
This file was deleted.

src/test/ui/const-generics/broken-mir-2.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// run-pass
2+
// revisions: full min
23

3-
#![feature(const_generics)]
4-
//~^ WARN the feature `const_generics` is incomplete
4+
#![cfg_attr(full, feature(const_generics))]
5+
#![cfg_attr(full, allow(incomplete_features))]
6+
#![cfg_attr(min, feature(min_const_generics))]
57

68
use std::fmt::Debug;
79

src/test/ui/const-generics/broken-mir-2.stderr

-11
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0282]: type annotations needed
2+
--> $DIR/cannot-infer-const-args.rs:12:5
3+
|
4+
LL | foo();
5+
| ^^^
6+
|
7+
= note: unable to infer the value of a const parameter
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0282`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0282]: type annotations needed
2+
--> $DIR/cannot-infer-const-args.rs:12:5
3+
|
4+
LL | foo();
5+
| ^^^
6+
|
7+
= note: unable to infer the value of a const parameter
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0282`.

src/test/ui/const-generics/cannot-infer-const-args.rs

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

47
fn foo<const X: usize>() -> usize {
58
0

src/test/ui/const-generics/cannot-infer-const-args.stderr

-20
This file was deleted.

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

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

58
fn foo<const N: usize>(v: &[u8; N]) -> &[u8] {
69
v

src/test/ui/const-generics/concrete-const-as-fn-arg.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
// Test that a concrete const type i.e. A<2>, can be used as an argument type in a function
22
// run-pass
3+
// revisions: full min
34

4-
#![feature(const_generics)]
5-
//~^ WARN the feature `const_generics` is incomplete
5+
#![cfg_attr(full, feature(const_generics))]
6+
#![cfg_attr(full, allow(incomplete_features))]
7+
#![cfg_attr(min, feature(min_const_generics))]
68

79
struct A<const N: usize>; // ok
810

src/test/ui/const-generics/concrete-const-as-fn-arg.stderr

-11
This file was deleted.

src/test/ui/const-generics/concrete-const-impl-method.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
// Test that a method/associated non-method within an impl block of a concrete const type i.e. A<2>,
22
// is callable.
33
// run-pass
4+
// revisions: full min
45

5-
#![feature(const_generics)]
6-
//~^ WARN the feature `const_generics` is incomplete
6+
#![cfg_attr(full, feature(const_generics))]
7+
#![cfg_attr(full, allow(incomplete_features))]
8+
#![cfg_attr(min, feature(min_const_generics))]
79

810
pub struct A<const N: u32>;
911

src/test/ui/const-generics/concrete-const-impl-method.stderr

-11
This file was deleted.

src/test/ui/const-generics/condition-in-trait-const-arg.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
// Checks that `impl Trait<{anon_const}> for Type` evaluates successfully.
12
// run-pass
3+
// revisions: full min
24

3-
#![feature(const_generics)]
4-
//~^ WARN the feature `const_generics` is incomplete
5+
#![cfg_attr(full, feature(const_generics))]
6+
#![cfg_attr(full, allow(incomplete_features))]
7+
#![cfg_attr(min, feature(min_const_generics))]
58

69
trait IsZeroTrait<const IS_ZERO: bool>{}
710

src/test/ui/const-generics/condition-in-trait-const-arg.stderr

-11
This file was deleted.

src/test/ui/const-generics/const-arg-in-fn.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// run-pass
2+
// revisions: full min
23

3-
#![feature(const_generics)]
4-
//~^ WARN the feature `const_generics` is incomplete
4+
#![cfg_attr(full, feature(const_generics))]
5+
#![cfg_attr(full, allow(incomplete_features))]
6+
#![cfg_attr(min, feature(min_const_generics))]
57

68
fn const_u32_identity<const X: u32>() -> u32 {
79
X

src/test/ui/const-generics/const-arg-in-fn.stderr

-11
This file was deleted.

src/test/ui/const-generics/const-argument-non-static-lifetime.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// run-pass
2+
// revisions: full
3+
// FIXME(#75323) Omitted min revision for now due to ICE.
24

3-
#![feature(const_generics)]
4-
//~^ WARN the feature `const_generics` is incomplete
5+
#![cfg_attr(full, feature(const_generics))]
6+
#![cfg_attr(full, allow(incomplete_features))]
57
#![allow(dead_code)]
68

79
fn test<const N: usize>() {}

src/test/ui/const-generics/const-argument-non-static-lifetime.stderr

-11
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: expected one of `,` or `>`, found `+`
2+
--> $DIR/const-expression-parameter.rs:16:22
3+
|
4+
LL | i32_identity::<1 + 2>();
5+
| ^ expected one of `,` or `>`
6+
7+
error: aborting due to previous error
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: expected one of `,` or `>`, found `+`
2+
--> $DIR/const-expression-parameter.rs:16:22
3+
|
4+
LL | i32_identity::<1 + 2>();
5+
| ^ expected one of `,` or `>`
6+
7+
error: aborting due to previous error
8+

src/test/ui/const-generics/const-expression-parameter.rs

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

47
fn i32_identity<const X: i32>() -> i32 {
58
5

0 commit comments

Comments
 (0)