Skip to content

Commit 1a7d9f5

Browse files
committed
Auto merge of #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 #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

Lines changed: 4 additions & 2 deletions
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

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 18 additions & 0 deletions
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+
Lines changed: 27 additions & 0 deletions
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

Lines changed: 12 additions & 4 deletions
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

Lines changed: 0 additions & 27 deletions
This file was deleted.

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

Lines changed: 4 additions & 2 deletions
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

Lines changed: 0 additions & 11 deletions
This file was deleted.

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

Lines changed: 4 additions & 2 deletions
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

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)