summaryrefslogtreecommitdiff
path: root/tests/compile-fail/scope_escape.rs
blob: 18be7db7f86d6bb2d23cf2aa39583c3731a114d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
extern crate rlua;

use rlua::*;

fn main() {
    struct Test {
        field: i32,
    }

    let lua = Lua::new();
    let mut outer: Option<Function> = None;
    lua.scope(|scope| {
        let f = scope.create_function_mut(|_, ()| Ok(())).unwrap();
        outer = Some(scope.create_function_mut(|_, ()| Ok(())).unwrap());
        //~^ error: borrowed data cannot be stored outside of its closure
    });
}