rust/tests/ui/variance/variance-cell-is-invariant.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

20 lines
414 B
Rust
Raw Normal View History

// Test that Cell is considered invariant with respect to its
// type.
use std::cell::Cell;
struct Foo<'a> {
x: Cell<Option<&'a isize>>,
}
fn use_<'short,'long>(c: Foo<'short>,
s: &'short isize,
l: &'long isize,
_where:Option<&'short &'long ()>) {
2022-04-01 21:12:17 -05:00
let _: Foo<'long> = c;
2022-04-01 12:13:25 -05:00
//~^ ERROR lifetime may not live long enough
}
fn main() {
}