2014-01-22 13:03:02 -06:00
|
|
|
// Test that Cell is considered invariant with respect to its
|
|
|
|
// type.
|
|
|
|
|
2022-04-01 21:12:17 -05:00
|
|
|
// revisions: base nll
|
|
|
|
// ignore-compare-mode-nll
|
|
|
|
//[nll] compile-flags: -Z borrowck=mir
|
|
|
|
|
2014-01-22 13:03:02 -06:00
|
|
|
use std::cell::Cell;
|
|
|
|
|
|
|
|
struct Foo<'a> {
|
2015-01-08 04:54:35 -06:00
|
|
|
x: Cell<Option<&'a isize>>,
|
2014-01-22 13:03:02 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn use_<'short,'long>(c: Foo<'short>,
|
2015-01-08 04:54:35 -06:00
|
|
|
s: &'short isize,
|
|
|
|
l: &'long isize,
|
2014-01-22 13:03:02 -06:00
|
|
|
_where:Option<&'short &'long ()>) {
|
2022-04-01 21:12:17 -05:00
|
|
|
let _: Foo<'long> = c;
|
|
|
|
//[base]~^ ERROR E0623
|
|
|
|
//[nll]~^^ ERROR lifetime may not live long enough
|
2014-01-22 13:03:02 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
}
|