forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#127243 - BoxyUwU:new_invalid_const_param_ty_test, r=compiler-errors Add test for adt_const_params Fixes rust-lang#84238 r? `@compiler-errors`
- Loading branch information
Showing
2 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
tests/ui/const-generics/adt_const_params/nested_bad_const_param_ty.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#![feature(adt_const_params)] | ||
#![allow(incomplete_features)] | ||
|
||
use std::marker::ConstParamTy; | ||
|
||
#[derive(ConstParamTy)] | ||
//~^ the trait `ConstParamTy` cannot be implemented for this ty | ||
struct Foo([*const u8; 1]); | ||
|
||
#[derive(ConstParamTy)] | ||
//~^ the trait `ConstParamTy` cannot be implemented for this ty | ||
struct Foo2([*mut u8; 1]); | ||
|
||
#[derive(ConstParamTy)] | ||
//~^ the trait `ConstParamTy` cannot be implemented for this ty | ||
struct Foo3([fn(); 1]); | ||
|
||
fn main() {} |
51 changes: 51 additions & 0 deletions
51
tests/ui/const-generics/adt_const_params/nested_bad_const_param_ty.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
error[E0204]: the trait `ConstParamTy` cannot be implemented for this type | ||
--> $DIR/nested_bad_const_param_ty.rs:6:10 | ||
| | ||
LL | #[derive(ConstParamTy)] | ||
| ^^^^^^^^^^^^ | ||
LL | | ||
LL | struct Foo([*const u8; 1]); | ||
| -------------- this field does not implement `ConstParamTy` | ||
| | ||
note: the `ConstParamTy` impl for `[*const u8; 1]` requires that `*const u8: ConstParamTy` | ||
--> $DIR/nested_bad_const_param_ty.rs:8:12 | ||
| | ||
LL | struct Foo([*const u8; 1]); | ||
| ^^^^^^^^^^^^^^ | ||
= note: this error originates in the derive macro `ConstParamTy` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error[E0204]: the trait `ConstParamTy` cannot be implemented for this type | ||
--> $DIR/nested_bad_const_param_ty.rs:10:10 | ||
| | ||
LL | #[derive(ConstParamTy)] | ||
| ^^^^^^^^^^^^ | ||
LL | | ||
LL | struct Foo2([*mut u8; 1]); | ||
| ------------ this field does not implement `ConstParamTy` | ||
| | ||
note: the `ConstParamTy` impl for `[*mut u8; 1]` requires that `*mut u8: ConstParamTy` | ||
--> $DIR/nested_bad_const_param_ty.rs:12:13 | ||
| | ||
LL | struct Foo2([*mut u8; 1]); | ||
| ^^^^^^^^^^^^ | ||
= note: this error originates in the derive macro `ConstParamTy` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error[E0204]: the trait `ConstParamTy` cannot be implemented for this type | ||
--> $DIR/nested_bad_const_param_ty.rs:14:10 | ||
| | ||
LL | #[derive(ConstParamTy)] | ||
| ^^^^^^^^^^^^ | ||
LL | | ||
LL | struct Foo3([fn(); 1]); | ||
| --------- this field does not implement `ConstParamTy` | ||
| | ||
note: the `ConstParamTy` impl for `[fn(); 1]` requires that `fn(): ConstParamTy` | ||
--> $DIR/nested_bad_const_param_ty.rs:16:13 | ||
| | ||
LL | struct Foo3([fn(); 1]); | ||
| ^^^^^^^^^ | ||
= note: this error originates in the derive macro `ConstParamTy` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0204`. |