-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add UI test for the variance of types appearing in consts
- Loading branch information
Showing
2 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|