Skip to content

Commit 6407580

Browse files
authored
Rollup merge of #127243 - BoxyUwU:new_invalid_const_param_ty_test, r=compiler-errors
Add test for adt_const_params Fixes #84238 r? `@compiler-errors`
2 parents a10c231 + 1df876f commit 6407580

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#![feature(adt_const_params)]
2+
#![allow(incomplete_features)]
3+
4+
use std::marker::ConstParamTy;
5+
6+
#[derive(ConstParamTy)]
7+
//~^ the trait `ConstParamTy` cannot be implemented for this ty
8+
struct Foo([*const u8; 1]);
9+
10+
#[derive(ConstParamTy)]
11+
//~^ the trait `ConstParamTy` cannot be implemented for this ty
12+
struct Foo2([*mut u8; 1]);
13+
14+
#[derive(ConstParamTy)]
15+
//~^ the trait `ConstParamTy` cannot be implemented for this ty
16+
struct Foo3([fn(); 1]);
17+
18+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
error[E0204]: the trait `ConstParamTy` cannot be implemented for this type
2+
--> $DIR/nested_bad_const_param_ty.rs:6:10
3+
|
4+
LL | #[derive(ConstParamTy)]
5+
| ^^^^^^^^^^^^
6+
LL |
7+
LL | struct Foo([*const u8; 1]);
8+
| -------------- this field does not implement `ConstParamTy`
9+
|
10+
note: the `ConstParamTy` impl for `[*const u8; 1]` requires that `*const u8: ConstParamTy`
11+
--> $DIR/nested_bad_const_param_ty.rs:8:12
12+
|
13+
LL | struct Foo([*const u8; 1]);
14+
| ^^^^^^^^^^^^^^
15+
= note: this error originates in the derive macro `ConstParamTy` (in Nightly builds, run with -Z macro-backtrace for more info)
16+
17+
error[E0204]: the trait `ConstParamTy` cannot be implemented for this type
18+
--> $DIR/nested_bad_const_param_ty.rs:10:10
19+
|
20+
LL | #[derive(ConstParamTy)]
21+
| ^^^^^^^^^^^^
22+
LL |
23+
LL | struct Foo2([*mut u8; 1]);
24+
| ------------ this field does not implement `ConstParamTy`
25+
|
26+
note: the `ConstParamTy` impl for `[*mut u8; 1]` requires that `*mut u8: ConstParamTy`
27+
--> $DIR/nested_bad_const_param_ty.rs:12:13
28+
|
29+
LL | struct Foo2([*mut u8; 1]);
30+
| ^^^^^^^^^^^^
31+
= note: this error originates in the derive macro `ConstParamTy` (in Nightly builds, run with -Z macro-backtrace for more info)
32+
33+
error[E0204]: the trait `ConstParamTy` cannot be implemented for this type
34+
--> $DIR/nested_bad_const_param_ty.rs:14:10
35+
|
36+
LL | #[derive(ConstParamTy)]
37+
| ^^^^^^^^^^^^
38+
LL |
39+
LL | struct Foo3([fn(); 1]);
40+
| --------- this field does not implement `ConstParamTy`
41+
|
42+
note: the `ConstParamTy` impl for `[fn(); 1]` requires that `fn(): ConstParamTy`
43+
--> $DIR/nested_bad_const_param_ty.rs:16:13
44+
|
45+
LL | struct Foo3([fn(); 1]);
46+
| ^^^^^^^^^
47+
= note: this error originates in the derive macro `ConstParamTy` (in Nightly builds, run with -Z macro-backtrace for more info)
48+
49+
error: aborting due to 3 previous errors
50+
51+
For more information about this error, try `rustc --explain E0204`.

0 commit comments

Comments
 (0)