Add UI test for the variance of types appearing in consts

This commit is contained in:
Dominik Stolz 2021-10-12 21:50:44 +02:00
parent 8b141a24d0
commit 59b36bcfb5
2 changed files with 27 additions and 0 deletions

View file

@ -0,0 +1,17 @@
// Test that the variance computation considers types that
// appear in const expressions to be invariant.
#![feature(rustc_attrs)]
#![allow(incomplete_features)]
#![feature(generic_const_exprs)]
trait Trait {
const Const: usize;
}
#[rustc_variance]
struct Foo<T: Trait> { //~ ERROR [o]
field: [u8; <T as Trait>::Const]
}
fn main() { }

View file

@ -0,0 +1,10 @@
error[E0208]: [o]
--> $DIR/variance-associated-consts.rs:13:1
|
LL | / struct Foo<T: Trait> {
LL | | field: [u8; <T as Trait>::Const]
LL | | }
| |_^
error: aborting due to previous error