Skip to content

Commit

Permalink
Add UI test for the variance of types appearing in consts
Browse files Browse the repository at this point in the history
  • Loading branch information
voidc committed Oct 12, 2021
1 parent 8b141a2 commit 59b36bc
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/test/ui/variance/variance-associated-consts.rs
Original file line number Diff line number Diff line change
@@ -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 changes: 10 additions & 0 deletions src/test/ui/variance/variance-associated-consts.stderr
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 59b36bc

Please sign in to comment.