Skip to content

Commit 59b36bc

Browse files
committed
Add UI test for the variance of types appearing in consts
1 parent 8b141a2 commit 59b36bc

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Test that the variance computation considers types that
2+
// appear in const expressions to be invariant.
3+
4+
#![feature(rustc_attrs)]
5+
#![allow(incomplete_features)]
6+
#![feature(generic_const_exprs)]
7+
8+
trait Trait {
9+
const Const: usize;
10+
}
11+
12+
#[rustc_variance]
13+
struct Foo<T: Trait> { //~ ERROR [o]
14+
field: [u8; <T as Trait>::Const]
15+
}
16+
17+
fn main() { }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error[E0208]: [o]
2+
--> $DIR/variance-associated-consts.rs:13:1
3+
|
4+
LL | / struct Foo<T: Trait> {
5+
LL | | field: [u8; <T as Trait>::Const]
6+
LL | | }
7+
| |_^
8+
9+
error: aborting due to previous error
10+

0 commit comments

Comments
 (0)