forbid dyn Trait in const generics
This commit is contained in:
parent
36d13cb01b
commit
9f34b82de2
4 changed files with 40 additions and 0 deletions
15
src/test/ui/const-generics/issues/issue-63322-forbid-dyn.rs
Normal file
15
src/test/ui/const-generics/issues/issue-63322-forbid-dyn.rs
Normal file
|
|
@ -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 }>();
|
||||
}
|
||||
|
|
@ -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`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue