Add UI test for the variance of types appearing in consts
This commit is contained in:
parent
8b141a24d0
commit
59b36bcfb5
2 changed files with 27 additions and 0 deletions
17
src/test/ui/variance/variance-associated-consts.rs
Normal file
17
src/test/ui/variance/variance-associated-consts.rs
Normal 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() { }
|
10
src/test/ui/variance/variance-associated-consts.stderr
Normal file
10
src/test/ui/variance/variance-associated-consts.stderr
Normal 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
|
||||
|
Loading…
Add table
Reference in a new issue