diff options
| author | Bastian Kauschke <bastian_kauschke@hotmail.de> | 2020-04-11 21:02:49 +0200 |
|---|---|---|
| committer | Bastian Kauschke <bastian_kauschke@hotmail.de> | 2020-04-29 19:29:10 +0200 |
| commit | 9f34b82de203a01b7bb1afd57714886a65dbea8f (patch) | |
| tree | 6baa941ec5460ce864d6ec471d7e14dffa139935 /src/test | |
| parent | 36d13cb01ba6a0a9b7c13ca2b9461a111cb3e395 (diff) | |
| download | rust-9f34b82de203a01b7bb1afd57714886a65dbea8f.tar.gz rust-9f34b82de203a01b7bb1afd57714886a65dbea8f.zip | |
forbid `dyn Trait` in const generics
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-63322-forbid-dyn.rs | 15 | ||||
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-63322-forbid-dyn.stderr | 17 |
2 files changed, 32 insertions, 0 deletions
diff --git a/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.rs b/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.rs new file mode 100644 index 00000000000..2bacd6c9a9c --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.rs @@ -0,0 +1,15 @@ +#![feature(const_generics)] +//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash + +trait A {} +struct B; +impl A for B {} + +fn test<const T: &'static dyn A>() { + //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` to be used + unimplemented!() +} + +fn main() { + test::<{ &B }>(); +} diff --git a/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.stderr b/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.stderr new file mode 100644 index 00000000000..73315af4483 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.stderr @@ -0,0 +1,17 @@ +warning: the feature `const_generics` is incomplete and may cause the compiler to crash + --> $DIR/issue-63322-forbid-dyn.rs:1:12 + | +LL | #![feature(const_generics)] + | ^^^^^^^^^^^^^^ + | + = note: `#[warn(incomplete_features)]` on by default + +error[E0741]: `&'static (dyn A + 'static)` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter + --> $DIR/issue-63322-forbid-dyn.rs:8:18 + | +LL | fn test<const T: &'static dyn A>() { + | ^^^^^^^^^^^^^^ `&'static (dyn A + 'static)` doesn't derive both `PartialEq` and `Eq` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0741`. |
