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