Skip to content

Commit be650a7

Browse files
committed
Add a bunch of revisions
This adds a bunch of revisions to const-generic tests
1 parent c94ed5c commit be650a7

31 files changed

+305
-38
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error: using raw pointers as const generic parameters is forbidden
2+
--> $DIR/raw-ptr-const-param-deref.rs:10:23
3+
|
4+
LL | struct Const<const P: *const u32>;
5+
| ^^^^^^^^^^
6+
7+
error: using raw pointers as const generic parameters is forbidden
8+
--> $DIR/raw-ptr-const-param-deref.rs:12:15
9+
|
10+
LL | impl<const P: *const u32> Const<P> {
11+
| ^^^^^^^^^^
12+
13+
error: aborting due to 2 previous errors
14+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
error: using raw pointers as const generic parameters is forbidden
2+
--> $DIR/raw-ptr-const-param-deref.rs:10:23
3+
|
4+
LL | struct Const<const P: *const u32>;
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: using raw pointers as const generic parameters is forbidden
11+
--> $DIR/raw-ptr-const-param-deref.rs:12:15
12+
|
13+
LL | impl<const P: *const u32> Const<P> {
14+
| ^^^^^^^^^^
15+
|
16+
= note: the only supported types are integers, `bool` and `char`
17+
= note: more complex types are supported with `#[feature(const_generics)]`
18+
19+
error: aborting due to 2 previous errors
20+

src/test/ui/const-generics/raw-ptr-const-param-deref.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
#![feature(const_generics)]
2-
//~^ WARN the feature `const_generics` is incomplete
1+
// Assert that cannot use const generics as ptrs and cannot deref them.
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
const A: u32 = 3;
59

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: using raw pointers as const generic parameters is forbidden
2+
--> $DIR/raw-ptr-const-param.rs:7:23
3+
|
4+
LL | struct Const<const P: *const u32>;
5+
| ^^^^^^^^^^
6+
7+
error: aborting due to previous error
8+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error: using raw pointers as const generic parameters is forbidden
2+
--> $DIR/raw-ptr-const-param.rs:7:23
3+
|
4+
LL | struct Const<const P: *const u32>;
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: aborting due to previous error
11+

src/test/ui/const-generics/raw-ptr-const-param.rs

Lines changed: 5 additions & 2 deletions
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
struct Const<const P: *const u32>; //~ ERROR: using raw pointers as const generic parameters
58

src/test/ui/const-generics/slice-const-param-mismatch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![feature(const_generics)]
2-
//~^ WARN the feature `const_generics` is incomplete
2+
#![allow(incomplete_features)]
33

44
struct ConstString<const T: &'static str>;
55
struct ConstBytes<const T: &'static [u8]>;

src/test/ui/const-generics/slice-const-param-mismatch.stderr

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
2-
--> $DIR/slice-const-param-mismatch.rs:1:12
3-
|
4-
LL | #![feature(const_generics)]
5-
| ^^^^^^^^^^^^^^
6-
|
7-
= note: `#[warn(incomplete_features)]` on by default
8-
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
9-
101
error[E0308]: mismatched types
112
--> $DIR/slice-const-param-mismatch.rs:9:35
123
|
@@ -40,6 +31,6 @@ LL | let _: ConstBytes<b"AAA"> = ConstBytes::<b"BBB">;
4031
= note: expected struct `ConstBytes<b"AAA">`
4132
found struct `ConstBytes<b"BBB">`
4233

43-
error: aborting due to 3 previous errors; 1 warning emitted
34+
error: aborting due to 3 previous errors
4435

4536
For more information about this error, try `rustc --explain E0308`.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
error: using `&'static str` as const generic parameters is forbidden
2+
--> $DIR/slice-const-param.rs:8:40
3+
|
4+
LL | pub fn function_with_str<const STRING: &'static str>() -> &'static str {
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: using `&'static [u8]` as const generic parameters is forbidden
11+
--> $DIR/slice-const-param.rs:13:41
12+
|
13+
LL | pub fn function_with_bytes<const BYTES: &'static [u8]>() -> &'static [u8] {
14+
| ^^^^^^^^^^^^^
15+
|
16+
= note: the only supported types are integers, `bool` and `char`
17+
= note: more complex types are supported with `#[feature(const_generics)]`
18+
19+
error: aborting due to 2 previous errors
20+

src/test/ui/const-generics/slice-const-param.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
// run-pass
1+
//[full] run-pass
2+
// revisions: min full
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 fn function_with_str<const STRING: &'static str>() -> &'static str {
9+
//[min]~^ ERROR using `&'static str` as const
710
STRING
811
}
912

1013
pub fn function_with_bytes<const BYTES: &'static [u8]>() -> &'static [u8] {
14+
//[min]~^ ERROR using `&'static [u8]` as const
1115
BYTES
1216
}
1317

0 commit comments

Comments
 (0)