about summary refs log tree commit diff
path: root/src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.rs
blob: 4690f9d8b08fc9025f3d3a8404f1e30d914235aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir

struct Invariant<'a> {
    f: Box<dyn FnOnce(&mut &'a isize) + 'static>,
}

fn to_same_lifetime<'r>(b_isize: Invariant<'r>) {
    let bj: Invariant<'r> = b_isize;
}

fn to_longer_lifetime<'r>(b_isize: Invariant<'r>) -> Invariant<'static> {
    b_isize
    //[base]~^ ERROR mismatched types
    //[nll]~^^ ERROR lifetime may not live long enough
}

fn main() {
}