Skip to content

Commit 5d251fb

Browse files
committed
add a ui test for Lazy{Cell,Lock} variance
1 parent ea46f9e commit 5d251fb

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Check that certain library types have correct variance.
2+
#![feature(rustc_attrs)]
3+
4+
5+
#[rustc_dump_variances]
6+
struct LazyCellIsCovariantOnlyInF<T, F>(std::cell::LazyCell<T, F>); //~ ERROR [T: o, F: +]
7+
8+
#[rustc_dump_variances]
9+
struct LazyLockIsCovariantOnlyInF<T, F>(std::sync::LazyLock<T, F>); //~ ERROR [T: o, F: +]
10+
11+
pub fn main() {}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error: [T: o, F: +]
2+
--> $DIR/variance-library-types.rs:6:1
3+
|
4+
LL | struct LazyCellIsCovariantOnlyInF<T, F>(std::cell::LazyCell<T, F>);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
7+
error: [T: o, F: +]
8+
--> $DIR/variance-library-types.rs:9:1
9+
|
10+
LL | struct LazyLockIsCovariantOnlyInF<T, F>(std::sync::LazyLock<T, F>);
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
13+
error: aborting due to 2 previous errors
14+

0 commit comments

Comments
 (0)