summaryrefslogtreecommitdiff
path: root/tests/compile/async_any_userdata_method.stderr
blob: 6790fbc21bea0f13cdee3d6681ea5d84230ba7ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
error: lifetime may not live long enough
  --> tests/compile/async_any_userdata_method.rs:9:58
   |
9  |           reg.add_async_method("t", |_, this: &String, ()| async {
   |  ___________________________________----------------------_^
   | |                                   |                    |
   | |                                   |                    return type of closure `[async block@$DIR/tests/compile/async_any_userdata_method.rs:9:58: 12:10]` contains a lifetime `'2`
   | |                                   lifetime `'1` represents this closure's body
10 | |             s = this;
11 | |             Ok(())
12 | |         });
   | |_________^ returning this value requires that `'1` must outlive `'2`
   |
   = note: closure implements `Fn`, so references to captured variables can't escape the closure

error[E0596]: cannot borrow `s` as mutable, as it is a captured variable in a `Fn` closure
  --> tests/compile/async_any_userdata_method.rs:9:58
   |
9  |           reg.add_async_method("t", |_, this: &String, ()| async {
   |  __________________________________________________________^
10 | |             s = this;
   | |             - mutable borrow occurs due to use of `s` in closure
11 | |             Ok(())
12 | |         });
   | |_________^ cannot borrow as mutable

error[E0597]: `s` does not live long enough
  --> tests/compile/async_any_userdata_method.rs:8:21
   |
8  |           let mut s = &s;
   |                       ^^ borrowed value does not live long enough
9  | /         reg.add_async_method("t", |_, this: &String, ()| async {
10 | |             s = this;
11 | |             Ok(())
12 | |         });
   | |__________- argument requires that `s` is borrowed for `'static`
13 |       }).unwrap();
   |       - `s` dropped here while still borrowed

error[E0521]: borrowed data escapes outside of closure
  --> tests/compile/async_any_userdata_method.rs:9:9
   |
6  |       lua.register_userdata_type::<String>(|reg| {
   |                                             ---
   |                                             |
   |                                             `reg` is a reference that is only valid in the closure body
   |                                             has type `&mut LuaUserDataRegistrar<'1, std::string::String>`
...
9  | /         reg.add_async_method("t", |_, this: &String, ()| async {
10 | |             s = this;
11 | |             Ok(())
12 | |         });
   | |          ^
   | |          |
   | |__________`reg` escapes the closure body here
   |            argument requires that `'1` must outlive `'static`
   |
   = note: requirement occurs because of a mutable reference to `LuaUserDataRegistrar<'_, std::string::String>`
   = note: mutable references are invariant over their type parameter
   = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance

error[E0373]: closure may outlive the current function, but it borrows `s`, which is owned by the current function
  --> tests/compile/async_any_userdata_method.rs:9:35
   |
9  |         reg.add_async_method("t", |_, this: &String, ()| async {
   |                                   ^^^^^^^^^^^^^^^^^^^^^^ may outlive borrowed value `s`
10 |             s = this;
   |             - `s` is borrowed here
   |
note: function requires argument type to outlive `'static`
  --> tests/compile/async_any_userdata_method.rs:9:9
   |
9  | /         reg.add_async_method("t", |_, this: &String, ()| async {
10 | |             s = this;
11 | |             Ok(())
12 | |         });
   | |__________^
help: to force the closure to take ownership of `s` (and any other referenced variables), use the `move` keyword
   |
9  |         reg.add_async_method("t", move |_, this: &String, ()| async {
   |                                   ++++